Unfortunately I am both a python and a openCV beginner, so wish to excuse me if the question is stupid.
I am trying to use a cv2.HOGDescriptor
to recognize
There is no need to perform that extra conversion yourself, that problem is related to the mixing of the new and old OpenCV bindings for Python. The other problem regarding hog.detectMultiScale
is simply due to incorrect parameter ordering.
The second problem can be directly seen by checking help(cv2.HOGDescriptor().detectMultiScale)
:
detectMultiScale(img[, hitThreshold[, winStride[, padding[,
scale[, finalThreshold[, useMeanshiftGrouping]]]]]])
as you can see, every parameter is optional but the first (the image). The ordering is also important, since you are effectively using winStride
as the first, while it is expected to be the second, and so on. You can used named arguments to pass it. (All this has been observed in the earlier answer.)
The other problem is the code mix, here is a sample code that you should consider using:
import sys
import cv2
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
hogParams = {'winStride': (8, 8), 'padding': (32, 32), 'scale': 1.05}
video = cv2.VideoCapture(sys.argv[1])
while True:
ret, frame = video.read()
if not ret:
break
result = hog.detectMultiScale(frame, **hogParams)
print result
The documentation for the C++ version of HOGDescriptor::detectMultiScale shows a hit_threshold
parameter (of type double
) prior to the win_stride
argument. So it appears you are missing an argument to the function. To accept the default argument for win_stride
, you should pass your addition arguments used in your question as keywords.