Ask Your Question
3

OpenCV with Logitech Pro 4000 on the Raspberry Pi

asked 2013-02-13 23:44:59 -0600

DuskFyre gravatar image

updated 2013-02-16 17:39:26 -0600

Hello everyone!

I have been attempting to use OpenCV to take pictures on the Raspberry Pi (Raspbian), but it does not seem to work for me. Whenever I run any camera-related programs, the window opens correctly, but only a grey image is displayed.

I have tested the webcam on my computer and it works fine. Additionally, the camera works with other, different webcam programs (Specifically, GuvCview). Here is the code I am currently using:

import cv2.cv as cv
import time

cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
capture = cv.CaptureFromCAM(0)

while True:

    frame = cv.QueryFrame(capture)
    cv.ShowImage("w1", frame)
if cv.WaitKey(10) == 27:  #Break on ESC
     break    

cv.DestroyAllWindows()

Thank you for your help!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-04-30 11:32:42 -0600

thePhi gravatar image

updated 2014-04-30 11:34:01 -0600

For me,

import cv2.cv

is not working. Try :

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    #capture frame-by-frame
    ret = cap.set(3,160) #set Width 
    ret = cap.set(4, 120) #set Heigth
    #ret = cap.set(5, .0) NOT working on Logitech QuickCam: No FPS setting :(
    ret, frame = cap.read()

    #our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    #Display the resulting frame
    cv2.imshow('frame', gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
edit flag offensive delete link more
0

answered 2013-02-18 02:17:33 -0600

It looks like some OS related issue. Are you sure, that all needed drivers are loaded and works properly. OpenCV uses standard V4L and V4L2 interfaces for cameras. Is it properly enabled on your platform?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-13 23:44:59 -0600

Seen: 1,422 times

Last updated: Apr 30 '14