Reputation: 332
I'm trying to make a GUI using Tkinter on python 2.7 that will display a video stream on my Raspberry PI B+. Thought the code works when I test it on windows and Ubuntu, running it on PI is a hole different problem. Whenever I try to run the video I get the same
cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3737: error: (-215) snc == 3 || scn == 4 in function cvtColor
I looked for answers over Stack Overflow and Raspberry PI forum, such as using modprobe, but none of those have worked so far.
The code bellow shows the samples of code where the problem is inserted:
From the init method
self.webcam_width, self.webcam_height = 400, 300
# We create the cv video capture
self.cap = cv2.VideoCapture(0)
self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, self.webcam_width)
self.cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, self.webcam_height)
Method that updates de video
def show_frame(self):
"""
Animate the webcam on the video label
:return:
"""
_, frame = self.cap.read()
frame = cv2.flip(frame, 1)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
self.webcam_label.imgtk = imgtk
self.webcam_label.configure(image=imgtk)
self.webcam_label.after(30, self.show_frame)
Thanks for your help, and sorry about my english
Upvotes: 0
Views: 1287
Reputation: 332
The problem was actually prior to calling the cvtColor, because it showed me an libv4l error. To solve that I simply booted the raspberry with the webcam connected
Upvotes: 1