LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquisition of IP Camera video stream

Hi,

 

I need to acquire images from an IP camera at intervals that range from 1s to 4 hours and save them on the harddrive as JPEG files (so basically, i want to do a "snap"). The acquisition must be done via a CompactRIO.

 

My camera is - of course - not supported by ImaqDX and I can't use third party software that emultes ImaqDX compatible devices because these pieces of software run on Windows and I'm on a Real Time CompactRIO.

 

So I configured the camera to send an MJPEG video stream over TCP and simply sent http requests to the camera and parsed the response. 

 

As the HTTP functions of Labview did not work, I had to reprogram it using basic TCP functions.

 

My problem is that sometimes I get corrupted images i.e. the top of the images is made of one image and the bottom is obviously made of another image. This does not happen very often, but still that probably means there is something wrong with my code.

 

Do I need to, maybe flush the TCP port at some point? How do I do that? Do you see something in my code that could cause this problem?

 

The code is attached.

 

Thanks,

 

Regards,

 

peper

0 Kudos
Message 1 of 11
(8,437 Views)

based on your problem I'd be suspect of your start and stop byte checks in Save one image.vi.  It's possible that, if you see a start image, that package is saved, perhaps the stop byte is missed, and the beginning of the second message is recorded before you see the next stop byte?  I'd consider adding a double check in there or possibly put some error checking in your stop bytes if you have that control so that you know each byte start/stop corrisponds to the same message. I haven't looked at your code too long, but that's where my mind first went.  Good luck!

 

Tim

CLA

0 Kudos
Message 2 of 11
(8,411 Views)

Hello peper2001, may you downconvert your project to LV2011?

 

Thanks

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 11
(8,229 Views)

Never mind, I posted it in the Version Conversion forum

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 11
(8,210 Views)

Extracted the .zip, tried to run it, but misses IMAQ ReadFile and IMAQ Create.

 

Do I need some supplementary library to have this?

0 Kudos
Message 5 of 11
(8,136 Views)

Hi,

 

The code saves the TCP string to a file and then read it using IMAQ function to display the image on the frontpanel. IMAQ is part of NI Vision toolkit (https://www.ni.com/en-us/shop/product/vision-acquisition-software.html).

 

If you don't have access to the NI Vision toolkit, you can:

 

A) desactivate the IMAQ read function in the code and view the image, outside Labview, with Windows (check the "path out" indicator).

Or

B) replace the IMAQ read function and display indicator with controls and functions from the "pictures" palette:

 

picture functions.png

 

I think this should work (haven't tried it, though).

 

Regards,

 

peper2001

 

 

 

 

0 Kudos
Message 6 of 11
(8,129 Views)

Hello,

 

This works for both my Intellinet NFD-130IRV. I removed both (not-working uninstalled) IMAQ blocks, and put the blocks as you described.

 

Little problems I encountered, may be useful for others:

 

-In the front screen, you cannot browse to a folder path, manually adjust this for example C:\Users\Steven\Desktop\images

-If you use other port settings than the default 80, you have to adjust this in the "Open TCP connection.vi" block

 

When I will be using this, I will put the port setting at the same location where "IP adress" and "MJPG stream name" are located,

at "set connection parameters"

 

Thanks a lot.

0 Kudos
Message 7 of 11
(8,108 Views)

Hi,

 

I'm glad to hear that the code is working for you.

 

Best regards,

 

peper2001

0 Kudos
Message 8 of 11
(8,099 Views)

I changed %Ss to %S%2us in the image file name generation, to discover the maximum image rate.

Seems to be about 0.90 seconds per image.

 

 

0 Kudos
Message 9 of 11
(8,088 Views)

Maximum achievable frame rate depends on your specific camera (check the theroretical frame rate of your video stream in the camera settings).

 

Also, I think there are three major performance bottlenecks in the code:

 

1) The string buffer is not pre-allocated. This could be quite easily fixed.

 

2) AFAIK, Labview doesn't provide a vi that can directly convert a JPEG string to a picture. However, it does provide a VI that can read a JPEG file and convert it to a picture. As a workaround, I save the JPEG string to the harddrive and then read back the saved file. Of course, reading and writing to the harddrive is not as fast as a memory access. 

 

3) Each time an image is requested I open the TCP port, send the "GET" command, read one image and then close the TCP port. Actually, things could be done a bit differently: once the TCP port has been open and the GET command sent, the camera starts streaming JPEG images. Hence the TCP port could be left open (not need to resend the GET command) and the code should just detect start and stop markers.

 

I hope that helps,

 

Regards,

peper2001

0 Kudos
Message 10 of 11
(8,085 Views)