Hi, colleagues
I have a question: why dump_window operator doesn't work when I use *.hdvp file from code?
- bExample1.ItemClick += (s, e) =>
- {
- HDevEngine dev = new HDevEngine();
- string exec = Application.ExecutablePath;
- string execFolder = System.IO.Path.GetDirectoryName(exec);
- dev.SetProcedurePath($@"{execFolder}");
- HDevProcedure proc = new HDevProcedure("Example1_GetImage");
- HDevProcedureCall call = new HDevProcedureCall(proc);
- HObject srcImage = (PE.Image as Bitmap).BitmapToHobject();
- string SomeText = "Hello, Denis!";
- call.SetInputIconicParamObject("SourceImage", srcImage);
- call.SetInputCtrlParamTuple("SomeText", new HTuple(SomeText));
- try
- {
- call.Execute();
- HTuple OutputImagePath = call.GetOutputCtrlParamTuple("OutputImagePath");
- HObject BackgroundImage = call.GetOutputIconicParamObject("BackgroundImage");
- dev.UnloadAllProcedures();
- call.Reset();
- dev.Dispose();
- proc.Dispose();
- call.Dispose();
- PE.Image = new Bitmap(OutputImagePath.S);
- }
- catch(HalconDotNet.HalconException ex)
- {
- Console.WriteLine(ex.Message);
- }
- };
- }
- }
复制代码
Appears error: HALCON operator error in procedure: 'Example1_GetImage' line: 7, dump_window_image:
Wrong type of control parameter 1
- get_image_size(SourceImage, Width, Height)
- dev_open_window(0, 0, Width, Height, 'black', WindowHandle)
- dev_set_window(WindowHandle)
- dev_display(SourceImage)
- disp_message (WindowHandle, SomeText, 'image', 12, 12, 'black', 'false')
- OutputImagePath:='OutputImage.png'
- dump_window_image(Image, WindowHandle)
- write_image(Image, 'png', 0, OutputImagePath)
复制代码 |