• Halcon相机硬触发采集图片


     1         public static void Start()
     2         {
     3             Thread thdGrab = new Thread(new ThreadStart(GrabImage));
     4             thdGrab.IsBackground = true;
     5             thdGrab.Start();
     6             Thread thdCal = new Thread(new ThreadStart(Process));
     7             thdCal.IsBackground = true;
     8             thdCal.Start();
     9         }
    10         private static void GrabImage()
    11         {
    12             HImage _imageA = new HImage();
    13             HImage _imageB = new HImage();
    14             HObject hv_objectA = null;
    15             HObject hv_objectB = null;
    16             HOperatorSet.GrabImageStart(hv_AcqHandle_A, -1);
    17             HOperatorSet.GrabImageStart(hv_AcqHandle_B, -1);
    18             //Run acquisition loop.
    19             while (cAuto.bStart)
    20             {
    21                 Thread.Sleep(10);
    22                 try
    23                 {
    24                     HOperatorSet.GrabImageAsync(out hv_objectA, hv_AcqHandle_A, -1.0);
    25                     HOperatorSet.GrabImageAsync(out hv_objectB, hv_AcqHandle_B, -1.0);
    26                     if (hv_objectA != null && hv_objectB != null)//采集OK
    27                     {
    28                         cAuto.UpdateGUI((int)cAuto.UpdateItem.Log_Info, "Camera_A,Camera_B grab image OK...");
    29                         HObjectToHImage(hv_objectA, ref _imageA);
    30                         HObjectToHImage(hv_objectB, ref _imageB);
    31                         hv_objectA = null;
    32                         hv_objectB = null;
    33                         List<HImage> lstImgs = new List<HImage>();
    34                         lstImgs.Add(_imageA.Clone());
    35                         lstImgs.Add(_imageB.Clone());
    36                         EnqueueImage(lstImgs);//入队列
    37                     }
    38                 }
    39                 catch(Exception ex) //处理超时引发的异常
    40                 {
    41                     continue;
    42                 }
    43             }
    44         }
    45         private static void Process()
    46         {
    47             while(cAuto.bStart)
    48             {
    49                 Thread.Sleep(20);
    50                 if (IsQueueImageEmpty()) { continue; }
    51                 List<HImage> lstImage = DequeueImage(); //出队列
    52                 //do something
             } 54 } 55 private static void HObjectToHImage(HObject obj, ref HImage img) 56 { 57 HTuple pointer, type, width, heght; 58 HOperatorSet.GetImagePointer1(obj, out pointer, out type, out width, out heght); 59 img.GenImage1(type, width, heght, pointer); 60 } 61
  • 相关阅读:
    python --函数
    Python基本数据类型
    初识python
    【 D3.js 高级系列 — 8.0 】 标线
    【 D3.js 高级系列 — 7.0 】 标注地点
    Azure SQL 数据库最新版本现已提供预览版
    Azure SQL 数据库新服务级别现已正式发布
    聚焦 SQL 数据库活动异地复制
    Azure SQL 数据库:服务级别与性能问答
    Azure SQL 数据库:新服务级别问答
  • 原文地址:https://www.cnblogs.com/larry-xia/p/9262816.html
Copyright © 2020-2023  润新知