程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Halcon installation and python joint programming

編輯:Python

halcon brief introduction

halcon It is the most famous commercial visual software in the industrial field , Performance is very good , Of course it's expensive .
opencv It's open source. , free , But it doesn't work , You need to write your own algorithm , Too much time and effort , So I'm going to halcon

halcon install

I installed 21.05 edition , The version number is python Call over there 21050, It belongs to a relatively new version ,license Words , Officially available for trial use 1 Months of trial License, Many of them are available online , Self search .
There's nothing to say about the installation , normal setup , After loading, it will License Put the file in the corresponding directory .
After everything is done , The desktop will appear 2 An icon

One belt XL, The other one doesn't have ,2 The difference is XL It is specially used to process large image files ,32k * 32k Use this for the above picture , General picture processing without XL That's OK

anaconda install

anaconda Download the latest version on the official website , I installed 2022.05 edition
Check the path option during installation , Tick both

My installation path is C:\anaconda3, Remember this path , You need to configure the environment later , stay C:\anaconda3\envs.
When it is installed, it comes with it python3.9, There are also many commonly used libraries , There is no need to install them one by one .

Anaconda Configuration of

stay windows Use administrator privileges to type cmd.exe, Input conda create -n halcon python=3.9, Can be in C:\anaconda3\env Next create a new one called halcon Development environment of . Then input conda activate halcon Activate halcon Environmental Science , You can see that the prompt has changed

install Halcon library

continue installation Halcon library ,pip install mvtec-halcon==21050,21050 I installed it Halcon Version number of , This number must be consistent with the installed Halcon Corresponding . Can be in Halcon After operation , help – Version information found in about .

After the installation , Input conda list

You can see what the arrow points to Halcon The library is already installed .

python Development environment of :pyCharm

I am using IDE yes PyCharm, See this article for installation , Skip the first 1 Step by step Python Can be installed .https://blog.csdn.net/13011803189/article/details/125114038
Or go straight to PyCharm Official website download , Just use the free community edition , The commercial version will be charged , It is not necessary to .

New project


And then in Halcon Copy from the installation directory of halcon.dll, halconc.dll, halconcpp.dll, hdevenginecpp.dll this 4 Files into the new project
my Halcon The installation directory is the default ,C:\Program Files\MVTec\HALCON-21.05-Progress\bin\x64-win64
When it's done , stay Pycharm It's like this in English

Halcon and Python Joint programming example

main.py The contents in are as follows , Without any modification , Copy and paste directly

import halcon as ha
import os
if __name__ == '__main__':
img = ha.read_image('pcb')
width, height = ha.get_image_size_s(img)
print(width, height)

If all the previous operations are correct , There should be a printout
1109 871


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved