06-08-2010
01:44 PM
- last edited on
03-31-2025
01:23 PM
by
Content Cleaner
Hello my name is Cris and I am trying to save 8 bit images generated from a Smart Camera NI 1742 that has a frame rate up to 60 fps. I want to stream images the time I need and save each image. I currently have implemented the next VI which I found in this article: Streaming Images from a Compact Vision System to a local AVI One of my objetives was this, can save an AVI file and now I can do it. According this article the VIs flattens the images to string data, and sends the data to the local machine (PC) through TCP/IP communication (because the data cannot be stored inside the Smart Camera). Then, the Local.vi (showed in figure), on the local Windows machine, receives the string data, unflattens it back to images, and saves the images to an AVI file. So, my question is how can I proceed for receives the string data and save it directly to individual files with names like 0001.jpg, 0002.jpg, etc, automatically instead of using Write frame to AVI?. I'm thinking to use the IMAQ Write String wich returns a string that contains the entire contents of the image encoded as an image file and the string can be saved to file (without unflatten it). How can I modify the Local.vi?
Any help, of comment will help a lot. Thanks.
Solved! Go to Solution.
06-09-2010 07:15 AM
Hello Cris,
Instead of creating an AVI file and adding each frame to it, just write an image file.
see this :
I'm not sure you will be able to save the 60fps though...
If your acquisition doesn't last too long maybe you can use the FTP save image function from VBA, to do that you will need an ftp server of course (you can use filezilla).
Hope this helps
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
06-09-2010 09:06 AM
On the smart camera, use IMAQ Write String to create a string that is equivalent to a JPEG file. Send the string back to the PC using TCP. Just write the string to a file as binary data using the standard File IO vi, with no header. This will be much better than unflattening and recompressing the image. You still won't be able to write 60 files per second, though. The amount of time it takes to open and close each file is significant. I would recommend writing all the strings to a single file. You can keep adding to the file as long as you want, then come back later and break the file into the individual images.
Bruce
06-09-2010 03:25 PM
Hi, thanks for your comments. I've tried to use your VI's design but I get an error as you can see in the next image:
I had this same error when I tried to save images inside the Smart Camera, it is not supported. When I click on CONTINUE, this appears:
That's why I used this couple of VIs in my project:
It is supposed my PC is my server and the Smart Camera my remote device. I don't think necessary to use an FTP server, is this faster or why your suggestion?
Thanks for your answer.
06-09-2010 04:04 PM
Hi, thanks for your comments. Here is the VI which runs inside the Smart Camera, as I can see the image is compressed and flatten to string, so,
1.- do you suggest allocate right there the IMAQ Write String? and
2.- how is that about writing all the strings to a single file? Could I recover the individual images for further analysis using Machine Vision and Image Processing VIs?
I've tried this before watch your comments and I got these results:
I modified the Local.vi (PC) like this:
and there appears a windows asking me about the location of the image, it changes automatically the name of the next image (maybe I should allocate the FILE DIALOG VI outside the For Loop):
The images are "saved" on the folder I choose, but when I stop running VIs, any images are not availables I don't know why:
That's the idea of what I want to do, even so I want to prove your suggestion Mr. Ammons. Even so, I'd like to know your answer at my questions 1 and 2 and your opinion about these last images.
I will attach the files which I use.
06-10-2010 06:43 PM - edited 06-10-2010 06:45 PM
Hi again, I've changed the Remote.vi (which runs in Smart Camera) adding the IMAQ Write String instead of compressing the images, as you can see in the next image:
When I run both VIs (Remote.vi and Local.vi), I get these errors
I think it is due to the order of the data converted to string in the IMAQ Write String or something like that. Should I send both the string size and string data? are both absolutly necesary?
Thanks for your help and comments
Bebin
06-10-2010 08:11 PM
You need string size so you know how many bytes to read for string. The camera side looks good to me.
On the PC side, you don't need to unflatten the string. If you try, you will get an error. Just save the string directly to a file.
Bruce
06-14-2010 02:26 PM
Ok, thanks for your comments.
I've changed the Local.vi (PC) to not unflatten the string. I've tried to save directly to a file and the images are being saved, but I cannot open them, I get a Preview not available. Am I making a mistake with the File Dialog.vi? I'm writing in pattern all files *.jpeg, should not write this? Where can be the problem?
Here is the PC vi:
and here is an image of how the images are being saved:
Thanks for all your help and comments.
Bebin
06-14-2010 03:28 PM
Do you believe its easier to save all the strings in one file and then go back later and obtain the images individually? How can this be done? is there any example in LabView? (I'm using LabView 2009).
Thanks for all the suggestions
Bebin
06-15-2010 10:11 AM
On Write to binary file, set the Header boolean input to false. You don't want to write the header info, just the string.
Bruce