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

Passing output value via a variable (Python) #36

Closed rgvxlens closed 4 years ago

rgvxlens commented 4 years ago

Hi there! I'm trying to pass the values for the eyes separately using the blinkdet example, but seems like it outputs the values for both the eyes together and not separately (just outputting max_radius)

Is there a way to output the values that I get using -json via a particular variable or just output the values (max_radius) of both the eyes separately?

esimov commented 4 years ago

Not sure if I understand correctly what you are trying to achieve? Can you detail a little bit?

rgvxlens commented 4 years ago

So the values that I get if I just use the command line version of Pigo with -json argument are: [{"face":{"x":242,"y":363,"size":256},"eyes":[{"x":230,"y":316,"size":21},{"x":233,"y":413,"size":21}]}]

I'm trying to get similar output using the Python program for the "blinkdet" example. In there, I've identified _maxradius = int(det[2]*0.45) where max_radius is the variable for storing the iris radius for both of the eyes (I guess?).

Is there a way to output the max_radius for the left separately and the right eye separately?

esimov commented 4 years ago

The only way on that example to identify the left and right eye separately is to introduce an index and check inside the if show_pupil: statement from line 86 if it's odd or even. The left eye is detected first. Otherwise the Go code needs to be extended. I was forced to use an 1D array, since it was not possible to transfer a multi dimensional array trough array pointer from Go to Python via a shared object. That was the reason of using in python some sort of trickery in identifying the detected objects.

https://github.com/esimov/pigo/blob/master/examples/blinkdet/blinkdet.py#L86

rgvxlens commented 4 years ago

I tried implementing the same but have not been successful. Could you explain a bit more, or give me a code-based example? The thing is that I can get the hang of Python when I work around it, but understanding the Go-based code is a bit difficult for me.

esimov commented 4 years ago

Not sure if I understand what you are trying to achieve? The code-based example is that one I have provided above.