Blocks.Camera
1import cv2 2 3 4def main(inputs, outputs, parameters, synchronise): 5 ''' 6 ## Opens your Camera using OpenCV\n 7 The Camera block opens your webcam using OpenCV and begins capturing the video feed. 8 This video feed is then propagated forward through the `share_image()` function 9 10 `while` loop is the part of the program that is executed continuously. 11 It is enabled by default but can be disabled by passing in 0 through the enable wire. 12 13 **Inputs**: None 14 15 **Outputs**: BGR Image 16 17 **Parameters**: None 18 ''' 19 cap = cv2.VideoCapture(0) 20 auto_enable = False 21 try: 22 enable = inputs.read_number('Enable') 23 except Exception: 24 auto_enable = True 25 try: 26 while cap.isOpened() and (auto_enable or inputs.read_number('Enable')): 27 ret, frame = cap.read() 28 if not ret: 29 continue 30 31 outputs.share_image("Img", frame) 32 synchronise() 33 except Exception as e: 34 print('Error:', e) 35 pass 36 finally: 37 print("Exiting") 38 cap.release()
def
main(inputs, outputs, parameters, synchronise)
5def main(inputs, outputs, parameters, synchronise): 6 ''' 7 ## Opens your Camera using OpenCV\n 8 The Camera block opens your webcam using OpenCV and begins capturing the video feed. 9 This video feed is then propagated forward through the `share_image()` function 10 11 `while` loop is the part of the program that is executed continuously. 12 It is enabled by default but can be disabled by passing in 0 through the enable wire. 13 14 **Inputs**: None 15 16 **Outputs**: BGR Image 17 18 **Parameters**: None 19 ''' 20 cap = cv2.VideoCapture(0) 21 auto_enable = False 22 try: 23 enable = inputs.read_number('Enable') 24 except Exception: 25 auto_enable = True 26 try: 27 while cap.isOpened() and (auto_enable or inputs.read_number('Enable')): 28 ret, frame = cap.read() 29 if not ret: 30 continue 31 32 outputs.share_image("Img", frame) 33 synchronise() 34 except Exception as e: 35 print('Error:', e) 36 pass 37 finally: 38 print("Exiting") 39 cap.release()
Block Description
Opens your Camera using OpenCV
The Camera block opens your webcam using OpenCV and begins capturing the video feed.
This video feed is then propagated forward through the share_image()
function
while
loop is the part of the program that is executed continuously.
It is enabled by default but can be disabled by passing in 0 through the enable wire.
Inputs: None
Outputs: BGR Image
Parameters: None