SaveLoadCaptureOptions
Read and modify the capture parameters in the scanner, store the modified parameters in the scanner and print them.
# Copyright (c) RVBUST, Inc - All rights reserved.
import PyRVC as RVC
import os
import numpy as np
from Utils.Tools import *
def UseX1():
# Initialize RVC X system.
RVC.SystemInit()
# Choose RVC X Camera type (USB, GigE or All)
opt = RVC.SystemListDeviceTypeEnum.All
# Scan all RVC X Camera devices.
ret, devices = RVC.SystemListDevices(opt)
print("RVC X Camera devices number:%d" % len(devices))
# Find whether any RVC X Camera is connected or not.
if len(devices) == 0:
print("Can not find any RVC X Camera!")
RVC.SystemShutdown()
return 1
print("devices size = %d" % len(devices))
# Create a RVC X Camera and choose use left side camera.
x = RVC.X1.Create(devices[0], RVC.CameraID_Left)
# Test RVC X Camera is valid or not.
if x.IsValid() == True:
print("RVC X Camera is valid!")
else:
print("RVC X Camera is not valid!")
RVC.X1.Destroy(x)
RVC.SystemShutdown()
return 1
#PrintCaptureMode(devices[0])
# Open RVC X Camera.
ret1 = x.Open()
# Test RVC X Camera is opened or not.
if ret1 and x.IsOpen() == True:
print("RVC X Camera is opened!")
else:
print("RVC X Camera is not opened!")
RVC.X1.Destroy(x)
RVC.SystemShutdown()
return 1
# Print ExposureTime Range
_, exp_range_min, exp_range_max = x.GetExposureTimeRange()
print("ExposureTime Range:[{}, {}]".format(exp_range_min, exp_range_max))
# Save CaptureOptions
x1_save_opts = RVC.X1_CaptureOptions()
x1_save_opts.exposure_time_3d = 20
x1_save_opts.exposure_time_2d = 21
x.SaveCaptureOptionParameters(x1_save_opts)
# Load CaptureOptions
ret, x1_opts= x.LoadCaptureOptionParameters()
PrintCaptureOptionX1(x1_opts)
# Close RVC X Camera.
x.Close()
# Destroy RVC X Camera.
RVC.X1.Destroy(x)
# Shutdown RVC X System.
RVC.SystemShutdown()
return 0
def UseX2():
# Initialize RVC X system.
RVC.SystemInit()
# Choose RVC X Camera type (USB, GigE or All)
opt = RVC.SystemListDeviceTypeEnum.All
# Scan all RVC X Camera devices.
ret, devices = RVC.SystemListDevices(opt)
print("RVC X Camera devices number:%d" % len(devices))
# Find whether any RVC X Camera is connected or not.
if len(devices) == 0:
print("Can not find any RVC X Camera!")
RVC.SystemShutdown()
return 1
print("devices size = %d" % len(devices))
# Create a RVC X Camera
x = RVC.X2.Create(devices[0])
# Test RVC X Camera is valid or not
if x.IsValid() == False:
print("RVC X Camera is not valid!")
RVC.X2.Destroy(x)
RVC.SystemShutdown()
exit(1)
#PrintCaptureMode(devices[0])
# Open RVC X Camera
ret1 = x.Open()
# Test RVC X Camera is opened or not
if x.IsOpen() == False:
print("RVC X Camera is not opened!")
RVC.X2.Destroy(x)
RVC.SystemShutdown()
exit(1)
# Set capture parameters
cap_opt = RVC.X2_CaptureOptions()
# Transform point map's coordinate to left/right(RVC.CameraID_Left/RVC.CameraID_Right) camera or reference
# plane(RVC.CameraID_NONE)
cap_opt.transform_to_camera = RVC.CameraID_Left
# Set camera exposure time (3~100) ms
cap_opt.exposure_time_2d = 20
cap_opt.exposure_time_3d = 20
# range in [0, 10]. the default value is 3. The contrast of point less than this value will be treat * as invalid point and be removed.
cap_opt.light_contrast_threshold = 2
# edge control after point matching, range in [0, 10], default = 2. The big the value, the more edge * noise to be
# removed.
cap_opt.edge_noise_reduction_threshold = 0
# Set projector color, defult is RVC.ProjectorColor_Blue
cap_opt.projector_color = RVC.ProjectorColor_Blue
x.SaveCaptureOptionParameters(cap_opt)
# Load CaptureOptions
ret, x2_opts= x.LoadCaptureOptionParameters()
PrintCaptureOptionX2(x2_opts)
# Close RVC X Camera.
x.Close()
# Destroy RVC X Camera.
RVC.X2.Destroy(x)
# Shutdown RVC X System.
RVC.SystemShutdown()
return 0
if __name__ == "__main__":
UseX1()
UseX2()