刚刚接触Halcon 看别人的帖子 都是有这个HD.RunHalcon(hWindowControl1.HalconWindow);显示张图片。
为什么我导出的C#程序没有这个RunHalcon这个方法?
- public partial class HDevelopExport
- {
- #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
- public HDevelopExport()
- {
- // Default settings used in HDevelop
- HOperatorSet.SetSystem("width", 512);
- HOperatorSet.SetSystem("height", 512);
- if (HalconAPI.isWindows)
- HOperatorSet.SetSystem("use_window_thread","true");
- action();
- }
- #endif
- #if !NO_EXPORT_MAIN
- // Main procedure
- private void action()
- {
- // Local iconic variables
- HObject ho_Image, ho_ImageGray;
- // Local control variables
- HTuple hv_WindowHandle = new HTuple(), hv_Width = new HTuple();
- HTuple hv_Height = new HTuple();
- // Initialize local and output iconic variables
- HOperatorSet.GenEmptyObj(out ho_Image);
- HOperatorSet.GenEmptyObj(out ho_ImageGray);
- HOperatorSet.SetWindowAttr("background_color","black");
- HOperatorSet.OpenWindow(0,0,512,512,0,"visible","",out hv_WindowHandle);
- HDevWindowStack.Push(hv_WindowHandle);
- ho_Image.Dispose();
- HOperatorSet.ReadImage(out ho_Image, "C:/Users/Administrator/Desktop/视觉Test/二维码/1.PNG");
- if (HDevWindowStack.IsOpen())
- {
- HOperatorSet.DispObj(ho_Image, HDevWindowStack.GetActive());
- }
- hv_Width.Dispose();hv_Height.Dispose();
- HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
- ho_ImageGray.Dispose();
- HOperatorSet.Rgb3ToGray(ho_Image, ho_Image, ho_Image, out ho_ImageGray);
- if (HDevWindowStack.IsOpen())
- {
- HOperatorSet.DispObj(ho_ImageGray, HDevWindowStack.GetActive());
- }
- ho_Image.Dispose();
- ho_ImageGray.Dispose();
- hv_WindowHandle.Dispose();
- hv_Width.Dispose();
- hv_Height.Dispose();
- }
- #endif
- }
- #if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
- public class HDevelopExportApp
- {
- static void Main(string[] args)
- {
- new HDevelopExport();
- }
- }
复制代码
|