|
百度网盘链接:https://pan.baidu.com/s/159CfdjkgKkpgiAUfVaarNQ 提取码:sxcg
具体链接在halcom.cn论坛,联系人QQ:3283892722
该论坛是一个学习交流平台,我会逐一的和大家分享学习。
欢迎大家录制视频,并提交给我,我来设置视频,你可在论坛进行打赏分享。
视频专用播放器:http://halcom.cn/forum.php?mod=viewthread&tid=258&extra=page%3D1代码如下:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using HalconDotNet;
- namespace GenerateExe
- {
- public class Program
- {
- private static void Main(string[] args)
- {
- if(args.Count()>0)
- {
- string imagePath = args[0];
- HObject ho_Image, ho_WhiteRegion = null;
- HTuple hv_File_Name = null;
- HTuple hv_FileExits = null, hv_FileHandle = new HTuple();
- HTuple hv_Rad = new HTuple();
- // Initialize local and output iconic variables
- HOperatorSet.GenEmptyObj(out ho_Image);
- HOperatorSet.GenEmptyObj(out ho_WhiteRegion);
- try
- {
- hv_File_Name = "1.txt";
- HOperatorSet.FileExists(hv_File_Name, out hv_FileExits);
- if ((int)(hv_FileExits) != 0)
- {
- HOperatorSet.DeleteFile(hv_File_Name);
- HOperatorSet.OpenFile(hv_File_Name, "append", out hv_FileHandle);
- }
- else
- {
- HOperatorSet.OpenFile(hv_File_Name, "output", out hv_FileHandle);
- }
- }
- catch{}
- try
- {
- ho_Image.Dispose();
- HOperatorSet.ReadImage(out ho_Image, imagePath);
- }
- catch{}
- try
- {
- ho_WhiteRegion.Dispose();
- HalconAlg.getWhiteRegion(ho_Image, out ho_WhiteRegion, out hv_Rad);
- HOperatorSet.FwriteString(hv_FileHandle, hv_Rad+"\n");
- }
- catch{}
- try
- {
- HOperatorSet.CloseFile(hv_FileHandle);
- }
- catch{}
- }
-
- }
- }
- }
复制代码
|
|