zl程序教程

您现在的位置是:首页 >  其他

当前栏目

C++ 调用 Halcon 时大尺寸操作无效问题的解决方案

2023-02-18 16:32:33 时间

C++ 调用 Halcon 时偶现大尺寸的算子操作无效问题,本文记录解决方案。

问题复现

  • 在 C++ 调用 Halcon 程序中,创建如下尺寸矩形
HObject Rectangle;
GenRectangle1(&Rectangle, 234, 31, 1534, 424)

HTuple test;
RegionFeatures(ho_roi, "width", &test);
cout << test[0].D() <<endl;
RegionFeatures(ho_roi, "area", &test);
cout << test[0].D() << endl;
RegionFeatures(ho_roi, "row1", &test);
cout << test[0].D() << endl;
RegionFeatures(ho_roi, "height", &test);
cout << test[0].D() << endl;
  • 正常运行时输出的都是正常的数据,出现问题时输出全为 0

问题原因

  • 原因不明 ……
  • 感觉的原因是由于某些操作尺寸较大,Halcon 默认画布装不下导致的 bug

解决方案

  • 在代码中显示定义较大的画布大小,例如加入如下代码:
HalconCpp::SetSystem("width", 8000);
HalconCpp::SetSystem("height", 8000);
  • 问题解决。