halcon语法程序:

dev_open_window (0, 300, -1, -1, 'black', WindowID)
read_image (Die4, 'C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/die/die_03.png')
draw_rectangle1 (WindowID, Row1, Column1, Row2, Column2)
gen_rectangle1 (ROI, Row1, Column1, Row2, Column2)
reduce_domain (Die4, ROI, ImageReduced)
create_template (ImageReduced, 5, 4, 'sort', 'original', TemplateID)
TemplRow := (Row1+Row2)/2
TemplCol := (Column1+Column2)/2
fast_match (Die4, Matches, TemplateID, 20)
connection (Matches, BallROI)
count_obj (BallROI, NumBall)
add_channels (BallROI, Die4, BallImage)
best_match (BallImage, TemplateID, 20, 'true', Row, Column, Error)
* disp_rectangle1 (WindowID, Row+Row1-TemplRow, Column+Column1-TemplCol, Row+Row2-TemplRow, Column+Column2-TemplCol)
RealNumBalls := 0
for i:=1 to NumBall by 1
if (Error[i-1]<255)
disp_rectangle1(WindowID,Row[i-1]+Row1-TemplRow,Column[i-1]+Column1-TemplCol,Row[i-1]+Row2-TemplRow,Column[i-1]+Column2-TemplCol)
RealNumBalls := RealNumBalls + 1
endif
endfor
set_spy ('mode', 'on')

 生成的C++代码:

