Streaming IMAQ Images over a Network (Or Internet)

Updated Sep 6, 2023

Reported In

Software

  • LabVIEW
  • LabWindows/CVI
  • Measurement Studio
  • Vision Development Module

Driver

  • NI-IMAQ
  • NI-IMAQdx

Issue Details

I want to stream images I acquire continuously with my IMAQ or IMAQdx device over a network. What are my options for transmitting IMAQ images over a network or the internet?

Solution

You can take advantage of the networking capabilities that LabVIEW, LabWindows™/CVI™, and Measurement Studio offer with IMAQ hardware and software. There are several ways for you to stream video from one networked computer to another.
 
  • TCP/IP
  • DataSocket
  • LabVIEW Web Server
  • LabVIEW Web Services
  • Creating an ActiveX Control for the Web
  • Network Streams
  • Network Shared Variables
 
TCP/IP
TCP/IP is a great way to transfer images over the network. TCP/IP offers reliable, guaranteed, and ordered delivery of data over a network. Unlike DataSocket, TCP/IP has less overhead for each packet, which results in faster transfer rate. Both the sender and receiver are required to be actively listening on the same port for the application to work. You can implement your program such that you have multiple clients on the same port, however you will need to manage each session programmatically yourself. 

Streaming Images from a Compact Vision System to a Local AVI demonstrates how to stream images from a CVS to a Windows machine using TCP communication and save the images to an AVI.

DataSocket 
DataSocket is a programming tool that enables you to read, write and share data between applications and/or different data sources/targets. DataSocket can access data in local files, HTTP, and FTP servers. DataSocket is easy to use and all of the client/server sessions are handled automatically by the DataSocket server. The DataSocket server also has security features implemented to ensure that only clients you want can log on. DataSocket does NOT guarantee proper delivery, so you can miss frames. 


LabVIEW Web Server 
You can take advantage of the Web Publishing capabilities in LabVIEW to publish images on a front panel VI to the web via the LabVIEW Web Server. This is easy to do and takes no additional programming. However, the display will be non-deterministic and most likely it will have a "flashing" update. Since the entire front panel is published as an image of the HTML page, the entire image will update each time. This may take a long time, and unnecessary updates of other front panel objects will be done. Refer to Creating HTML Documents and Embedding VI Front Panel Images in the LabVIEW Help for more information.

LabVIEW Web Services 
LabVIEW Web Services allows you to remotely monitor a LabVIEW application using a custom web-based client.  A simple example of this would be a VI that acquires images and publishes them to the web.  The advantage of this over the traditional LabVIEW Web Server is that it's possible to publish only the acquired image, instead of an image of the entire front panel. However, unlike with the Web Server, some programming is required for implementation.

Refer to Auto Refresh for LabVIEW Web Service Using LabVIEW for more information.

Creating an ActiveX Control for the Web
Both DataSocket and IMAQ functionalities can be used through a web using an ActiveX control. To develop the DataSocket web page, you must create a DataSocket reader component with which users connect to the server, automatically read and display the IMAQ image and disconnect from the server. You can create component with ActiveX controls and Visual Basic code to manipulate those controls and save this component as an ActiveX control. After making the ActiveX control, you can insert it into a web page.

Refer to Measurement Studio Help for more information.

Network Streams
Network Streams allow easily configurable lossless communication of data over a network. They require both a reader and writer endpoint of which there must be a 1 to 1 match, but provide an easy way to create lossless TCP/IP communication.


Network Shared Variables
Network Shared Variables provide a quick and easy way to configure network communication between NI applications. They are configured at edit time, and can be used to transfer a variety of data types. Network Shared Variables can be configured with buffers to allow lossless data transfer, or as lossy transfer mechanisms to ensure up-to-date data. One advantage of Network Shared Variables is that they can have both multiple readers and multiple writers.

Refer to Using the LabVIEW Shared Variable for more information.
 

Additional Information

Each method has its own advantages and disadvantages, and which one you choose will depend on your application needs.
 
MethodProsCons
TCP/IPFastestNot Web-Based
Single Client
DataSocketEasy to Use
Multiple Client
Security features
Not as Fast
Not Web-Based
LabVIEW Web ServerEasy to Use
Web-Based
Multiple Clients
Slowest
"Flashing" Image Updates
LabVIEW Web ServiceWeb-Based
Multiple clients
Customizable Interface
Slower
Harder to Implement than Web Server
Customized ActiveX Control in Web PageWeb-Based
Multiple Clients
More work to implement
Network StreamLossless
Advantages of TCP/IP Without Complexity
Single Client
Network Shared VariableEasiest to Implement
Multiple Clients
Can be Lossy
Slower

Table 1. Pros and Cons of Network Protocols