vision-camera-face-detector
vision-camera-face-detector copied to clipboard
What is `bounds.x` and `bounds.y` for?
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
?
Any update on this, I'm getting different results on Android and IOS
@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.
https://github.com/mrousavy/react-native-vision-camera/discussions/1229 I made a simple example.
@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 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.
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 https://github.com/bglgwyng/OrientationExample maybe this one.