///////////////////////////////////////////////////////////////////////////////
// File generated by HDevelop for HALCON/C++ Version 12.0
/////////////////////////////////////////////////////////////////////////////// #ifndef __APPLE__
# include "HalconCpp.h"
# include "HDevThread.h"
# if defined(__linux__) && !defined(NO_EXPORT_APP_MAIN)
# include <X11/Xlib.h>
# endif
#else
# ifndef HC_LARGE_IMAGES
# include <HALCONCpp/HalconCpp.h>
# include <HALCONCpp/HDevThread.h>
# else
# include <HALCONCppxl/HalconCpp.h>
# include <HALCONCppxl/HDevThread.h>
# endif
# include <stdio.h>
# include <HALCON/HpThread.h>
# include <CoreFoundation/CFRunLoop.h>
#endif using namespace HalconCpp; #ifndef NO_EXPORT_MAIN
// Main procedure
void action()
{ // Local iconic variables
HObject ho_Die4, ho_ROI, ho_ImageReduced, ho_Matches;
HObject ho_BallROI, ho_BallImage; // Local control variables
HTuple hv_WindowID, hv_Row1, hv_Column1, hv_Row2;
HTuple hv_Column2, hv_TemplateID, hv_TemplRow, hv_TemplCol;
HTuple hv_NumBall, hv_Row, hv_Column, hv_Error, hv_RealNumBalls;
HTuple hv_i; SetWindowAttr("background_color","black");
OpenWindow(0,300,-1,-1,0,"","",&hv_WindowID);
HDevWindowStack::Push(hv_WindowID);
ReadImage(&ho_Die4, "C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/die/die_03.png");
DrawRectangle1(hv_WindowID, &hv_Row1, &hv_Column1, &hv_Row2, &hv_Column2);
GenRectangle1(&ho_ROI, hv_Row1, hv_Column1, hv_Row2, hv_Column2);
ReduceDomain(ho_Die4, ho_ROI, &ho_ImageReduced);
CreateTemplate(ho_ImageReduced, 5, 4, "sort", "original", &hv_TemplateID);
hv_TemplRow = (hv_Row1+hv_Row2)/2;
hv_TemplCol = (hv_Column1+hv_Column2)/2;
FastMatch(ho_Die4, &ho_Matches, hv_TemplateID, 20);
Connection(ho_Matches, &ho_BallROI);
CountObj(ho_BallROI, &hv_NumBall);
AddChannels(ho_BallROI, ho_Die4, &ho_BallImage);
BestMatch(ho_BallImage, hv_TemplateID, 20, "true", &hv_Row, &hv_Column, &hv_Error);
//disp_rectangle1 (WindowID, Row+Row1-TemplRow, Column+Column1-TemplCol, Row+Row2-TemplRow, Column+Column2-TemplCol)
hv_RealNumBalls = 0;
{
HTuple end_val15 = hv_NumBall;
HTuple step_val15 = 1;
for (hv_i=1; hv_i.Continue(end_val15, step_val15); hv_i += step_val15)
{
if (0 != (HTuple(hv_Error[hv_i-1])<255))
{
DispRectangle1(hv_WindowID, (HTuple(hv_Row[hv_i-1])+hv_Row1)-hv_TemplRow, (HTuple(hv_Column[hv_i-1])+hv_Column1)-hv_TemplCol,
(HTuple(hv_Row[hv_i-1])+hv_Row2)-hv_TemplRow, (HTuple(hv_Column[hv_i-1])+hv_Column2)-hv_TemplCol);
hv_RealNumBalls += 1;
}
}
}
SetSpy("mode", "on");
} #ifndef NO_EXPORT_APP_MAIN #ifdef __APPLE__
// On OS X systems, we must have a CFRunLoop running on the main thread in
// order for the HALCON graphics operators to work correctly, and run the
// action function in a separate thread. A CFRunLoopTimer is used to make sure
// the action function is not called before the CFRunLoop is running.
HTuple gStartMutex;
H_pthread_t gActionThread; static void timer_callback(CFRunLoopTimerRef timer, void *info)
{
UnlockMutex(gStartMutex);
} static Herror apple_action(void **parameters)
{
LockMutex(gStartMutex);
action();
CFRunLoopStop(CFRunLoopGetMain());
return H_MSG_OK;
} static int apple_main(int argc, char *argv[])
{
Herror error;
CFRunLoopTimerRef Timer;
CFRunLoopTimerContext TimerContext = { 0, 0, 0, 0, 0 }; CreateMutex("type","sleep",&gStartMutex);
LockMutex(gStartMutex); error = HpThreadHandleAlloc(&gActionThread);
if (H_MSG_OK != error)
{
fprintf(stderr,"HpThreadHandleAlloc failed: %d\n", error);
exit(1);
} error = HpThreadCreate(gActionThread,0,apple_action);
if (H_MSG_OK != error)
{
fprintf(stderr,"HpThreadCreate failed: %d\n", error);
exit(1);
} Timer = CFRunLoopTimerCreate(kCFAllocatorDefault,
CFAbsoluteTimeGetCurrent(),0,0,0,
timer_callback,&TimerContext);
if (!Timer)
{
fprintf(stderr,"CFRunLoopTimerCreate failed\n");
exit(1);
}
CFRunLoopAddTimer(CFRunLoopGetCurrent(),Timer,kCFRunLoopCommonModes);
CFRunLoopRun();
CFRunLoopRemoveTimer(CFRunLoopGetCurrent(),Timer,kCFRunLoopCommonModes);
CFRelease(Timer); error = HpThreadHandleFree(gActionThread);
if (H_MSG_OK != error)
{
fprintf(stderr,"HpThreadHandleFree failed: %d\n", error);
exit(1);
} ClearMutex(gStartMutex);
return 0;
}
#endif int main(int argc, char *argv[])
{
// Default settings used in HDevelop (can be omitted)
int ret=0;
SetSystem("width", 512);
SetSystem("height", 512); #if defined(_WIN32)
SetSystem("use_window_thread", "true");
#elif defined(__linux__)
XInitThreads();
#endif #ifndef __APPLE__
action();
#else
ret = apple_main(argc,argv);
#endif
return ret;
} #endif #endif

  

