-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tflite use USB camera with android image classification app #61445
Comments
Hi @suyash-narain, can you try reviewing this documentation to see if it helps you? https://source.android.com/docs/core/camera |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
Hi @pkgoogle I was trying to replicate https://developer.android.com/training/camerax/configuration#camera-selection and add this snippet to select cameraId using camerax api on the official tflite image classification example using kotlin. The build is successful but the app keeps on crashing. |
Hi @suyash-narain, It's hard for me to tell exactly what you are doing, can you share your code? or just the portion which is causing the issue? Glad to hear that your build is successful. Do you have any errors or error logs you can share as well when it crashes? Generally the more information you share with me the faster/more likely I will be able to help you. Thanks for your help! |
Hi @pkgoogle, my code is sourced from https://github.com/tensorflow/examples/blob/master/lite/examples/image_classification/android/app/src/main/java/org/tensorflow/lite/examples/imageclassification/fragments/CameraFragment.kt The code is below:
In above code, cameraid=103 is determined from my android device with a usb camera connected, using the command: 'dumpsys media.camera' I created another MyCameraFilter.kt which i use in camerafragment.kt as below:
I tried adding CameraSelector.LENS_FACING_EXTERNAL which is part of @ExperimentalLensFacing but my android studio didn't take this annotation at all. Do you have any suggestions how to move forward? my device only supports usb camera, and since camerax contains camera2, i assume i can use camera2 api with camerax interchangeably. How else can i use a usb camera to perform image classification? thanks |
logcat error log on android studio when running the classification app:
|
Hi, @suyash-narain, those are the two ways that makes sense, LENS_FACING_EXTERNAL is experimental so sometimes it doesn't always work. You did say you try it, was there a building error? That information can be helpful. Hi, @miaout17, can you please take a look? Thanks. |
android studio doesn't take LENS_FACING_EXTERNAL and its corresponding annotation. It shows it as an error (marking with red font and a red underline) before the build. So couldn't build with it. using val cameraSelector = CameraSelector.Builder().addCameraFilter(MyCameraFilter("$mCameraId")).build() doesn't lead to any build error, but the app crashes at runtime, and camera is not detected as could be seen from the above posted error log |
System information
provided in TensorFlow): No
Describe the problem
I am new to android and building the tflite image classification app in tensorflow/examples using android studio. I want to make use of a USB camera instead of the mobile back camera to detect the images for classification. How can I achieve that?
What changes do i need to make in CameraFragment.kt to make sure the app can search for a connected USB camera as well? currently the default app only searches for back camera as in this code https://github.com/tensorflow/examples/blob/0bbf4fe43fbf41b7174b9ce4a64d69bd33aadd21/lite/examples/image_classification/android/app/src/main/java/org/tensorflow/lite/examples/imageclassification/fragments/CameraFragment.kt
thanks
The text was updated successfully, but these errors were encountered: