esimov / pigo

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

what is the mean of iouThreshold #44

Closed haydenzhourepo closed 3 years ago

haydenzhourepo commented 3 years ago

First Tks for your nice project. I am a bit confuse of the mean of iou parameter and it impact the result of the detection, and i use this lib for face detection, I'm wonder of how to set iouThreshold value correctly.

esimov commented 3 years ago

IoU means intersection over union.

Because the detector is based on pixel intensity comparison, this means that it’s also sensible to small perturbations and variations of the underlying pixel data, influenced mostly by the scaling and the rotation of the objects, resulting overlaps in detection. This is the reason why the cascade detections are clustered together in a post processing step and the final result is produced by applying the intersection over union formula on the detected clusters.

To answer your question in most use cases the default value should just work fine. But you can also adapt the IoU value to your specific environment (light conditions for example), so I suggest if the default value is not working for you then adjust it accordingly. You should adjust it with a point decimal difference, because it is slightly sensible and might results in multiple overlapping detections. You should also check the iou value used on the real time examples (python and wasm version). I hope that this answered your question.

Endre

haydenzhourepo commented 3 years ago

according to ClusterDetections function's code segment:

for j := 0; j < len(detections); j++ {
                // Check if the comparison result is below a certain threshold.
                if calcIoU(detections[i], detections[j]) > iouThreshold {
                    assignments[j] = true
                    r += detections[j].Row
                    c += detections[j].Col
                    s += detections[j].Scale
                    q += detections[j].Q
                    n++
                }
            }

Int this snippet, The calcloU fun which in the for's inner loop calutate the iou value of two detections,and if the calculated value is grater than the iouThreshold param , we union the two detections as one detection result, the same as the follow sequence dectections. As a result we get one unioned result in a inner loop. so the smaller the iouThreshold params is, the lesser the results num is. becouse if iouThreshold params is smaller we will union more detections as only one result.

So, Whether this comment // Check if the comparison result is below a certain threshold. should be // Check if the comparison result is greater then a certain threshold. if so we union the detections

esimov commented 3 years ago

Thanks for this notification. It has been corrected.