halcon程序输出成c++程序
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++程序的更多相关文章
- 使用py2exe将python程序打包成exe程序
近日帮朋友写了个python小程序,从互联网上抓取一些需要的文章到本地.为了运行方便,希望能转换成exe程序在windows下定期执行.从百度上找了些文章,发现py2exe的应用比较多,遂使用之. 1 ...
- 将halcon导出的c++程序打包成dll库
1.从“文件”菜单中,选择“新建”,然后选择“项目…”. 2.从“项目类型”窗格中选择“Visual C++”下的“Win32”. 3.从“模板”窗格中,选择“Win32 控制台应用程序”. 4.为 ...
- sencha touch打包成安装程序
为了更好地向大家演示如何打包一个sencha touch的项目,我们用sencha cmd创建一个演示项目,如果你的sencha cmd环境还没有配置,请参照 sencha touch 入门系列 (二 ...
- 将eclipse的应用程序打包成.exe
转自:http://blog.163.com/loveshijie_1991/blog/static/1760553112012102573437156/ 参考:http://blog.csdn.ne ...
- 使用EXE4J和Inno Setup 编译器将java程序打包成windows桌面应用安装程序
java项目结构如下: Demo是模仿程序快照,主要设计两个按钮:保存快照和恢复快照: 保存快照将对象(窗口)序列化保存下来,后面无论做了什么操作,只要点击恢复快照, 就会读取之前保存的序列化的对象. ...
- 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 ...
- Windows服务项目打包成安装包(Windows服务)-----------VS2017项目程序打包成.msi或者.exe
VS2017项目程序打包成.msi或者.exe Windows服务项目使用VS2017项目程序打包成.msi或者.exe安装包 项目打包成安装包(Windows服务) 1.安装打包插件:Microso ...
- VS2017项目程序打包成.msi或者.exe
VS2017项目程序打包成.msi或者.exe 1.安装打包插件:Microsoft Visual Studio 2017 Installer Projects 打开vs2017 ,选择 工具 --& ...
- sencha touch 扩展篇之将sencha touch打包成安装程序(上)- 使用sencha cmd打包安装程序
由于最近一直忙着android原生的开发,很久没有更新博客了,官方的sencha cmd工具功能非常强大,创建项目,压缩项目,打包安装程序都能轻松实现,这讲我们就给大家介绍下如何使用sencha cm ...
随机推荐
- SpriteKit手机游戏摇杆JoyStick的使用 -- by iFIERO游戏开发教程
### 工欲善其事,必先利其器 有时候学习如何应用第三方库是非常重要的,因为我们不用再自己重复造轮子,在这里,我们就把原先利用重力感应来操控飞机改为用游戏摇杆joystick来操控,具体的操作如下:` ...
- Spring Cloud(十):服务网关 Zuul(路由)【Finchley 版】
Spring Cloud(十):服务网关 Zuul(路由)[Finchley 版] 发表于 2018-04-23 | 更新于 2018-05-09 | 通过之前几篇 Spring Cloud 中 ...
- springmvc项目,浏览器报404错误的问题
问题描述: 建立了web工程,配置pom.xml,web.xml,编写controller类,在spring-mvc-servlet.xml文件中指定开启注解和扫描的包位置<mvc:annota ...
- SIG蓝牙mesh笔记3_网络结构
目录 3. Mesh Networking 3.1 Bearers 承载层 3.2 Network Layer 网络层 3.2.3 Address validity 地址有效性 3.2.4 Netwo ...
- 一:HDFS 用户指导
1.hdfs的牛逼特性 Hadoop, including HDFS, is well suited for distributed storage and distributed processin ...
- Thunder团队第六周 - Scrum会7
Scrum会议7 小组名称:Thunder 项目名称:i阅app Scrum Master:杨梓瑞 工作照片: 参会成员: 王航:http://www.cnblogs.com/wangh013/ 李传 ...
- 软件工程第六周psp
1.psp表格 类别 任务 开始时间 结束时间 中断时间 delta时间 立会 讲技术文档,分配任务 10月20日16:17 10月20日16:50 0 33分钟 准备工作 根据任务查资料 10月20 ...
- Median of Two Sorted Arrays(hard)
题目要求: 有两个排序的数组nums1和nums2分别为m和n大小. 找到两个排序数组的中位数.整体运行时间复杂度应为O(log(m + n)). 示例: 我的方法: 分别逐个读取两个数组的数,放到一 ...
- OSG学习:多重纹理映射
#include<osgViewer\Viewer> #include<osg\Node> #include<osg\Geode> #include<osg\ ...
- Web界面和Winform界面生成,代码生成工具
在上面一篇随笔<代码生成工具之界面快速生成>介绍了代码生成工具Database2Sharp的界面生成操作,其中介绍了Web界面(包括列表界面.内容显示.内容编辑界面的生成,另外还介绍了Wi ...