gocv icon indicating copy to clipboard operation
gocv copied to clipboard

Fix the problem that the non-maximum suppression return position is 0

Open Hexert opened this issue 1 year ago • 2 comments

Hexert avatar Jul 05 '22 17:07 Hexert

image

For the same target, when the length of boxes and indices is 2, after the NMSBoxes method, the length of the returned indices is also 2, and the values in the indices are all 0. At this time, one of the boxes cannot be removed, and the appropriate target detection is retained. frame, so return the length of indicesVector to extract a suitable target detection frame

Hexert avatar Jul 05 '22 18:07 Hexert

Hello @Hexert thanks for looking into this.

Seems to me the correct solution is to set the size/values of the slice returned with indices, that way a developer does not have to "guess" the resulting size.

For example:

...
indices = make([]int, indicesVector.length)
for i := 0; i < int(indicesVector.length); i++ {
		indices[i] = int(ptr[i])
}
return

Generally speaking we almost never add another param to a function signature that does not exist in the OpenCV function itself.

The same solution would also be needed for NMSBoxesWithParams().

Also, the branch for PRs is normally against dev. See https://github.com/hybridgroup/gocv/blob/release/CONTRIBUTING.md for details.

deadprogram avatar Jul 13 '22 09:07 deadprogram