vision-camera-face-detector icon indicating copy to clipboard operation
vision-camera-face-detector copied to clipboard

What is `bounds.x` and `bounds.y` for?

Open bglgwyng opened this issue 2 years ago • 6 comments

I supposed that those are top and left of the bounding box, and I directly used them to display the overlay bounding box for the detected face. And I realized that frame is mirrored so I tried right instead of left. Nevertheless, the bounding box was not correctly positioned over the face.

So I looked into the source and I saw these lines.

    Double offsetX =  (boundingBox.exactCenterX() - ceil(boundingBox.width())) / 2.0f;
    Double offsetY =  (boundingBox.exactCenterY() - ceil(boundingBox.height())) / 2.0f;

    Double x = boundingBox.right + offsetX;
    Double y = boundingBox.top + offsetY;

    bounds.putDouble("x", boundingBox.centerX() + (boundingBox.centerX() - x));
    bounds.putDouble("y", boundingBox.centerY() + (y - boundingBox.centerY()));

But I couldn't understand the definition of x and y. So I just replaced the definitions with boundingBox.top and boundingBox.left. And It worked really well! What is the intended usage of x and y? What is the problem when I just use boundingBox.top and boundingBox.left?

bglgwyng avatar Jul 16 '22 13:07 bglgwyng

Any update on this, I'm getting different results on Android and IOS

nguyenhieuax avatar Sep 07 '22 07:09 nguyenhieuax

@nguyenhieuax https://github.com/bglgwyng/vision-camera-face-detector I forked this repo and fix this issue. Frame object works differently in ios and android. You'll receive cropped images in ios, so their aspect ratio is different to each other even in the same camera view size. I'm going to share face detection + bounding box rendering example soon.

bglgwyng avatar Sep 07 '22 10:09 bglgwyng

https://github.com/mrousavy/react-native-vision-camera/discussions/1229 I made a simple example.

bglgwyng avatar Sep 07 '22 13:09 bglgwyng

@bglgwyng the top value still not so correct when i test on the Ipad one. Also, when i use your lib there are no contours data anymore.

jackviatick avatar Sep 08 '22 08:09 jackviatick

@jackviatick Sorry, I removed countours for my own purpose. I think you can easily restore it. And if you figure out the correct solution that works also on iPad, please share it here for me. I'd be very grateful.

bglgwyng avatar Sep 10 '22 05:09 bglgwyng

https://github.com/mrousavy/react-native-vision-camera/discussions/1229 I made a simple example.

this link no longer works, i've run into basically the same problem and would like to know how you fixed it. Working with android

srikanth-c-p avatar Sep 12 '24 14:09 srikanth-c-p

@srikanth-c-p https://github.com/bglgwyng/OrientationExample maybe this one.

bglgwyng avatar Sep 19 '24 01:09 bglgwyng