halcon程序输出成c++程序的更多相关文章

  1. 使用py2exe将python程序打包成exe程序

    近日帮朋友写了个python小程序,从互联网上抓取一些需要的文章到本地.为了运行方便,希望能转换成exe程序在windows下定期执行.从百度上找了些文章,发现py2exe的应用比较多,遂使用之. 1 ...

  2. 将halcon导出的c++程序打包成dll库

     1.从“文件”菜单中,选择“新建”,然后选择“项目…”. 2.从“项目类型”窗格中选择“Visual C++”下的“Win32”. 3.从“模板”窗格中,选择“Win32 控制台应用程序”. 4.为 ...

  3. sencha touch打包成安装程序

    为了更好地向大家演示如何打包一个sencha touch的项目,我们用sencha cmd创建一个演示项目,如果你的sencha cmd环境还没有配置,请参照 sencha touch 入门系列 (二 ...

  4. 将eclipse的应用程序打包成.exe

    转自:http://blog.163.com/loveshijie_1991/blog/static/1760553112012102573437156/ 参考:http://blog.csdn.ne ...

  5. 使用EXE4J和Inno Setup 编译器将java程序打包成windows桌面应用安装程序

    java项目结构如下: Demo是模仿程序快照,主要设计两个按钮:保存快照和恢复快照: 保存快照将对象(窗口)序列化保存下来,后面无论做了什么操作,只要点击恢复快照, 就会读取之前保存的序列化的对象. ...

  6. Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer 关于Newtonsoft.Json,LINQ to JSON的一个小demo mysql循环插入数据、生成随机数及CONCAT函数 .NET记录-获取外网IP以及判断该IP是属于网通还是电信 Guid的生成和数据修整(去除空格和小写字符)

    Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer   Advanced Installer :Free for 30 da ...

  7. Windows服务项目打包成安装包(Windows服务)-----------VS2017项目程序打包成.msi或者.exe

    VS2017项目程序打包成.msi或者.exe Windows服务项目使用VS2017项目程序打包成.msi或者.exe安装包 项目打包成安装包(Windows服务) 1.安装打包插件:Microso ...

  8. VS2017项目程序打包成.msi或者.exe

    VS2017项目程序打包成.msi或者.exe 1.安装打包插件:Microsoft Visual Studio 2017 Installer Projects 打开vs2017 ,选择 工具 --& ...

  9. sencha touch 扩展篇之将sencha touch打包成安装程序(上)- 使用sencha cmd打包安装程序

    由于最近一直忙着android原生的开发,很久没有更新博客了,官方的sencha cmd工具功能非常强大,创建项目,压缩项目,打包安装程序都能轻松实现,这讲我们就给大家介绍下如何使用sencha cm ...

随机推荐

  1. gitignore 文件生效办法

    .gitignore 可以添加一些不加入git版本控制的文件 比如一些测试文件.因人而异的配置信息等等 .gitignore 文件展示如下 /.idea/target//.classpath /.pr ...

  2. usdt信息小结

    https://blog.csdn.net/weixin_42208011/article/details/80499536 https://blog.csdn.net/weixin_42208011 ...

  3. 一道java笔试题

    输入一串用空格隔开的数字串,对于数字串的奇数位按升序排序,偶数位按降序排序. 示例输入: 4 6 2 3 6 7 8 1 处理过程: 奇数位:4 2 6 8 升序排序结果: 2 4 6 8 偶数位:6 ...

  4. Redis+Keepalived高可用方案详细分析

    背景 目前,Redis集群的官方方案还处在开发测试中,未集成到稳定版中.且目前官方开发中的Redis Cluster提供的功能尚不完善(可参考官方网站或http://www.redisdoc.com/ ...

  5. Thunder团队第六周 - Scrum会议1

    Scrum会议1 小组名称:Thunder 项目名称:i阅app Scrum Master:王航 工作照片: 参会成员: 王航(Master):http://www.cnblogs.com/wangh ...

  6. 基于NABCD评论“探路者”Alpha版作品

    1.分析 N(Need):”为了重温贪吃蛇这一经典游戏,本组的选题定为贪吃蛇游戏,并在此基础上进行了新的创新,将普通的贪吃蛇游戏改为单词版贪吃蛇.市面上的英语单词背记软件对于那些缺少英语学习兴趣.毅力 ...

  7. 第二十一次ScrumMeeting会议

    第二十一次Scrum Meeting 时间:2017/12/11 地点:SPR咖啡馆 人员:王子铭 游心 解小锐 王辰昱 李金奇 杨森 陈鑫 赵晓宇 照片: 目前工作进展 名字 今日 明天的工作 蔡帜 ...

  8. jquery.validate 中文乱码解决方法

    第一种.就是所说的引用jquery.validate.messages_cn.js                    下载地址:http://files.cnblogs.com/files/pin ...

  9. SpringData——HelloWorld

    1.背景 最开始了解SpringData的时候,以为他不就是ORM的一种实现方式嘛,还能有什么新的东西.从hibernate到ibatis.mybatis,也许他只不过是spring想整合一个更方便的 ...

  10. Jenkins系列-Jenkins通过Publish over SSH插件实现远程部署

    配置ssh免秘钥登录 安装Publish over SSH插件 插件使用官网:https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plug ...