python - OpenCV error on Raspberry Pi in fuction cvtColor -


i using raspberry pi model b+ fresh install of raspbian , raspberry pi camera. playing around opencv code object tracking. found piece of code , worked initially.

here code in question.

import cv2 import numpy np  cap = cv2.videocapture(0)  while(1):  # take each frame _, frame = cap.read()  # convert bgr hsv hsv = cv2.cvtcolor(frame, cv2.color_bgr2hsv)  # define range of blue color in hsv lower_blue = np.array([110, 50, 50], dtype=np.uint8) upper_blue = np.array([130,255,255], dtype=np.uint8)  # threshold hsv image blue colors mask = cv2.inrange(hsv, lower_blue, upper_blue)  # bitwise-and mask , original image res = cv2.bitwise_and(frame,frame, mask= mask)  cv2.imshow('frame',frame) cv2.imshow('mask',mask) cv2.imshow('res',res) k = cv2.waitkey(5) & 0xff if k == 27:     break  cv2.destroyallwindows() 

but when tried run again, ran error:

traceback (most recent call last): file "/home/pi/desktop/alpha/object.py", line 50, in <module> hsv = cv2.cvtcolor(frame,cv2.color_bgr2hsv) error: /usr/src/packages/build/opencv-2.4.1+dfsg/modules/imgproc/src/color.cpp:3344: error: (-215) (scn == 3 || scn == 4) && (depth == cv_8u || depth == cv_32f) in function cvtcolor 

any please? worked first time around afterwards doesn't work. i've tried everything.

so found answer. had run code on raspberry pi:

sudo modprobe bcm2835-v4l2 

thank help.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -