LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save image from picturebox

smercurio,

Sorry,  I got it wrong what you wanted.

 

Here is the VI: Webcam.vi.zip

 

The VI show the image acquired from a USB Webcam and show it in the Front Panel using PictureBox. and I want to save a picture.

 

Thanks.

0 Kudos
Message 11 of 34
(3,655 Views)
Since you are using the avicap32 DLL (which seems to be the Windows built-in support for webcams), then I believe the only way to do this is to use the WM_CAP_FILE_SAVEAS message to save the file. I don't have a webcam, so I can't verify that, but from what I've seen on the net this is how it was done, even when a .NET PictureBox was being used to display the image.
0 Kudos
Message 12 of 34
(3,643 Views)

smercurio_fc, I tried to do what you suggested, but the return of the VM_CAP_FILE_SAVEAS is False (0) that means ERROR!

And the command don't save any file.

 

Can somebody see if there is any mistake in this VI?

 

Mike, I'm trying to understand your advise. I'm trying to make a VI with your advise. If you have any other advise to make it easier, its helpful!

 

Thanks a lot!

0 Kudos
Message 13 of 34
(3,622 Views)

There's nothing explicitly wrong with the VI as far as I could tell. The thing you have to keep in mind is that the WM_CAP_FILE_SAVEAS message saves a video, not an image. The method of using the WM_CAP_EDIT_COPY message seems to be the only way to do it since the avicap32 API is not explicitly updating the Image property of the control. It makes sense that it wouldn't since that DLL is not .NET aware. It's probably writing directly to the window. Not sure if the following will work, but it's worth a try:

 

 

 

Off-hand, doesn't the webcam you have come with any software?

Message Edited by smercurio_fc on 03-17-2009 09:27 AM
0 Kudos
Message 14 of 34
(3,611 Views)

smercurio_fc, could you post your VI. I'm having trouble trying to do it.

 

And I don't have any driver or software from the Webcam.

 

Thanks for help!

0 Kudos
Message 15 of 34
(3,588 Views)
Here you go. You had not uploaded the control typedef so I had to disconnect the front panel control from the typedef, and I created the block diagram constant from this static instance. You should probably replace the constant with your typedef.
0 Kudos
Message 16 of 34
(3,574 Views)

smercurio_fc, in the output of the GetDataObject() I visualized with probe and I got the folowing message:

 

"Not A Refnum
Refnum (in hex): 0x00000000"

 

Anybody knows this error?

It seems that the WM_CAP_EDIT_COPY is not working, but the return of the function is TRUE (that means that its working).

It's really hard to work

 

Thanks for  helping so much!

0 Kudos
Message 17 of 34
(3,561 Views)

I'm not an expert on this specific issue, but based on what I've read and past experience with some .NET functions I think the problem has to do with making sure that all of the calls are running in the same thread. The CLFN functions are setup to run in the UI thread. Thus, I believe that you have to explicitly configure the VI to run in the user thread. To do this select File->VI Properties. Then select "Execution" from the dropdown. Set the "Preferred Execution System" to "user interface".

 

Unfortunately, I have no web cam so there's no way for me to test this on my own, so the best that I can do is to provide suggestions. If the above doesn't work we'll have to find another solution. 

0 Kudos
Message 18 of 34
(3,537 Views)

I'm having some similar problems with the .NET picturebox in LabVIEW 8.6.1.  I can get it to display an image, but I cant seem to save that image to a file no matter what method I try.  

 

I've searched quite a bit and it seems that everyone typically uses either the PictureBox.Image.Save(String filename, ImageFormat format) or the PictureBox.Image.Save(String filename) methods.  I get the same error either way.  Good old 1172:

 

******** 

Error 1172 occurred at Error calling method System.Drawing.Image.Save of ObjectId handle: 0xA7E1520 for obj 0x3C2413D[System.Drawing.Bitmap] in domain [LabVIEW Domain for Run] and thread 4704, (System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

) in DMSDK test.vi

 

Possible reason(s):

 

LabVIEW:  A .NET exception occurred. 

 

******** 

 

Has anyone used these methods successfully?  I attached my vi if anyone feels like checking it out.  Maybe there's something obvious that I'm missing...

 

 

0 Kudos
Message 19 of 34
(3,295 Views)

I don't get any error when I use the Save method. See attached example.

 

Note: When creating paths you should not use string functions. Use the Build Path function in the File I/O palette. 

0 Kudos
Message 20 of 34
(3,280 Views)