You are on page 1of 6

3.4 LabVIEW and Video streaming.......................................................................... 1 3.4.1 WebCams.................................................................................................... 1 3.4.2 NI-IMAQ for USB Cameras....................................................................... 2 3.4.

3 Example of image acquisition..................................................................... 6 References....................................................................................................................... 6

3.4 LabVIEW and Video streaming


3.4.1 WebCams
The LabVIEW programming environment by National Instruments has an excellent addon package that is capable of performing a number of powerful image analysis and recognition operations. Even the core LabVIEW products contain capabilities for displaying, loading, and saving images in a variety of formats. Unfortunately, at a moment of time, LabVIEW only inherently supports expensive hardware based capture devices, leaving image capturing and processing out of the hands of low-budget users. The LabVIEW webcam library, developed in 2002 by Peter Parente [1], allows a LabVIEW program to capture images from any inexpensive imaging device, such as the excellent yet inexpensive Lego webcam. This functionality opens up a number of possibilities for the augmentation of collected data by images. For example, webcam images can be embedded in front panels for monitoring remote hardware or even for remote experimentation. As another example, webcam images can be processed for information that can then act as a trigger for other data collection operations. The driver LabVIEW WebCam 1.40 has been tested to work with Windows 98, Me, 2000, and XP (Figure. 3.4-1). On average, the driver is capable of returning images to LabVIEW at 7 FPS. Now we can find an updated version LabVIEW WebCam 1.41 [1].

Figure. 3.4-1 Using LabVIEW WebCam 1.40 to aquire image

Philipp Spitzer has contributed an updated version of the LabVIEW webcam library that remedies some crash bugs (version 1.4.1 of the LabVIEW webcam library). This newer version requires LabVIEW 8 or higher.

3.4.2 NI-IMAQ for USB Cameras


NI-IMAQ for USB Cameras is a free software driver for acquiring images from any DirectShow imaging device into LabVIEW. These devices include USB cameras, webcams, microscopes, scanners, and many consumer-grade imaging products. With the driver, users can configure their device, and acquire images into LabVIEW. When combined with the NI Vision Development Module (which is included in the LabVIEW Student Addition) students, professors, and academic professionals can analyze images with hundreds of functions for image processing, including filters, binary morphology, pattern matching, and color inspection. The NI Vision Development Module also includes the Vision Assistant for prototyping different functions, benchmarking inspections, and automatically generating code. With NI-IMAQ for USB Cameras, you can: Acquire images from any USB imaging device with DirectShow support Choose between one-shot or continuous image acquisition Configure cameras programmatically (now includes the ability to programmatically select video modes without a popup dialog) Acquire directly into Vision Assistant for easy application prototyping Please note that while NI-IMAQ for USB Cameras comes with complete documentation. This example program was developed and tested by a National Instruments Applications Engineer for technical support purposes. This code is supported by National Instruments, but may not be completely tested and verified with each new revision of related products and drivers. System Requirements include: Windows 2000/XP (English, Italian, Japanese, French, Italian, Norwegian, Dutch, Spanish/Portuguese, Russian, and simple Chinese) LabVIEW 7.0 or higher with NI Vision 7.1 or higher for the USB LabVIEW support. Vision Assistant 7.1 or higher for the USB Vision Assistant plugin module. The NI-IMAQ for USB Cameras Virtual Instrument (VI) Library is a series of LabVIEW VIs for using LabVIEW with your USB camera and is included with the NI-IMAQ for USB Cameras software. IMAQ Vision for LabVIEW is an image processing and analysis library consisting of more than 400 VIs. IMAQ Vision for LabVIEW is required to use the NI-IMAQ for USB Cameras VI library. The following sections describe the basic concepts and information necessary to build an application with NI-IMAQ for USB Cameras. Figure. 3.4-2 shows a block diagram of the NI-IMAQ for USB Cameras architecture.

Figure. 3.4-2 NI-IMAQ for USB Architecture

The NI-IMAQ for USB Cameras examples illustrate some common applications. You can find these examples in the <LabVIEW>\examples\imaq directory (imagUSB examples.llb). For a brief text description of an example, open the example VI and select WindowsShow VI Info.

