Home>

https://algorithm.joho.info/programming/python/opencv-hog-cascade-human-detection-py/
I am trying to perform image authentication using the source code of, but the way to deal with errors is getting worse.

Error message

File"C: \ Users \ Yumi \ python \ Local \ PythonApplication2 \ PythonApplication2 \ PythonA
pplication2.py" ;, line 29, in<module>
main ()
File"C: \ Users \ Yumi \ python \ Local \ PythonApplication2 \ PythonApplication2 \ PythonA
pplication2.py" ;, line 10, in main
gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV (3.4.2) d: \ build \ opencv \ opencv-3.4.2 \ modules \ imgproc \ src \ color.
hpp: 253: error: (-215: Assertion failed) VScn :: contains (scn)&&VDcn :: contains (dc
n)&&VDepth :: contains (depth) in function'cv :: CvtHelper<struct cv :: Set<3,4, -1> ;,
struct cv :: Set<1, -1, -1>, struct cv :: Set<0,2,5>, 2>:: CvtHelper'

Applicable source code

import cv2

def main ():

img = cv2.imread ("input.jpg")

gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY)

hog = cv2.HOGDescriptor ()
hog.setSVMDetector (cv2.HOGDescriptor_getDefaultPeopleDetector ())
hogParams = {'winStride&apos ;: (8, 8),'padding&apos ;: (32, 32),'scale&apos ;: 1.05}

human, r = hog.detectMultiScale (gray, ** hogParams)

for (x, y, w, h) in human:
cv2.rectangle (img, (x, y), (x + w, y + h), (0,0,200), 3)

cv2.imwrite ("result.jpg", img)

ifname=='main&apos ;:
main ()

Tried

I moved the image data to the corresponding visual studio file, but it didn't work.