更新UCD-API库及文档
This commit is contained in:
44
docs/UCD-API文档/examples/work_with_dsc.py
Normal file
44
docs/UCD-API文档/examples/work_with_dsc.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
from UniTAP.utils import encode_video_frame, decode_video_frame, video_frame_save_to_file, ImageFileFormat
|
||||
#
|
||||
# To initialize UniTAP library wrapper user should create UniTAP.TsiLib() object.
|
||||
#
|
||||
lUniTAP = UniTAP.TsiLib()
|
||||
|
||||
#
|
||||
# For opening device, please, put serial number of the device as 8 symbol str or put index of device.
|
||||
#
|
||||
# dev = lUniTAP.open("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# For UCD-500 available following roles:
|
||||
# UniTAP.dev.UCD500.DPSourceDPSink, USBCSourceUSBCSink, DPSourceUSBCSink and USBCSourceDPSink
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
role.dprx.video_capturer.start(stream_number=0)
|
||||
frame = role.dprx.video_capturer.pop_element()
|
||||
role.dprx.video_capturer.stop()
|
||||
|
||||
# Decode DSC Video frame and save
|
||||
image_path = "image.bmp"
|
||||
decoded_vf = decode_video_frame(frame)
|
||||
video_frame_save_to_file(video_frame=decoded_vf, path=image_path, file_type=ImageFileFormat.IFF_BMP)
|
||||
|
||||
# Save raw DSC Video frame
|
||||
image_path = "image.dsc"
|
||||
video_frame_save_to_file(video_frame=frame, path=image_path, file_type=ImageFileFormat.IFF_DSC)
|
||||
|
||||
#
|
||||
# Since the 3.5 version, TsiLib and TSIDevice objects have the option to be closed earlier.
|
||||
# TSIDevice can be closed with the TsiLib method close(). TsiLib can be closed with cleanup().
|
||||
# Clean up will close all opened devices and block ability to open any devices
|
||||
# with same TsiLib object.
|
||||
#
|
||||
lUniTAP.close(dev)
|
||||
|
||||
lUniTAP.cleanup()
|
||||
Reference in New Issue
Block a user