Tuesday 15 September 2015

python - OpenCV display single image webcam -



python - OpenCV display single image webcam -

i have stream webcam. want take single frame when press key (spacebar) , display single frame in window. , each time press button window gets updated new pic. possible?

this code far:

import cv2 import sys video_capture = cv2.videocapture(0) while true: # capture frame-by-frame ret, frame = video_capture.read() grayness = cv2.cvtcolor(frame, cv2.color_bgr2gray) # display resulting frame cv2.imshow('video', frame) if cv2.waitkey(1) & 0xff == ord('q'): break # when done, release capture video_capture.release() cv2.destroyallwindows()

all have capture output of waitkey in variable. checking against q break loop. in case space, can display in different window using imshow.

python python-2.7 opencv webcam

No comments:

Post a Comment