Hello Mat

 找回密码
 立即注册
查看: 5719|回复: 8

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

[复制链接]

84

主题

115

帖子

731

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
1467
发表于 2020-4-19 12:06:44 | 显示全部楼层 |阅读模式
多个图像显示解决图像闪烁问题
  1. * This program performs the calibration of a multi-view stereo
  2. * setup consisting of 4 identical cameras.
  3. *
  4. * Set some parameters
  5. dev_update_off ()
  6. dev_get_preferences ('suppress_handled_exceptions_dlg', PreferenceValues)
  7. dev_set_preferences ('suppress_handled_exceptions_dlg', 'true')
  8. ImgPath := '3d_machine_vision/multi_view/'
  9. ImgPrefix := 'multi_view_calib_'
  10. FileName := ImgPath + ImgPrefix + 'cam_0_00'
  11. read_image (Image, FileName)
  12. get_image_size (Image, Width, Height)
  13. Scale := 0.5
  14. *
  15. * Calibration parameters
  16. CaltabDescr := 'caltab_100mm.descr'
  17. * CaltabThickness := 0.0064
  18. NumCameras := 4
  19. NumCalibObjects := 1
  20. NumPoses := 20
  21. CameraType := 'area_scan_polynomial'
  22. StartCamPar := [0.0085,0.0,0.0,0.0,0.0,0.0,6e-6,6e-6,Width * .5,Height * .5,Width,Height]
  23. *
  24. * Create camera calibration model and set parameters
  25. create_calib_data ('calibration_object', NumCameras, NumCalibObjects, CalibDataID)
  26. * Set used camera type
  27. set_calib_data_cam_param (CalibDataID, 'all', CameraType, StartCamPar)
  28. * Set used calibration object
  29. set_calib_data_calib_object (CalibDataID, 0, CaltabDescr)
  30. *
  31. * Process the calibration images
  32. open_windows_multi_view_setup (Height, Width, Scale, WindowHandles)
  33. NumIgnoredImg := 0
  34. for PoseIndex := 0 to NumPoses - 1 by 1
  35.     for CameraIndex := 0 to NumCameras - 1 by 1
  36.         FileName := ImgPath + ImgPrefix + 'cam_' + CameraIndex + '_' + PoseIndex $ '02'
  37.         read_image (Image, FileName)
  38.         *
  39.         set_system ('flush_graphic', 'false')
  40.         dev_set_window (WindowHandles[CameraIndex])
  41.         dev_display (Image)
  42.         Message := ['Camera ' + CameraIndex,'Pose # ' + PoseIndex]
  43.         Color := ['black','black']
  44.         * Extract observation data
  45.         ShowErrorMsg := false
  46.         try
  47.             * Find the calibration table, extract the marks and store the
  48.             * observation in the calibration data model
  49.             find_calib_object (Image, CalibDataID, CameraIndex, 0, PoseIndex, [], [])
  50.             * Read the caltab and the marks' contours found for visualization
  51.             get_calib_data_observ_contours (Caltab, CalibDataID, 'caltab', CameraIndex, 0, PoseIndex)
  52.             get_calib_data_observ_contours (Marks, CalibDataID, 'marks', CameraIndex, 0, PoseIndex)
  53.             dev_display (Caltab)
  54.             dev_display (Marks)
  55.         catch (Exception)
  56.             * If the calibration table or marks were not identified,
  57.             * process the next image. Some missing data is
  58.             * not dramatic since the calibration is robust.
  59.             ShowErrorMsg := true
  60.             NumIgnoredImg := NumIgnoredImg + 1
  61.             Message := [Message,'This image will be ignored.']
  62.             Color := [Color,'red']
  63.         endtry
  64.         disp_message (WindowHandles[CameraIndex], Message, 'window', 12, 12, Color, 'true')
  65.         if (ShowErrorMsg)
  66.             * Show error status
  67.             enforce_visualization (WindowHandles)
  68.             disp_continue_message (WindowHandles[3], 'black', 'true')
  69.             stop ()
  70.         endif
  71.     endfor
  72.     enforce_visualization (WindowHandles)
  73. endfor
复制代码
open_windows_multi_view_setup函数如下:
  1. * This procedure opens four windows in order to display
  2. * the images of a multi-view stereo setup consisting
  3. * of four cameras
  4. *
  5. dev_open_window ((Height * Scale) + 10, (Width * Scale) + 10, Width * Scale, Height * Scale, 'black', WindowHandle3)
  6. dev_set_draw ('margin')
  7. dev_set_line_width (1)
  8. dev_set_color ('green')
  9. set_display_font (WindowHandle3, 14, 'mono', 'true', 'false')
  10. *
  11. dev_open_window ((Height * Scale) + 10, 0, Width * Scale, Height * Scale, 'black', WindowHandle2)
  12. dev_set_draw ('margin')
  13. dev_set_line_width (1)
  14. dev_set_color ('green')
  15. set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
  16. *
  17. dev_open_window (0, (Width * Scale) + 10, Width * Scale, Height * Scale, 'black', WindowHandle1)
  18. dev_set_draw ('margin')
  19. dev_set_line_width (1)
  20. dev_set_color ('green')
  21. set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
  22. *
  23. dev_open_window (0, 0, Width * Scale, Height * Scale, 'black', WindowHandle0)
  24. dev_set_draw ('margin')
  25. dev_set_line_width (1)
  26. dev_set_color ('green')
  27. set_display_font (WindowHandle0, 14, 'mono', 'true', 'false')
  28. WindowHandles := [WindowHandle0,WindowHandle1,WindowHandle2,WindowHandle3]
  29. return ()
复制代码
enforce_visualization函数如下:
  1. * This procedure enforces the visualization in the windows
  2. * specified within WindowHandles
  3. *
  4. set_system ('flush_graphic', 'true')
  5. for Index := 0 to |WindowHandles| - 1 by 1
  6.     write_string (WindowHandles[Index], '')
  7. endfor
  8. return ()
复制代码
主要函数:
set_system ('flush_graphic', 'false')
set_system ('flush_graphic', 'true')

PS:Halcon12版本




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-11-23 00:25 , Processed in 0.234389 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表