TypeError: Incorrect type of self (must be 'CascadeClassifier' or its derivative)

asked 2018-08-16 12:15:59 -0600

R.F gravatar image

Good morning,

I am running a simple python code to recognize pedestrians.When I run this code on my ubunutu machine there is no error. it works perfectly However when i run it in my Docker container I get this error. "TypeError: Incorrect type of self (must be 'CascadeClassifier' or its derivative)"

I know the container cannot generate a graphical window that's why I comment commands like imshow. But I just need it to detect and not to display anything. Because when they detect something I send an order to my robot to stop.

I don't understand why. Can anyone help please?

Here is my code :

pedestrians_cascade= cv2.CascadeClassifier('/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/client/hogcascade_pedestrians.xml')

    cap=cv2.VideoCapture('http://192.168.0.132:8080/?action=stream')
    incr = 0
    while True:
            s = time.time() - start_time
            while s<=9:
                    s = time.time() - start_time
                    ret, frame=cap.read()
                    #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
                    bodies = pedestrians_cascade.detectMultiScale(frame)
                    tcpDecision1.stop_start(bodies, frame)
                    #cv2.imshow('frame',frame)
                    k = cv2.waitKey(30) & 0xff
                    if k == 27:
                            break
edit retag flag offensive close merge delete

Comments

which cv2 version is it (on your box and the docker) ? and how do you install that ?

note, that opencv3 does not support hog cascades anymore.

berak gravatar imageberak ( 2018-08-17 01:00:43 -0600 )edit