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
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 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 .
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
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 .
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 .
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
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