00. 目录

文章目录

  • 00. 目录
  • 01. 概述
  • 02. 开发环境
  • 03. Halcon源码
  • 04. Halcon源码导出方法
  • 05. Halcon源码导出为C++程序
  • 06. 附录

01. 概述

halcon是一款非常不错的视觉类辅助设计软件,它是由非常专业的MVtec公司全新推出的最新版本。在功能上拥有非常实用方便的机器视觉开发能力,其非常独特的内部结构能够很好的辅助各种机器的视觉功能,这样不管是在医学图像上面还是各种图像分析上面都能够起到非常大的帮助,并且软件内部搭在了非常先进智能的图像算法能力,用户们在制作各种产品的时候就可以节省非常多的时间,极大的提高了工作效率。在用途方面,它也有着非常广泛的应用,能够用于多个行业的使用,就比如形态学,测量图像以及blob等等相关图像领域。作为系列的最新版本,它不光是优化了许多内容还新增了一些非常便捷的功能,现在可以做到通过更加高级方便的算法来读取条形码,极大的加快了读取速度。还对软件的开发操作环境进行非常人性化的升级优化等等

02. 开发环境

Windows系统:Windows10

Halcon版本:HDevelop 19.11

03. Halcon源码

* 读取图片文件
read_image (Image, 'fabrik')* 获取图片大小信息
get_image_size (Image, Width, Height)dev_open_window (0, 0, Width, Height, 'black', WindowHandle)

04. Halcon源码导出方法

4.1 选择文件–>导出

4.2 选择导出相关设置

支持导出的方式有:文本文件、C文件、C++文件、VB文件和C#文件。

05. Halcon源码导出为C++程序

5.1 导出文件选择C++

5.2 导出之后,查看导出的C++文件

