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.93k stars 1.73k forks source link

No TextureView support #15

Closed bryanstern closed 9 years ago

bryanstern commented 9 years ago

The CameraSource class currently only supports sending preview frames to a SurfaceView. https://developers.google.com/android/reference/com/google/android/gms/vision/CameraSource.html#start(android.view.SurfaceHolder)

It would be great if it also supported TextureView in the same way as this View is much more flexible. The decompiled CameraSource suggests this should be possible as calling CameraSource#start without a SurfaceView will actually send the preview frames to an unused SurfaceTexture.

Working around this with reflection (grabbing the camera, stopping the preview, adding a TextureView, and restarting) is really slow because starting the preview is slow and now happens 2x.

Please let me know if there is a better place to provide this feedback.

pm0733464 commented 9 years ago

The issue with supporting TextureView in the API is that it is not backward compatible to gingerbread, since that class was introduced later in ice cream sandwich. We typically have the official Google Play services APIs fully support devices back to gingerbread.

With that said, the CameraSource class isn't closely tied to the rest of the mobile vision implementation, so the rest of the API could be used without it. If your app doesn't need to support gingerbread devices, it wouldn't be too hard for you to replace CameraSource with your own camera managing class (which used TextureView). The main interaction between the camera source and the detector (and associated pipeline) is this method for sending preview frames into the detector:

https://developers.google.com/android/reference/com/google/android/gms/vision/Detector.html#receiveFrame(com.google.android.gms.vision.Frame)

You'd just need to have your camera managing class call this to pump preview frames into the detector/pipeline.

bryanstern commented 9 years ago

Thanks, thats the route I ultimately ended up going. It would be nice if you could include the CameraSource source.

On a side note, I'm curious why you chose to support API 10+ instead of 14+.

reisub commented 7 years ago

With news about dropping Gingerbread from Play services, do you plan to add TextureView support to mobile vision API?

ajaysaini-sgvu commented 7 years ago

+1

mypplication commented 7 years ago

+1000

AndrewVovk commented 7 years ago

++

ajhool commented 7 years ago

Clarification on this issue: My understanding of this issue is that people want to control the camera using separate logic and only want android-vision to interact with a TextureView rendering. Does android-vision require camera control (eg. to focus on an area of interest)?

If, for instance, a prerecorded mp4 video was playing in a SurfaceView, could android-vision parse out text/objects/barcodes from the video? Modern video players use TextureViews, so it certainly makes sense to add TextureView support for that.