日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > ChatGpt >内容正文

ChatGpt

【机器视觉】 Halcon代码导出高级语言代码

發布時間:2024/4/24 ChatGpt 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【机器视觉】 Halcon代码导出高级语言代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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代码导出高级语言代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。