Package: dmcam
IntroductionThedmcamPython extension is part ofSmartToF SDK, it's developed for python programmers to interacting with SmartToF Module.Quick exampleimportsys,osimportnumpyasnpimporttimeimportdmcam# --  init the lib with default log filedmcam.init(None)# --  init with specified log file# dmcam.init("test.log")# -- set debug leveldmcam.log_cfg(dmcam.LOG_LEVEL_INFO,dmcam.LOG_LEVEL_DEBUG,dmcam.LOG_LEVEL_NONE)# -- list deviceprint(" Scanning dmcam device ..")devs=dmcam.dev_list()ifdevsisNone:print(" No device found")sys.exit(1)print("found%ddevice"%len(devs))foriinrange(len(devs)):print("#%d:%s"%(i,dmcam.dev_get_uri(devs[i],256)[0]))print(" Open dmcam device ..")# open the first devicedev=dmcam.dev_open(devs[0])# Or open by URI# dev = dmcam.dev_open_by_uri("xxxx")assertdevisnotNone# - set capture config  -cap_cfg=dmcam.cap_cfg_t()cap_cfg.cache_frames_cnt=10# framebuffer = 10cap_cfg.on_error=None# use cap_set_callback_on_error to set cbcap_cfg.on_frame_rdy=None# use cap_set_callback_on_frame_ready to set cbcap_cfg.en_save_replay=True# True = save replay, False = not savecap_cfg.en_save_dist_u16=False# True to save dist stream for openni replaycap_cfg.en_save_gray_u16=False# True to save gray stream for openni replaycap_cfg.fname_replay=os.fsencode("dm_replay.oni")# set replay filenamedmcam.cap_config_set(dev,cap_cfg)# dmcam.cap_set_callback_on_frame_ready(dev, on_frame_rdy)# dmcam.cap_set_callback_on_error(dev, on_cap_err)print(" Set paramters ...")wparams={dmcam.PARAM_INTG_TIME:dmcam.param_val_u(),dmcam.PARAM_FRAME_RATE:dmcam.param_val_u(),}wparams[dmcam.PARAM_INTG_TIME].intg.intg_us=1000wparams[dmcam.PARAM_FRAME_RATE].frame_rate.fps=20ifnotdmcam.param_batch_set(dev,wparams):print(" set parameter failed")print(" Start capture ...")dmcam.cap_start(dev)f=bytearray(320*240*4*2)print(" sampling 100 frames ...")count=0run=Truewhilerun:# get one framefinfo=dmcam.frame_t()ret=dmcam.cap_get_frames(dev,1,f,finfo)# print("get %d frames" % ret)ifret>0:w=finfo.frame_info.widthh=finfo.frame_info.heightprint(" frame @%d,%d,%dx%d"%(finfo.frame_info.frame_idx,finfo.frame_info.frame_size,w,h))dist_cnt,dist=dmcam.frame_get_dist_u16(dev,w*h,f,finfo.frame_info)gray_cnt,gray=dmcam.frame_get_gray_u16(dev,w*h,f,finfo.frame_info)count+=1ifcount>=100:breakelse:breaktime.sleep(0.01)# breakprint(" Stop capture ...")dmcam.cap_stop(dev)print(" Close dmcam device ..")dmcam.dev_close(dev)dmcam.uninit()Changelog1.80.4:API changeNew:dmcam_cmap_palette_set/getset and get default color palette for pesudo RGB image convertion colormapsupport 60+ color palette (naming similar with matplotlib) indmcam_cmap_palette_eChange:dmcam_cmap_dist_f32_to_RGB/dmcam_cmap_dist_u16_to_RGBadd admcam_cmap_cfg_tparameter to support user specified color palette.For compatible, user can simply set this parameter to NULL to use the default color palette.New:PARAM_FLIPadded indmcam_dev_param_eto support image flip in sensor side (currently IMX556 only).New:dmcam_cap_save_frameuse to better choosing which frame to be saved into ONI replay file.New:en_save_manuallyadded indmcam_cap_cfg_tto enable user to usedmcam_cap_save_frameto save specified frame.New:DMCAM_FILTER_ID_FLYNOISEAdded indmcam_filter_id_eas fly noise filter id.fly_noise_thresholdis added indmcam_filter_args_uas fly noise threshold, valid range from 0 to 255Enhance: add parameter forDMCAM_FILTER_ID_DEPTH_FILTERto fine control the filter strengthdepth_filter_mode/depth_filter_strengthis added todmcam_filter_args_uREMOVE:dmcam_cmap_gray_u16_to_RGB32/dmcam_cmap_gray_f32_to_RGB32Main features:All linux python wheel are generated with manylinux2010 standardSupport NEW SmartToF TC-S3 (SONY IMX556 VGA TOF) device.Support Dual-freq mode for SONY TOF devices.Support 60+ color palette which is similar with the colormap defined in matplotlib.Add SSE2 optimization on depth filter/colormap conversion.Make fly-noise filter accessible and the filter strength can be controlled byDMCAM_FILTER_ID_FLYNOISEfilter.Enhance recording  function:dmcam_cap_config_setcan be used to start/stop recording during capturing without the need to stop capturing.BUG fix:Fix stall of USB layer sometimes when cap_start/cap_stop are invoked in multi-thread  app.Fix wrong value in IR image under ARM-v7 platform.1.70.0:Recommend to upgrade device firmware to 1.70 to use this SDKAPI changeRemove deprecateddmcam_cmap_floatchangedmcam_param_roi_tstructureremove filter id DMCAM_FILTER_ID_BINNINGNew:  support dual-freq of SONY IMX556New:  support binning modeEPC driver: 2x2, 4x4 and 2x4IMX driver: 2x2, 4x4, and 8x8New:  ethernet based Tof camera supportEnhance: Use parameter set/get API with parameter id PARAM_ROI to set ROI and Binning instead of using filter interface.Enhance: better support replay in HDR /Dual-freq/Binning modeFIX:C sample compiling issuewrong frame info when seeking frames of oni fileFirst frame checksum error sometimes1.68.2:Fix:Correct to set gray/ir value to be zero when overexposure.New:  add DMCAM_FILTER_ID_BINNING to support pix binningEnhance: better support ROI.1.68.1:Enhance:Optimize TC-E2 accuracy and error correction of calibration data.New: add parameter idPARAM_INFO_LENSfor user to get lens parameter throughdmcam_param_batch_get1.68.0:Enhance:replay supports gray frames related with ambient compensation from FW 164replay support switching between HDR to normal mode.dmcam_dev_get_urireturns URI with token for eth devicesEnhance performance ofdmcam_frame_get_pcl_xyzdanddmcam_frame_get_pcl_xyziNew:adddmcam_frame_get_pcl_xyziapi to get point clouds with gray as textureadddmcam_cap_seek_frameapi to seek frames when device is replay-fileadddmcam_frame_get_dist_rawfor user to get raw distance without calibrationFor sony sensors:add compression support for SONY sensorFilter chain optimizedCalibration method refined.Fix:lens paramter file not closed after openrecorded replay file without timestampdevice cannot close properly sometimes (FW ver= 164/165)1.62.2:FIX:the problem that replay file size > 2GB may not work properly under windowsEnhance: some kind of error tolerance on playing corrupted replay file.Enhance:  adden_fdev_rewindindmcam_cap_cfg_tto allow rewind replay when use dmcam replay file as device.1.62.1:Enhance:during file replay mode,if fps is set to 0,  frame capture is only ongoing after invokingdmcam_get_frames/dmcam_get_frame. This is usefully to pause & resume  the replay at application level1.62.0:Fix:replay problem when switch from QVGA to VGAFix:replay file cannot played in Niviewer of OpenNIEnhance:optimize env-light compensation1.61.6:Enhance:optimize DIST&GRAY calc performance further (boost about 50%). TC-E3 can reach up-to 115fps @ Cortex-A7 1GhzFIX:TC-E3 replay problemFIX:wrong return value ofdmcam_cap_get_frameswhen the host process is slow.New: support SONY sensorsNew: support env-light compensation1.61.2:Enhance: optimize DIST&GRAY calc performance (boost about 40%)FIX:dmcam_frame_get_pcl_xyzdanddmcam_frame_get_pcl_xyznow return number of points (x,y,z) / (x,y,z,d) equal to the number of pixels of the depth image. Invalid point in the cloud is denoted as (0,0,0) and (0,0,0,0) respectively.1.61.1:Fixa possible problem cause memory exhaustion.1.61.0:Fix: unicode problem, all python API should use 'bytes' instead of 'str' to invoke  C API in type of 'char*'1.60.0: Major releaseSupport save replay and play replay.