03-12-2018 12:29 PM
Hello,
In the attached VI I am trying to obtain a single image from a Thorlabs camera and save it to a file.
The image is displaying correctly in the picturebox, but my Save method for the Image class isn't working - it gives me the usual 1172 error.
Please can someone point me to what might be the problem?
Thanks,
Graham
03-12-2018 02:58 PM
Do you intend on overwriting the same image over and over again? I wonder if part of the issue is file permission where it doesn't allow for overwriting the image.png until the references are closed. In that case I would expect it to work once and not again. Is that what you are seeing?
I remember doing something like that in the past and having it work as expected. Still an alternative that I know works would be to save the image to a stream, get the buffer, and then write that buffer to a file using the Write Binary File.
Check out my code posted here. In it is a Get Image Data From PictureBox which takes a picturebox, then saves the image to a PNG stream, and then gets the buffer back and using a vi.lib function turns that into LabVIEW image data. I'd suggest changing the VI to have file path in, and a write binary file function to write that buffer to disk. I'd still suggest creating a new file name each iteration of the loop instead of overwriting the same file.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-02-2018 07:42 PM
Hello Graham.
I am also looking for a way to save the content of a .NET picturebox.
The image is created by a vision library (Halcon) which I am just starting to learn about so I would like to be able to save the images directly from the picture box.
Would it be possible for you to convert your example to LV2014, please?
Thanks.
08-03-2018 08:00 AM
Back saved to 2014 but I don't have 2014 to test with so you'll have to tell me if it relinked properly.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-06-2018 05:40 PM
Thank you very much Hooovahh.
It worked perfectly but, unfortunately, the image-save process in these VIs cannot be used in my project.
In my case, I have an ActiveX Pictuer box that gets drawn by some Halcon (vision verification) routines.
While trying to get the resulting image with a Get Image only a black picture is retrieved.
Will write a new post asking for support on this.
Again, thank you very much.
08-15-2018 08:15 AM
@guillermoe wrote:
I am also looking for a way to save the content of a .NET picturebox.
@guillermoe wrote:
In my case, I have an ActiveX Pictuer box that gets drawn by some Halcon (vision verification) routines.
It's not exactly clear, which container you are using to display the images: Halcon .NET HWindowControl, Halcon ActiveX HWindowXCtrl or some native Windows .NET/ActiveX object. Believing that Halcon based container is being used, I could say that there are several methods to export the images into the files.
1. If you want to save the contents of the panel display indicator (HWindowControl or HWindowXCtrl), you may use dump_window function on the indicator refnum.
2. If you want to save from the HImage object, which you're dealing with, you may use write_image function on the image refnum.
08-16-2018 03:45 PM
Hello dadreamer.
Yes, thats exactly what I was told to do about this.
Problem is I just started learning about Halcon as a colleague had to move out of the city and there was a request to save the images from the resulting tests into a file.
As my knowledge on Halcon is almost null, thought it could be possible to just use a normal GetImage from an Active X object but it didnt work.
My colleague had to come to the city this weekend and showed me what you say: the Dump Window function to save the image data of the HWindow object.
Thank you very much.
08-17-2018 12:09 AM
Glad that you figured this out. For the future references - you may always launch HDevelop, open Help and type some keywords in the search, e.g. "save image to file", so it would show you the related functions/operators, that could do that.
By the way, Halcon support states that anyone should use .NET instead of ActiveX, as the latter becomes out-of-support for some reasons (fading tech, maybe). And for my own thinking, .NET is much more stable and easier to maintain, than ActiveX/COM.