-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Android app rework using Kotlin and more modern approach #352
base: master
Are you sure you want to change the base?
Conversation
Reimplemented android app using Kotlin and more modern approach
There must be something wrong with the configuration of the camera activity. |
Could you provide more details (logs, screenshots, etc.)? |
Sure, here you are: ![Screenshot_20210914-154736](https://user-images.githubusercontent.com/1271164/133265926-7eeaa4c1-cc17-4b8b-adf1-a08cf2815c69.png | width=200) Do you want anything more specific? |
As for now I'll try to replicate this on one of my devices. |
Ok, it's not happening on my devices. Could you provide some informations about the device you're using? And were you holding the device horizontally or vertically? (the app is locked in single position so I can't tell from the screenshot) |
Hmm.. I tested this on another device (Samsung S20 I think). On that one it works fine! But on my other device (CAT S62) it works just like the screenshot I've attached. More stats:
Samsung S20:
|
Ok, the CAT is not using 16:9 for camera images. Maybe I can force similar resolution on my phone. |
On the original java code (not the Kotlin MVVM) I get the below: S62: (the device that had issue
Samsung S20:
And it works well on both devices. |
You could put a breakpoint in YoloV4Detector class and view the |
I'll try it now. BTW was this a porting from hunglc007 or a fresh implementation based on it? |
It's mostly fresh implementation with parts from hunglc007. The old implementation was a pain in the ass to convert to Kotlin and it used archaic camera APIs. |
Ok, that got to be conversion problem. The androidx camera provides images in YUV format and there is a code which converts it to RGB. Something must be wrong with the YUV buffer (I had these problems previously). I'll take a look a it later. The problem is most probably in |
Could it be that the frame size (864x480) is messing around with the YUV? |
Most probably yes. Usually it has something to do with the buffer size being some funny number. |
The image is resized without maintaining aspect ratio. The same thing was done in the old implementation. I could replace it with padding instead but I don't know if it is an idea worth pursuing. |
I didn't factor the stride in image conversion, thats why for some resolution images are corrupted. I'm working on a fix |
…or future android API compatibility works
@Paschalis Check my fix. There should be no problems for 16:9 on your CAT phone. Still 4:3 is usually native format for cameras so stick to that for later use. Please let me know if the fix works on your devices. |
Thanks @Gunock for the update! It does work, I can confirm that: BTW, as a follow-up to my previous comment, yolo accepts the resized image without aspect ratio? If so, and given that training happens on unstretched images, do you believe that a left/right white padding would improve detection? I'm asking as I'm thinking of implementing this feature if it improves inference. |
You can either train yolo on non square images or add padding. I guess padding would improve inference but that's just guessing. EDIT: Maybe right/bottom padding would be better. Result position transposing should be easier and adding padding also should be easier (put image in position 0,0). |
Thanks for the tip! But then, with right/bottom padding wouldn't the Or is |
YOLO operates on normalized coords (i.e. positions and dimensions are expressed in percent's). There's some code in Whatever you do with padding there will be needed some offset correction in bounding boxes. |
Hi @Gunock , It's me again! In particular, I tested 3 models:
In contrast with the last time, the above issue persists on both devices Can you guide me or give me some hints (once again) on how to resolve this? Cheers, |
Please contact me by mail ( asz.czyk.dev@gmail.com ). |
…age analysis, used Color class for pixel color extraction
@Paschalis I have migrated from YUV to ARGB in CameraX's ImageAnalysis (latest version added support for it). This should resolve any issues with image color format conversion. I have also added image scaling that retains aspect ratio. This resolved issues with zero detections when using your custom model. |
Chore/updates 05 2024
No description provided.