
[code]

    cap = cv2.VideoCapture(0)
    cap.set(3, 640)
    cap.set(4, 480)
    cap.set(5, 60)
    f = open("output.csv","w")
    f.write("t,x,y\n")
    start = time.time()
    
    while(True):
        ret, frame = cap.read()
    
        hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
    
        low_color = np.array([160, 100, 150])#75
        upper_color = np.array([180, 160, 255])
    
        ex_img = cv2.inRange(hsv,low_color,upper_color)
    
        x = np.argmax(np.sum(ex_img,axis=0))
        y = np.argmax(np.sum(ex_img,axis=1))
    
        t = time.time() - start
        f.write(str(t)+","+str(x)+","+str(y)+"\n")
        print(str(t)+","+str(x)+","+str(y)+"\n")
    
        cv2.circle(frame,(x,y),10,(0,255,0))
    
        cv2.imshow('frame',frame)
    
        if t > 20:
            break
    
        key = cv2.waitKey(1) & 0xFF
    
    cap.release()
    cv2.destroyAllWindows()
    f.close()
    
[/code]

これを実行すると

> error processing request: /tmp/binarydeb/ros-kinetic-
> opencv3-3.2.0/modules/imgproc/src/color.cpp:9815: error: (-215) (scn == 3 ||
> scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor

となります  
どうしたらいいですか？


CC BY-SA 3.0
2017-11-16T09:20:05.723
39619
2017-11-16T09:56:47.763
2017-11-16T09:56:47.763
19110
26221
question
python opencv
pythonのopencvでcvtColorがエラーを出す