Webcam video recording
bruce
New Member Posts: 15 ✭
in Peripherals
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,
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.
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 = cv2.cv.CV_FOURCC(*'XVID') out = cv2.VideoWriter('output.avi',fourcc,30.0,(640,480)) while(True): ret, frame = cap.read() #gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) out.write(frame) cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): # break cap.release() out.release() cv2.destroyAllWindows()
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.
Comments
-
You'll find an example here, for detecting button presses, which might help:
https://up-community.org/wiki/MRAA/UPM#Turn_an_LED_on.2Foff_by_detecting_a_button_press_on_a_GPIO
Categories
- All Categories
- 63 Announcements & News
- 58 Product News - New Product/Product Change Notice/ End-of-life
- 99 Welcome Developers!
- 46 Unboxing & Project Sharing
- 114 Tech Updates
- 3.4K UP Products
- 14 UP 7000
- 1 UP Squared i12
- 12 UP Xtreme i12
- 13 UP Squared Pro 7000
- 1 UP Element i12 Edge
- 23 UP Squared V2
- 63 UP 4000
- 23 UP Xtreme i11
- 34 UP Squared 6000
- 57 UP Squared Pro
- 135 UP Xtreme
- 820 UP Squared
- 1.4K UP Board
- 74 UP Core Plus
- 217 UP Core
- 3 UP Xtreme Lite
- 40 UP AI Edge
- 265 Starter Kits & Peripheral