GTX_AI 发表于 2020-4-19 12:06:44

多个图像同步显示解决图像闪烁问题

多个图像显示解决图像闪烁问题* This program performs the calibration of a multi-view stereo
* setup consisting of 4 identical cameras.
*
* Set some parameters
dev_update_off ()
dev_get_preferences ('suppress_handled_exceptions_dlg', PreferenceValues)
dev_set_preferences ('suppress_handled_exceptions_dlg', 'true')
ImgPath := '3d_machine_vision/multi_view/'
ImgPrefix := 'multi_view_calib_'
FileName := ImgPath + ImgPrefix + 'cam_0_00'
read_image (Image, FileName)
get_image_size (Image, Width, Height)
Scale := 0.5
*
* Calibration parameters
CaltabDescr := 'caltab_100mm.descr'
* CaltabThickness := 0.0064
NumCameras := 4
NumCalibObjects := 1
NumPoses := 20
CameraType := 'area_scan_polynomial'
StartCamPar :=
*
* Create camera calibration model and set parameters
create_calib_data ('calibration_object', NumCameras, NumCalibObjects, CalibDataID)
* Set used camera type
set_calib_data_cam_param (CalibDataID, 'all', CameraType, StartCamPar)
* Set used calibration object
set_calib_data_calib_object (CalibDataID, 0, CaltabDescr)
*
* Process the calibration images
open_windows_multi_view_setup (Height, Width, Scale, WindowHandles)
NumIgnoredImg := 0
for PoseIndex := 0 to NumPoses - 1 by 1
    for CameraIndex := 0 to NumCameras - 1 by 1
      FileName := ImgPath + ImgPrefix + 'cam_' + CameraIndex + '_' + PoseIndex $ '02'
      read_image (Image, FileName)
      *
      set_system ('flush_graphic', 'false')
      dev_set_window (WindowHandles)
      dev_display (Image)
      Message := ['Camera ' + CameraIndex,'Pose # ' + PoseIndex]
      Color := ['black','black']
      * Extract observation data
      ShowErrorMsg := false
      try
            * Find the calibration table, extract the marks and store the
            * observation in the calibration data model
            find_calib_object (Image, CalibDataID, CameraIndex, 0, PoseIndex, [], [])
            * Read the caltab and the marks' contours found for visualization
            get_calib_data_observ_contours (Caltab, CalibDataID, 'caltab', CameraIndex, 0, PoseIndex)
            get_calib_data_observ_contours (Marks, CalibDataID, 'marks', CameraIndex, 0, PoseIndex)
            dev_display (Caltab)
            dev_display (Marks)
      catch (Exception)
            * If the calibration table or marks were not identified,
            * process the next image. Some missing data is
            * not dramatic since the calibration is robust.
            ShowErrorMsg := true
            NumIgnoredImg := NumIgnoredImg + 1
            Message :=
            Color :=
      endtry
      disp_message (WindowHandles, Message, 'window', 12, 12, Color, 'true')
      if (ShowErrorMsg)
            * Show error status
            enforce_visualization (WindowHandles)
            disp_continue_message (WindowHandles, 'black', 'true')
            stop ()
      endif
    endfor
    enforce_visualization (WindowHandles)
endforopen_windows_multi_view_setup函数如下:
* This procedure opens four windows in order to display
* the images of a multi-view stereo setup consisting
* of four cameras
*
dev_open_window ((Height * Scale) + 10, (Width * Scale) + 10, Width * Scale, Height * Scale, 'black', WindowHandle3)
dev_set_draw ('margin')
dev_set_line_width (1)
dev_set_color ('green')
set_display_font (WindowHandle3, 14, 'mono', 'true', 'false')
*
dev_open_window ((Height * Scale) + 10, 0, Width * Scale, Height * Scale, 'black', WindowHandle2)
dev_set_draw ('margin')
dev_set_line_width (1)
dev_set_color ('green')
set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
*
dev_open_window (0, (Width * Scale) + 10, Width * Scale, Height * Scale, 'black', WindowHandle1)
dev_set_draw ('margin')
dev_set_line_width (1)
dev_set_color ('green')
set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
*
dev_open_window (0, 0, Width * Scale, Height * Scale, 'black', WindowHandle0)
dev_set_draw ('margin')
dev_set_line_width (1)
dev_set_color ('green')
set_display_font (WindowHandle0, 14, 'mono', 'true', 'false')
WindowHandles :=
return ()enforce_visualization函数如下:
* This procedure enforces the visualization in the windows
* specified within WindowHandles
*
set_system ('flush_graphic', 'true')
for Index := 0 to |WindowHandles| - 1 by 1
    write_string (WindowHandles, '')
endfor
return ()主要函数:
set_system ('flush_graphic', 'false')
set_system ('flush_graphic', 'true')

PS:Halcon12版本




页: [1]
查看完整版本: 多个图像同步显示解决图像闪烁问题