-
-
Notifications
You must be signed in to change notification settings - Fork 938
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
Is there any way I can get the preview size selected by camera view. I dont need the list of previews supported but the preview size which is eventually chosen after all the logic done. I have an overlay over camera view which needs preview width and height #802
Comments
Just call getWidth() or getHeight() as with any view in Android |
Zest of problem is that I am using camera view over which i am using MLKit for face detection using Frame Processor. However, My Bounding box is getting shifted to the left in many devices. So, I have debugged a lot in your code and found that
What I'm looking for is previewWidth and previewHeight value, so that I can pass it to my overlay for setting camera info: fun setCameraInfo(previewWidth: Int, previewHeight: Int, facing: Facing) { IF i'm passing widthValue and HeightValue, my bounding box is getting shifted to the left(as you can see above difference in widthValue and previewWidth value), however when I debugged and hardcoded the values of previewWidth and previewHeight(because its not provided as much as I know in this lib), its working fine in all the device. Can you suggest me how can I take these values?? |
there should be some way for anyone using an overlay above cameraView to get previewWidth and previewHeight. |
Hi |
You are processing a frame of size |
Hi @natario1 , I hope this can give you a better picture: Our Moto : xml Design : <com.otaliastudios.cameraview.CameraView
What is Graphic overlay : A view which renders a series of custom graphics to be overlayed on top of an associated preview
We are using it to create our Bounding Box of face provided by ML face recognition Kit. We are using firebase Ml kit face recognition to create a bounding box of the face detected. We are also scaling x and y coordinate from the preview's coordinate system to the view coordinate system.
Not to mention but we are passing the frame size as well to the ML Kit addFrameProcessor { Issue : We only call "takePictureSnapshot()" when our bounding box is inside the oval. Probable cause : |
I understand that it works with preview stream size, but it's just by coincidence. You should probably call setCameraInfo(frame.size.width, frame.size.height), or if this doesn't work, setCameraInfo(0, 0) and do the scaling yourself. I also imagine that this graphic overlay should be match_parent to work correctly. |
We recently used @amit2273 Going by your finding, it looks like exposing |
Hi @natario1 , I have tried setCameraInfo(frame.size.width, frame.size.height) and it doesn't work. Also, I have used firebase sample tutorial for implementing the same where they are using their own camera source When I went through the internal working of code, they are calculating the preview Width and preview Height , which you are also doing inside the your library and setting it to graphic overlay in CameraSourcePreview.java 's startIfReady() method : @SuppressLint("MissingPermission")
} I'm just trying to replicate the same code . |
Yeah well you have to rotate them. It's much cleaner in CameraView than it is in their app: int width = frame.getRotationToView() % 180 == 0 ? frame.getWidth() : frame.getHeight();
int height = frame.getRotationToView() % 180 == 0 ? frame.getHeight() : frame.getWidth();
overlay.setCameraInfo(width, height, frame.getFacing()) And then you will have to change something else in your code to make it work correctly. For example, ML results are rotated based on the frame rotation that you pass to the ML detector, and you might have to rotate the detector results as well. GraphicOverlay does not care about rotation and this is wrong. I don't have much time to help you, feel free to open a PR with |
Thanks @natario1 for your time. Really appreciative. |
@hpkaushik121 I was struggling with the same thing. What I found may help you. When you set the To illustrate: Let's say you have a screen that is 300px wide by 400px high. Let's also say that you have your Let's also say you have an overlay view on top of the |
Hi @amit2273 could you share a sample or tell what exactly you have done? |
Hi @abhishektiwari-kiwi, @hpkaushik121 fun setCameraInfo(previewWidth: Int, previewHeight: Int, facing: Facing) { So, Please interchange the values of frame.size.width and frame.size.height when passing it to camera overlay.
|
How do I?
Describe your problem here. Please, read the docs first.
Questions not strictly related to CameraView should be asked elsewhere.
Version used
CameraView exact version.
The text was updated successfully, but these errors were encountered: