esimov / pigo

Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go.
MIT License
4.37k stars 309 forks source link

oval shape #42

Closed pjebs closed 4 years ago

pjebs commented 4 years ago

Is it possible to use oval shape instead of square or circle?

esimov commented 4 years ago

It's possible, but why would you need it?

pjebs commented 4 years ago

oval shape is more natural for a face. I can more cleanly extract out the face portion from the full image.

esimov commented 4 years ago

@pjebs do you wish to be integrated into the CLI application or the WASM version?

pjebs commented 4 years ago

both

esimov commented 4 years ago

I will take care of this.

pjebs commented 4 years ago

thank you

esimov commented 4 years ago

@pjebs I have update the CLI tool to support ellipses for marking the detected faces. Please also check the readme file for the supported marker types and how you can use the newly introduced marker flag.

pjebs commented 4 years ago

Will wasm have ovals too?

pjebs commented 4 years ago

It's it possible to get the coordinates of the oval? Perhaps the rectangle encompassing the oval

esimov commented 4 years ago

Will wasm have ovals too?

No, at least not yet. If required could be included into WASM too.

It's it possible to get the coordinates of the oval? Perhaps the rectangle encompassing the oval

Yes, you can get the coordinates of the detected faces/eyes/landmark point by using the -json flag.

On the WASM demo you can display the face coordinates by pressing the x key. Check the wasm folder for more details.

pjebs commented 4 years ago

How long will it take to implement for wasm?

esimov commented 4 years ago

Done. Now it's possible to toggle between the detection marker shapes by pressing the c key. Also check the wasm demo reference.

pjebs commented 4 years ago

I saw the change to CLI:

dc.DrawEllipse(
    float64(face.Col),
    float64(face.Row),
    float64(face.Scale)/2,
    float64(face.Scale)/1.6,
)
type Detection struct {
    Row   int
    Col   int
    Scale int
    Q     float32
}
DrawRectangle(x, y, w, h float64)
DrawEllipse(x, y, rx, ry float64)

I was wondering where the 2 and 1.6 came from? I mistakenly thought perhaps the face-detector could return a ellipse for the face. I'm assuming the face-detector just gives you a rectangle that contains the face and you just put an ellipse inside with some constants you thought looked okay visually.

If that's the case, is it possible to change marker param for rect to square and have rect be the actual rectangle returned by the face detector? Since the oval is arbitrarily chosen by you.

Either way, thank you @esimov for your package.

esimov commented 4 years ago

The detector returns just the coordinates of the detected face together with the scale factor. In fact the scale factor is the dimension of the detection window, which means in the case of ellipse, since the face detector returns a rectangle (square) this needs to be adapted to the actual shape of a face, this is the reason why on y axis I'm using a smaller scale factor (I'm dividing by 2 because x and y are pointing to the center of the detection window.

pjebs commented 3 years ago

Is there a way to detect the actual oval shape of the actual face?