设置首页收藏本站
LICENSES:2024_11
开启左侧

HalconDotNet dump_window problem.

[复制链接]
Evgeniy 发表于 2021-5-24 19:38:12 | 显示全部楼层 |阅读模式
Hi, colleagues

I have a question: why dump_window operator doesn't work when I use *.hdvp file from code?
  1. bExample1.ItemClick += (s, e) =>
  2.             {
  3.                 HDevEngine dev = new HDevEngine();

  4.                 string exec = Application.ExecutablePath;
  5.                 string execFolder = System.IO.Path.GetDirectoryName(exec);

  6.                 dev.SetProcedurePath($@"{execFolder}");

  7.                 HDevProcedure proc = new HDevProcedure("Example1_GetImage");
  8.                 HDevProcedureCall call = new HDevProcedureCall(proc);

  9.                 HObject srcImage = (PE.Image as Bitmap).BitmapToHobject();

  10.                 string SomeText = "Hello, Denis!";

  11.                 call.SetInputIconicParamObject("SourceImage", srcImage);
  12.                 call.SetInputCtrlParamTuple("SomeText", new HTuple(SomeText));

  13.                 try
  14.                 {
  15.                     call.Execute();
  16.                     HTuple OutputImagePath = call.GetOutputCtrlParamTuple("OutputImagePath");
  17.                     HObject BackgroundImage = call.GetOutputIconicParamObject("BackgroundImage");

  18.                     dev.UnloadAllProcedures();
  19.                     call.Reset();

  20.                     dev.Dispose();
  21.                     proc.Dispose();
  22.                     call.Dispose();

  23.                     PE.Image = new Bitmap(OutputImagePath.S);
  24.                 }
  25.                 catch(HalconDotNet.HalconException ex)
  26.                 {
  27.                     Console.WriteLine(ex.Message);
  28.                 }

  29.             };
  30.         }
  31.     }
复制代码

Appears error: HALCON operator error  in procedure: 'Example1_GetImage' line: 7, dump_window_image:
Wrong type of control parameter 1
  1. get_image_size(SourceImage, Width, Height)
  2. dev_open_window(0, 0, Width, Height, 'black', WindowHandle)
  3. dev_set_window(WindowHandle)
  4. dev_display(SourceImage)
  5. disp_message (WindowHandle, SomeText, 'image', 12, 12, 'black', 'false')
  6. OutputImagePath:='OutputImage.png'
  7. dump_window_image(Image, WindowHandle)
  8. write_image(Image, 'png', 0, OutputImagePath)
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-24 19:42:15 | 显示全部楼层
My version: Halcon 18.11
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
Criss 发表于 2021-5-25 10:08:35 | 显示全部楼层
Evgeniy 发表于 2021-5-24 19:42
My version: Halcon 18.11

We usually realize all functions by calling the. hdvp function by calling the engine and passing in the window handle.
It is more convenient to use HDevProcedure call.
As an engine call,. hdev file should not be passed in directly, but you can start debugging and use HDevelop process debugging to see if your value is passed in.
It is a complete program similar to the parameterless method, but. hdvp can pass parameters. ‘

Attachment is the way I use it, and the test is basically no problem!

HalconEngine.rar (2.05 KB, 下载次数: 4)
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 13:39:00 | 显示全部楼层
Criss, thank you for answer!!!

Very interesting thing!!! So, you mean I can use HWindowControl descriptor as input parameter in *.hdvp file and after that I can use the HOperatorSet.DumpWindow for getting picture?

I need to check this idea!

I will wrote later about my results.
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 14:35:27 | 显示全部楼层
Criss, do you have any example with window descriptor?
Because I can't!
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 14:48:45 | 显示全部楼层
I just need to transfer a picture to a file. Write something on this picture and return it back.

The first attempt was unsuccessful.
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 15:13:22 | 显示全部楼层
Criss, is I am right? You not use *.hdvp file in your project? You just only make it with HDevEngine and HoperatorSet?
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 20:12:33 | 显示全部楼层
No Idea, how to solve this problem. Looks like dump_window is not working at all from C# project.
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
Criss 发表于 2021-5-26 20:15:51 | 显示全部楼层
Evgeniy 发表于 2021-5-26 15:13
Criss, is I am right? You not use *.hdvp file in your project? You just only make it with HDevEngine ...

Sure,It's My Halcon Engine's Demo,It's Works!
https://1drv.ms/u/s!AgtcKzAtnq7fiz5nuVQ9Z8lCsaQw?e=f7K7pP
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-5-26 22:47:33 | 显示全部楼层
Criss, thank you!

Very interesting example.

But my additional problem that is I am trying to make service application and there can not be any control and forms at all.

In your example you are using HWindowControl - and this is cool, but I need the solution without any controls. I try to make it without them, but your example very helpfull!!! Thank you!!!
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表