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 ...
随机推荐
- Struts2(九.利用layer组件实现图片显示功能)
1.layer前端组件介绍 layer是一款口碑极佳的web弹层组件,她具备全方位的解决方案,致力于服务各个水平段的开发人员,您的页面会轻松地拥有丰富而友好的操作体验. http://sentsin. ...
- 基础的表ADT -数据结构(C语言实现)
读数据结构与算法分析 表的概述 形如A1,A2,A3... 操作合集 PrintList MakeEmpty Find Insert Delete 表的简单数组实现 分析: PrintList和Fin ...
- 孤荷凌寒自学python第八十五天配置selenium并进行模拟浏览器操作1
孤荷凌寒自学python第八十五天配置selenium并进行模拟浏览器操作1 (完整学习过程屏幕记录视频地址在文末) 要模拟进行浏览器操作,只用requests是不行的,因此今天了解到有专门的解决方案 ...
- Python+Flask+Gunicorn 项目实战(一) 从零开始,写一个Markdown解析器 —— 初体验
(一)前言 在开始学习之前,你需要确保你对Python, JavaScript, HTML, Markdown语法有非常基础的了解.项目的源码你可以在 https://github.com/zhu-y ...
- Python3 深浅拷贝
一 定义 在Python中对象的赋值其实就是对象的引用.当创建一个对象,把它赋值给另一个变量的时候,python并没有拷贝这个对象,只是拷贝了这个对象的引用而已. 浅拷贝: 浅拷贝值只拷贝一层,具有自 ...
- Sublime Text 插件之:MarkDown
Sublime Text 插件之:MarkDown 喜欢写文档的同学应该离不开 MarkDown ,ST(Sublime Text)的插件 Markdown Preview 就支持实时在浏览器中预览p ...
- Centos7 下nginx nginx-1.13.4 安装
环境:CentOS Linux release 7.3.1611 (Core) Linux localhost.localdomain 3.10.0-514.26.2.el7.x86_64 #1 S ...
- LintCode-61.搜索区间
搜索区间 给定一个包含 n 个整数的排序数组,找出给定目标值 target 的起始和结束位置. 如果目标值不在数组中,则返回[-1, -1] 样例 给出[5, 7, 7, 8, 8, 10]和目标值t ...
- <Android>对话框的使用
Android系统提供四种对话框:警告对话框(AlertDialog),进度对话框(ProgressDialog),日期选择对话框(DatePickerDialog)和时间选择对话框(TimePick ...
- Qt单元测试(QTestLib)
版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Qt单元测试(QTestLib) 本文地址:http://techieliang.co ...