googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

How to rebuild detector after orientation change? #254

Open alex-uspenskyi opened 7 years ago

alex-uspenskyi commented 7 years ago

I'm working on React Native application component that uses vision API.

It works fine in native up but when I launch the same in RN app - face tracker stops working.

I do mCameraSource.stop(); that rebuilds my preview. But I'm getting

inconsistent image dimensions E/pittpatt: detector.cc:220] inconsistent image dimensions E/NativeFaceDetectorImpl: Native face detection failed java.lang.RuntimeException: Error detecting faces.

in Face Tracker. I found somewhere that I need to rebuild tracker but I don't know how.

I've tried mDetector.release(); mProcessor.release();

still having tracking working.

pm0733464 commented 7 years ago

My guess is that the app is somehow passing in images of different size during face tracking. The assumption is that all images passed in are of the same dimension -- this is what you'd expect when using images from the camera, for example.

If you know of an image dimension change (e.g., as a result of rotating the camera) you should stop the camera source and use a new instance of camera source.