rodgomesc / vision-camera-face-detector

VisionCamera Frame Processor Plugin to detect faces using MLKit Vision Face Detector
MIT License
89 stars 65 forks source link

Bound object is empty #3

Closed max-frai closed 2 years ago

max-frai commented 2 years ago

Hello, thank you for the plugin. I'm using it with ios and everything is ok except it does not show me position of the face relative to screen. This is not supported for now or it could be some bug?

Array [
  Object {
    "bounds": Object {},
    "cotours": Object {},
    "leftEyeOpenProbability": 0.1603792905807495,
    "pitchAngle": 4.061193943023682,
    "rightEyeOpenProbability": 0.9974306225776672,
    "rollAngle": -6.199738502502441,
    "smilingProbability": 0.10511480271816254,
    "yawAngle": -40.35028076171875,
  },
]
iAmGhost commented 2 years ago

contours and bounds are not implemented yet for iOS. I've tried to fix it while fixing contours but I had no idea how bounding box calculation works.

https://github.com/rodgomesc/vision-camera-face-detector/blob/8ec789b5261d48f46dff770c348bac67f8b27cb2/ios/VisionCameraFaceDetector.swift#L29-L32

rusakovic commented 2 years ago

Waiting for this feature =)

iAmGhost commented 2 years ago

I've sent PR for fixing empty countours here: https://github.com/rodgomesc/vision-camera-face-detector/pull/4

You can try fixing it yourself by replicating code of android plugin(which I failed)

https://github.com/rodgomesc/vision-camera-face-detector/blob/84119185190fe3a9966c4fedf44ab1ab8bc3f487/android/src/main/java/com/visioncamerafacedetector/VisionCameraFaceDetectorPlugin.java#L47-L71

PietroGranati commented 2 years ago

Hi, thank you @iAmGhost for the contouring, I've implemented a sort of bounding box, in fact is the frame of the face given in a origin point with width and height I don't know if it helps

private static func processBoundingBox(from face: Face) -> [[String:CGFloat]] {
        let frame = face.frame;
        var pointsArray: [[String:CGFloat]] = [];
        let currentPointsMap = [
            "origin_x": frame.origin.x,
            "origin_y": frame.origin.y,
            "width":frame.size.width,
            "height":frame.size.height,
        ]
        pointsArray.append(currentPointsMap)
        return pointsArray
    }
iAmGhost commented 2 years ago

@PietroGranati Also check for #9, it fixes this issue but not merged with master yet