|
27 | 27 | (defn fetch [url]
|
28 | 28 | (http/get url))
|
29 | 29 |
|
| 30 | +(defonce camera-view-atom (atom nil)) |
| 31 | +(defonce classifier-atom (atom nil)) |
| 32 | + |
| 33 | +(defn some-onResume [^plain.someactivity2.MyActivity this ^android.os.Bundle bundle] |
| 34 | + (.superOnResume this bundle) |
| 35 | + (.start @camera-view-atom)) |
| 36 | + |
| 37 | +(defn some-onPause [^plain.someactivity2.MyActivity this ^android.os.Bundle bundle] |
| 38 | + (.stop @camera-view-atom) |
| 39 | + (.superOnPause this bundle)) |
| 40 | + |
| 41 | +(defn some-onDestroy [^plain.someactivity2.MyActivity this ^android.os.Bundle bundle] |
| 42 | + (.superOnDestroy this bundle) |
| 43 | + ;; executor.execute(new Runnable() { |
| 44 | + ;; @Override |
| 45 | + ;; public void run() { |
| 46 | + ;; classifier.close(); |
| 47 | + ;; } |
| 48 | + ;; }); |
| 49 | + ) |
| 50 | + |
30 | 51 | (defn some-onCreate [^plain.someactivity2.MyActivity this ^android.os.Bundle bundle]
|
31 | 52 | (.superOnCreate this bundle)
|
32 | 53 | (.setContentView this com.example.ndksample.myapplication.R$layout/activity_main)
|
|
39 | 60 | (Log/i "已启动" "clojure repl server")))
|
40 | 61 |
|
41 | 62 | (let [camera-view (.findViewById this com.example.ndksample.myapplication.R$id/cameraView)
|
| 63 | + _ (reset! camera-view-atom camera-view) |
42 | 64 | image-view-result (.findViewById this com.example.ndksample.myapplication.R$id/imageViewResult)
|
43 | 65 | text-view-result (.findViewById this com.example.ndksample.myapplication.R$id/textViewResult)
|
44 | 66 | _ (.setMovementMethod text-view-result (ScrollingMovementMethod.))
|
|
51 | 73 | (onError [^CameraKitError camera-kit-error]
|
52 | 74 | (Log/i "onError" (str camera-kit-error)) )
|
53 | 75 | (onImage [^CameraKitImage camera-kit-image]
|
54 |
| - (Log/i "onImage" "......") ) |
| 76 | + (Log/i "onImage" "......") |
| 77 | + (let [bitmap (.getBitmap camera-kit-image) |
| 78 | + bitmap (Bitmap/createScaledBitmap bitmap 224 224 false) |
| 79 | + _ (.setImageBitmap image-view-result bitmap) |
| 80 | + results (.recognizeImage @classifier-atom bitmap)] |
| 81 | + (.setText text-view-result (.toString results))) ) |
55 | 82 | (onVideo [^CameraKitVideo camera-kit-video] )))
|
56 | 83 | ;;
|
57 | 84 | (.setOnClickListener btn-toggle-camera
|
|
0 commit comments