Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save 8 bit images from a TCP connection with a Smart Camera

Solved!
Go to solution

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?

 

Save AVI.pngAny help,  of comment will help a lot. Thanks.

Impossible is nothing
0 Kudos
Message 1 of 18
(6,116 Views)

Hello Cris,

 

Instead of creating an AVI file and adding each frame to it, just write an image file.

 

see this :

 

Local_BD.png

 

 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

Antoine Chalons

0 Kudos
Message 2 of 18
(6,101 Views)

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

Bruce Ammons
Ammons Engineering
Message 3 of 18
(6,094 Views)

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:

 

error writing not supported.PNG

 

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:

not an image.PNG

 

 

 

That's why I used this couple of VIs in my project:

 

project.PNG

 

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.

Impossible is nothing
0 Kudos
Message 4 of 18
(6,084 Views)

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?

 

 smartcamera VI.PNG

 

 

I've tried this before watch your comments and I got these results:

 

I modified the Local.vi (PC) like this:

using string.PNG

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):

 

 

 

2.PNG

 

 

 

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:

 

 

 

3.PNG

 

 

 

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.

 

 

Impossible is nothing
0 Kudos
Message 5 of 18
(6,088 Views)

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:

IMAQ Write String.PNG

 

 

 

 

 

When I run both VIs (Remote.vi and Local.vi), I get these errors

 

 

 

Error with Write String.PNG

 

 

 

 

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

Message Edited by bebin on 06-10-2010 06:45 PM
Impossible is nothing
0 Kudos
Message 6 of 18
(6,062 Views)

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

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 18
(6,057 Views)

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:

 

Local vi PC.PNG

 

 

 

and here is an image of how the images are being saved:

 

not saving correctly.PNG

 

 

 Thanks for all your help and comments.

 

Bebin

Impossible is nothing
0 Kudos
Message 8 of 18
(6,022 Views)

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

Impossible is nothing
0 Kudos
Message 9 of 18
(6,017 Views)

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

Bruce Ammons
Ammons Engineering
Message 10 of 18
(5,991 Views)