Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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)
    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()

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)
.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()