///
// File generated by HDevelop for HALCON/C++ Version 19.11.0.0
// Non-ASCII strings in this file are encoded in local-8-bit encoding (cp936).
// Ensure that the interface encoding is set to locale encoding by calling
// SetHcppInterfaceStringEncodingIsUtf8(false) at the beginning of the program.
//
// Please note that non-ASCII characters in string constants are exported
// as octal codes in order to guarantee that the strings are correctly
// created on all systems, independent on any compiler settings.
//
// Source files with different encoding should not be mixed in one project.
///#ifndef __APPLE__
#  include "HalconCpp.h"
#  include "HDevThread.h"
#else
#  ifndef HC_LARGE_IMAGES
#    include <HALCONCpp/HalconCpp.h>
#    include <HALCONCpp/HDevThread.h>
#    include <HALCON/HpThread.h>
#  else
#    include <HALCONCppxl/HalconCpp.h>
#    include <HALCONCppxl/HDevThread.h>
#    include <HALCONxl/HpThread.h>
#  endif
#  include <stdio.h>
#  include <CoreFoundation/CFRunLoop.h>
#endifusing namespace HalconCpp;#ifndef NO_EXPORT_MAIN
// Main procedure
void action()
{// Local iconic variablesHObject  ho_Image;// Local control variablesHTuple  hv_Width, hv_Height, hv_WindowHandle;//读取图片文件ReadImage(&ho_Image, "fabrik");//获取图片大小信息GetImageSize(ho_Image, &hv_Width, &hv_Height);SetWindowAttr("background_color","black");OpenWindow(0,0,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle);HDevWindowStack::Push(hv_WindowHandle);}#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.
// Note that starting with macOS 10.12, the run loop may be stopped when a
// window is closed, so we need to put the call to CFRunLoopRun() into a loop
// of its own.
HTuple      gStartMutex;
H_pthread_t gActionThread;
HBOOL       gTerminate = FALSE;static void timer_callback(CFRunLoopTimerRef timer, void *info)
{UnlockMutex(gStartMutex);
}static Herror apple_action(void **parameters)
{// Wait until the timer has fired to start processing.LockMutex(gStartMutex);UnlockMutex(gStartMutex);try{action();}catch (HException &exception){fprintf(stderr,"  Error #%u in %s: %s\n", exception.ErrorCode(),(const char *)exception.ProcName(),(const char *)exception.ErrorMessage());}// Tell the main thread to terminate itself.LockMutex(gStartMutex);gTerminate = TRUE;UnlockMutex(gStartMutex);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);for (;;){HBOOL terminate;CFRunLoopRun();LockMutex(gStartMutex);terminate = gTerminate;UnlockMutex(gStartMutex);if (terminate)break;}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;
}
#endifint main(int argc, char *argv[])
{int ret = 0;try{#if defined(_WIN32)SetSystem("use_window_thread", "true");
#endif// file was stored with local-8-bit encoding//   -> set the interface encoding accordinglySetHcppInterfaceStringEncodingIsUtf8(false);// Default settings used in HDevelop (can be omitted)SetSystem("width", 512);SetSystem("height", 512);#ifndef __APPLE__action();
#elseret = apple_main(argc,argv);
#endif}catch (HException &exception){fprintf(stderr,"  Error #%u in %s: %s\n", exception.ErrorCode(),(const char *)exception.ProcName(),(const char *)exception.ErrorMessage());ret = 1;}return ret;
}#endif#endif

06. 附录

6.1 机器视觉博客汇总
网址:https://dengjin.blog.csdn.net/article/details/116837497

【机器视觉】 Halcon代码导出高级语言代码相关推荐

  1. Halcon PDF文档(hdevelop_users_guide)学习总结之六——Halcon如何导出C++代码

    网页图片不清晰,请另存到电脑后,以图片方式学习!

  2. 第二讲:C#与halcon联合环境配置,halcon代码导出与软件界面搭建

    一,c#与halcon联合环境配置 1.首先将找到你的halco安装目录,然后在目录下找到两个文件,halcon.dll与halcondotent.dll如下: 2.用vs2019创建一个C#窗体项目 ...

  3. 第一章 插件安装和代码导出

    Selenium IDE 1.firefox3.6安装seleniumIDE插件 地址:http://seleniumhq.org/projects/ide/ 安装完成之后,重启firefox,可以在 ...

  4. Halcon 摄像机标定流程-代码实现

    1. 标定参数的构成 • 标定参数分为相机的内参和外参: • 内参:内参标定的是摄像系统的内部结构和关系,镜头的畸变在出厂的时候就已经固定下来的,唯一可能改变的是镜头和相机之间的组装关系.所以如果相机 ...

  5. php调用python导出excel_如何使用Django导出Excel代码问题

    本篇文章主要介绍了Django 导出 Excel 代码的实例详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 这篇技术贴讲怎样在Django的框架下导出Excel, 最 ...

  6. [java]轻量级隔离化的excel导入导出的导入导出,解放导入导出冗余代码(有github源码)

    如何使用 只需要添加相应的注解 @Excel(name = "学生统计数据表",sheetName = "Sheet1" ) @Data public clas ...

  7. Java POI的Excel操作(行高列宽比例;生成说明,标题,字段;导出Excel代码,压缩)

    摘要 本文主要讲解了POI中的表格行高列宽比例,以及根据这个不同的场景生成,如标题,说明,字段头.主要是思路给大家参考,生成表格如下(完整代码代码在最后,由于我的数据格式特殊,我把我以前的通用导出数据 ...

  8. java response 输出word_如何使用java代码导出word

    前言: 导出word的需求其实在日常工作中用到的地方还不少,于是想写一篇文章好好记录一下,在导出之前,需要了解一下关于浏览器如何处理servlet的后台数据.具体可以了解一下http通信下载行为在se ...

  9. Excel 2010 VBA 入门 013 导入或导出VBA代码

    目录 1.导出宏代码 步骤1 步骤2 2.导入宏代码 步骤1 步骤2 说明 利用VBE的导入文件和导出文件功能,可以方便地导入和导出代码以实现代码的迁移. 1.导出宏代码 步骤1 按组合键[Alt+F ...

最新文章

  1. 12月24日,为我们的无线网络默哀……
  2. C 工具库3:固定大小的 obj pool
  3. hive left outer join 子查询临时表_基于历史数据的用户访问次数,每天新老用户,日活,周活,月活的hive计算...
  4. 3-3HDFS中文件的读写操作
  5. ES6 面向对象编程
  6. 数字图像处理入门(冈萨雷斯第三版)
  7. 在无参考数据集(比如LIME、MEF、DICM)上使用NIQE指标
  8. cmd脚本(WIN10下)
  9. 2014突破性科学技术:超隐私智能手机
  10. 华为od试题java_华为od社招一面凉经
  11. JavaScript防流量劫持
  12. maven 依赖com.google.code.kaptcha
  13. 终于!疫情之下,第一批企业没能熬住面临倒闭,员工被遣散,没能等来春暖花开!...
  14. 在线Excel转公式工具
  15. SpringCloud Gateway 增加了context-path 404解决办法
  16. 阿里云栖开发者沙龙(Java技术专场)火热来袭!
  17. 淮北师范大学ACM-ICPC语法直播1
  18. java编程猜拳游戏_Java开发实现猜拳游戏
  19. pytroch:model.train()、model.eval()的使用
  20. 网盘服务器安装监控系统,服务器监控程序一键安装

热门文章

  1. 【OpenCV学习】矩阵基本操作
  2. .NET核心正则类详解
  3. asp.net中关于静态页面生成的代码实例
  4. p20pro 鸿蒙,后置镜头变液态双摄?华为P50Pro再曝光,搭载鸿蒙OS传感器变1寸
  5. python tcl quartus_TCL脚本在Quartus II中的应用
  6. Java黑皮书课后题第6章:*6.38(生成随机字符)使用程序清单6-10 RandomCharacter中的方法,打印100个大写字母及100个一位数字,每行打印10个
  7. 经典面试题:链表的相交与环问题
  8. DBUtils - Python数据库连接池
  9. P2700 逐个击破
  10. 初学scrum及首次团队开发