Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW and Halcon

0 Kudos
Message 41 of 70
(7,876 Views)

Thank you for your reply.

0 Kudos
Message 42 of 70
(7,861 Views)

Dear dadreamer:

Thank you for the demo of running HDVP file directly in LabVIEW. I have gained a lot.But I still don't understand, how to put the LabVIEW in the acquisition of images to HDVP file, I checked by ProcCall SetInputIconicParamObject ()

The image variable is passed into the HDVP file, but I don't know how to implement it. Could you help me? Thank you.

    

0 Kudos
Message 43 of 70
(7,796 Views)

Hi, cmbd!

You go in the right direction. I just checked it on this very simple procedure:

scale_image_range ( Image : ImageScaled : Min, Max : )

So, here we should pass one iconic input parameter and two control input parameters and receive one iconic output parameter.

This is how it works for me:

Download All
0 Kudos
Message 44 of 70
(7,780 Views)
Thank you very much for your reply. You are really wonderful. You have solved the problem that has bothered me for a long time. I believe this is also a problem for many engineers who want to call Halcon directly with LabVIEW. Thanks again, I will study your demo well.
0 Kudos
Message 45 of 70
(7,770 Views)

dear dadreamer! I also use labview to call halcon, first of all thank you for your image conversion algorithm, I used it in my project. But at present I have a big trouble. After labview calls halcon, the memory usage in my application gradually increases, but it will not increase after reaching 1GB. Why is this?

 

thankyou!

0 Kudos
Message 46 of 70
(7,555 Views)

Hi, ljq!

Right now I don't have a clear answer for you, but here are some questions to figure out the reasons behind your problem.

1. Are you freeing all the memory allocated for HALCON objects with Dispose invoke node (if available) and with Close Reference onwards?

2. Are you working with very large images (with resolution of 32k x 32k pixels)? If yes, then you should use halcondotnetxl.dll instead of halcondotnet.dll.

Then it would be good to show us your sample code, where you can stably reproduce the issue you've described. Is my basic example from this thread working fine for you or does it introduce the memory leak as well?

0 Kudos
Message 47 of 70
(7,542 Views)

Hello dadreamer, first thank you very much for that VI you provided, it helped me a lot to understand how the Labview-Halcon interaction works.

In my case i want to display multiple 3D object models in the same window in Labview using the procedure "visualize_object_model_3d", just like in your VI.

The thing is, even when leaving the VI unchanged, i get the following error after the execution of the HDevProcedureCall :

 

Error visu 3d.PNG

 

That probably means the Halcon procedure do not recognize the sent WindowID, which is odd because i didn't bring any modification to that part of the program. I highly suppose it is a matter of Halcon/Labview/.NET version but I can be wrong and could use some help here. I am running LV2018 64-bits and Halcon 18.11.1.1 64-bits on a Windows 7 64-bits.

 

I know that topic is quite old but this is the only one i found being relevant for my problem.

Thanks again.

Regards.

0 Kudos
Message 48 of 70
(7,241 Views)

Hi, Boris_M!


@Boris_M wrote:

 

I highly suppose it is a matter of Halcon/Labview/.NET version but I can be wrong and could use some help here.


You are right, it's a HALCON version issue. I'm facing exactly the same error message on HALCON 20.05 Progress (64-bit) and LabVIEW 2020. But I have just installed HALCON 13.0 (64-bit) in parallel and everything is working fine with this version.

2021-01-16_19-14-00.jpg

 

To my big regret I'm unable to come with a quick fix for this problem. Seems like something was changed (broken?) in HALCON internals as it even doesn't have any relations to visualize_object_model_3d.hdpl code. Maybe HWindow handle is interpreted differently or it's just some sort of a bug. Interestingly HDevelop runs the mentioned procedure just fine - no errors for a code like this:

 

read_image(Image, 'Sample.png')
get_image_size(Image, Width, Height)
GV := []
R := []
C := []
for rows := 0 to Height-1 by 1
   for cols := 0 to Width-1 by 1
    get_grayval(Image, rows, cols, GVt)
    if (GVt>0)
    tuple_insert(GV, |GV|, GVt, GV)
    tuple_insert(R, |R|, rows, R)
    tuple_insert(C, |C|, cols, C)    
    endif
  endfor    
endfor

gen_object_model_3d_from_points (C, R, GV, ObjectModel3D)
dev_get_window (WindowHandle)
visualize_object_model_3d (WindowHandle, [ObjectModel3D], \
                           [], [], ['lut','color_attrib'], ['linear','coord_z'], [], [], [], PoseOut)
clear_object_model_3d(ObjectModel3D)

 

I suppose, to get this issue solved you need to contact MVTec support or your local representative, so they would be able to test/check everything.

0 Kudos
Message 49 of 70
(7,222 Views)

Okay, I think I have sorted the things out. New versions of HALCON don't want HWindow Handle on input, but want HWindow object itself instead. This refers to both first (WindowHandle) and second (ObjectModel3D) parameters of visualize_object_model_3d procedure. Pretty obvious now, but it required me to rewrite one of C# examples to make sure.

 

Anyway here's the fixed SubVI and some basic example, which works fine on my side. Have fun. 😼

0 Kudos
Message 50 of 70
(7,193 Views)