Figure. 3.4-3 NI-IMAQ USB cameras VIs

From the selected location we can to open the imagUSB examples.llb library and from this library we select one of the applications. For example we can to select and open Grab.vi (see the Figure. 3.4-3).

Figure. 3.4-4 Panel and Digram of the Grab.vi example

When you runn this examples if the application find a camere will work with this camera if not will display one error message. The example from the Figure. 3.4-4 will perform a continuous acquisition from the present USB camera. We can use this examples to build our new aplications and to implement a web cam transmision from our remote application and/or laboratory. NI-IMAQ for USB Cameras [3] provides an add-on module for Vision Assistant 7.1 and greater. This module allows you to acquire images from USB cameras and process these images with Vision Assistant. To access the NI-IMAQ for USB Cameras Vision Assistant Module, select the Acquire Image option after launching Vision Assistant, or select the Acquire Image icon on the Vision Assistant menu bar. Either method opens the NI-IMAQ for USB Cameras Image Acquisition window in Vision Assistant. The NI-IMAQ for USB Cameras Vision Assistant Image Acquisition window allows you to select a camera from a list of USB cameras recognized by the system, set properties of the camera, and acquire images. Figure 3.4-5 shows the NI-IMAQ for USB Cameras Image Acquisition window.

Figure. 3.4-5 NI-IMAQ for USB Cameras Acquisition Page in Vision Assistent

The following options are available in the NI-IMAQ for USB Cameras Image Acquisition window. Refer to Figure 3.4-5 for the location of each option within the window. SnapAcquires a single image from the selected camera. GrabAcquires a continuous image from the selected camera. SequenceAcquires a user specified number of images. Sequence acquisitions are useful for capturing events that change quickly. Copy to BrowserCopies the current image in the display to the Vision Assistant Image Browser for processing. Multiple images can be sent to the browser and then processed later using Vision Assistant. List of CamerasLists the available USB cameras. Camera Video SettingsOpens a dialog box with the video settings the camera supports.

Camera Image SettingsOpens a dialog box with the image settings the camera supports.

Two types of image acquisitions are available in LabVIEWsnap and grab. The following sections describe and give examples for each acquisition type. NI-IMAQ for USB Cameras does not support simultaneous acquisitions from more than one camera. Note The NI Vision Assistant USB Acquisition Module always acquires images when an image acquisition step is open. Make sure to close the step before acquiring an image in LabVIEW. Refer to the NI-IMAQ for USB Cameras and NI Vision Assistant section of this guide for more information. SNAP A snap acquires a single image into a memory buffer. Use this acquisition mode to acquire a single frame to a buffer. When you invoke a snap, it initializes the device and acquires the next incoming video frame to a buffer. Use a snap for low-speed or singlecapture applications. Use IMAQ USB Snap to perform a snap acquisition in LabVIEW (Figure 3.4-6 (a)).

(a) SNAP

(b) GRAB
Figure. 3.4-6 Snap (a) and Grab (b) acquisition in LabVIEW

GRAB A grab is a continuous, high-speed acquisition of data to a single buffer in host memory. This function performs an acquisition that loops continually on one buffer. You can get a copy of the acquisition buffer by grabbing a copy to a LabVIEW image buffer. You must use two VIsIMAQ USB Grab Setup and IMAQ USB Grab Acquirefor a grab acquisition in LabVIEW. Call IMAQ USB Grab Setup once to initialize the acquisition and start capturing the image to an internal software buffer. You can call IMAQ USB Grab Acquire multiple times to copy the image currently stored in the internal buffer to a LabVIEW image buffer. After the program finishes copying images, call IMAQ USB Close once to shut down the acquisition. Figure 3.4-6 (b) shows a simplified block diagram for using IMAQ USB Grab Setup and IMAQ USB Grab Acquire.

3.4.3 Example of image acquisition

References
1. Peter Parente Web: http://www.cs.unc.edu/~parente/index.shtml 2. National Instruments Web: www.ni.com 3. User Guide NI-IMAQ for USB Cameras

You might also like