Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Python input from Webcam on raspberry pi?

i'm using a sony ps3 eye as webcam input on my pi for an OpenCL python program I'm writing, but for some reason no matter what i do the pi python compiler isn't accessing the webcam. Yet the same code when run on my laptop using the same webcam runs perfectly. Then i checked the usb devices on my pi and it state that "sony playstation 3 eye cam" was on usb port 6. also when using the "motion" package on the pi i was able to use the camera perfectly as input. So my problem is again that the python compiler isn't communicating with my webcam on the pi. Please, think about this and tell me how to fix it; i simply can't think of what's wrong. Here's the sample code I used, and please help me out. Thank you very much.

import cv2.cv as cv

#cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0

capture = cv.CaptureFromCAM(camera_index)
while not capture:
  print "error opening capture device, correction attempt"

while True:
  frame = cv.QueryFrame(capture)
  if frame is None:
    print "fail with putting in frame"

  else:
    c = cv.WaitKey(100)
    print 'capturing!'
    cv.SaveImage("pictest.png", frame)
like image 896
syk435 Avatar asked Nov 13 '22 13:11

syk435


1 Answers

I never updated this but my solution was: I used the Motion Package for Raspberry Pi to receive images (since the Sony Ps3 EyeToy Camera did not have drivers written that were compatible with the Pi) and then Used OpenCV to analyze each Image. Doing this as each image came in, many times a second, is the same as analyzing video through OpenCV.This implementation worked perfectly for my needs, and I used other Bash tools to delete old image files after a certain time period so my memory was not unnecessarily filled.

like image 63
syk435 Avatar answered Nov 15 '22 06:11

syk435