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 ...
随机推荐
- logstash-input-jdbc and logstash-ouput-jdbc
要求通过logstash从oracle中获取数据,然后相应的直接传入mysql中去. 基本测试成功的配置文件如下: input { stdin { } jdbc { jdbc_connection_s ...
- (C#)原型模式—深复制与浅复制
1.原型模式 用原型实例指定创建对象的实例,并且通过拷贝这些原型创建新的对象. *原型模式隐藏了创建对象的细节,提高了性能. *浅复制:被复制对象的所有变量都含有与原来对象相同的值,而且所有对其他对象 ...
- unable to access android sdk add-on list and SDK 更新镜像设置
前记 国内的网络呀,真是操蛋!!!!!! unable to access android sdk add-on list 在 Android Studio 安装目录 bin/idea.propert ...
- TW实习日记:第13天
昨天困扰的问题终于解决了.因为是百度地图api提供的函数,所以这个解决办法并不适用于所有异步请求,仅仅针对百度地图api的调用接口函数和回调函数.有两种解决方法可以解决百度地图api中常出现的请求回调 ...
- java核心技术 笔记
一 . 总览 1. 类加载机制:jdk内嵌的class_loader有哪些,类加载过程.--后面需要补充 2. 垃圾收集基本原理,常见的垃圾收集器,各自适用的场景.--后面需要补充 3. 运行时动态编 ...
- 【zabbix 监控】第一章 zabbix的安装配置
安装前准备 一.下载网络yum源: http://mirrors.163.com/.help/centos.html https://opsx.alibaba.com/mirror 1.首先备份/et ...
- VBS简明教程
VBS简明教程 一.输出 VBS的输出使用函数Msgbox调用对话框进行输出. Msgbox(message) Message为要输出的信息 二.输入 VBS的输入,调用函数Inputbox()进 ...
- opencv-学习笔记(5)形态学转变
opencv-学习笔记(4)形态学转变 本章讲了几种形态学操作 腐蚀erode 膨胀dilate 开运算MORPH_OPEN 闭运算MORPH_CLOSE 形态学梯度MORPH_GRADIENT 礼帽 ...
- 左值&右值
一.引子 我们所谓的左值.右值,正确的说法应该是左值表达式.右值表达式. 因为C++的表达式不是左值就是右值. 在C中,左值指的是既能够出现在等号左边也能出现在等号右边的表达式,右值指的则是只能出现在 ...
- 福大软工1816:Alpha(10/10)
Alpha 冲刺 (10/10) 队名:第三视角 组长博客链接 本次作业链接 团队部分 团队燃尽图 工作情况汇报 张扬(组长) 过去两天完成了哪些任务: 文字/口头描述: 1.和愈明.韫月一起对接 2 ...