movie2/Recording
1 # CVBpy Example Script
2 #
3 # 1. Starts a stream from device
4 # 2. Starts recording.
5 # 3. Writes images to movie file.
6 # 4. Stops recording.
7 # 5. Stops the device's stream.
8 #
9 
10 import os
11 import cvb
12 import cvb.movie2
13 
14 with cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "CVMock.vin"), port=0) as device:
15 
16  stream = device.stream()
17  stream.start()
18 
19  # Replay cvrv file with Common Vision Blox Viewer
20  output_file = os.path.expanduser('~/Movie2ExampleVideo.cvrv')
21 
22  # Raw video settings
23  raw_video_settings = cvb.movie2.RawVideoSettings()
24  # Define pixel format
25  pixel_format = cvb.movie2.RecorderPixelFormat.Color
26  if len(device.device_image.planes) == 1:
27  pixel_format = cvb.movie2.RecorderPixelFormat.Mono
28  # Create the recorder
29  with cvb.movie2.Recorder(output_file, device.device_image.size, pixel_format, raw_video_settings) as recorder:
30 
31  print("Start recording 100 frames:")
32 
33  for i in range(100):
34  image, status = stream.wait()
35  if status == cvb.WaitStatus.Ok:
36  # Write image to file
37  recorder.write(image)
38  print(".", end="")
39 
40  stream.abort()
41 
42  print("\nMovie file written to: " + output_file)
Settings for initializing a raw video engine recorder.
Definition: __init__.py:38
Common Vision Blox Movie recording module for Python.
Definition: __init__.py:1
Recorder object writing video streams with the given pixel format and recording engine.
Definition: __init__.py:60
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
Opens a device with the given provider and acquisition stack.
Definition: __init__.py:1327
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:7153