Webcam video recording

brucebruce New Member Posts: 15
Hi, I purchased the UP board a week ago, I am working on a hobby project, I am a novice so I need your guidance.

I want to record a video (using a push button switch for Start/Stop recording) from a webcam connected to one of the USB port. I found this sample code on OpenCV documentation,
import numpy as np
import cv2

cap = cv2.VideoCapture(0)	#webcam defined,
#fourcc = cv2.VideoWritter_fourcc(*'XVID')
fourcc =*'XVID')
out = cv2.VideoWriter('output.avi',fourcc,30.0,(640,480))

	ret, frame =
	#gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
	if cv2.waitKey(1) & 0xFF == ord('q'): #


Now the problem is that the video doesn't stop by itself, every time I have to press CTRL+C to stop the execution.

Can anyone please guide me how to connect a push button switch with UP board and then execute the code to start and stop the video recording.

I also want to perform some other operation as soon as the recording is being stopped.
please guide me.


Sign In or Register to comment.