Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Setting 1394 Camera Attributes Using Visual Studio .NET 2003/2005

Primary Software: Driver Software>>NI-IMAQ for IEEE-1394
Primary Software Version: 2.1
Primary Software Fixed Version: N/A
Secondary Software: Measurement Studio>>Visual C++ Support
Hardware: Image Acquisition (IMAQ)

Problem: How do I programmatically set 1394 camera attributes using Visual Studio .NET 2003/2005?

Solution:

1394 cameras can set attribute values in a couple of different ways in what are known as attribute modes.  You can select from a list of supported modes, including Absolute, Auto, Off, One Push, Relative, and Ignore. To find out which modes are supported by your camera you can consult the camera's user manual or go to Measurement and Automation Explorer » NI-IMAQ Devices » [IMAQ device] » [camera] and click on the tab "Camera Attributes".  Here you will be able to click on each attribute and see which modes are available to use.  You can also programmatically determine the available modes for a certain attribute by using the imaq1394AttributeInquiry2 function.

Visual C++ Example:

/* first, switch over from relative mode to absolute mode */
imaq1394SetAttribute(Sid, IMAG1394_ATTR_SHUTTER, IMG1394_ABSOLUTEMODE);

/* next, set the absolute value */
double shutterTime = 0.02;
imaq1394SetAttribute(Sid, IMG1394_ATTR_ABSOLUTE_SHUTTER, (unsigned long)&shutterTime);


The key is that you must first switch over to the mode you are using and then each mode sets
the attribute differently. Below is the excerpt from the NI-IMAQ for IEEE 1394 Function
Reference describing this function:


imaq1394SetAttribute

Format:
rval = imaq1394SetAttribute (SESSION_ID sessionId, unsigned long attribute, unsigned long value);

Purpose
Sets an attribute for a camera.

Parameter Type
Description
sessionId SESSION_ID A valid Session ID, which you can obtain
using imaq1394CameraOpen2.attribute
attribute unsigned long The attribute whose value you want to set. Refer to Attributes for a list of attributes.value
value unsigned long (passed by value) or double (passed by reference) The value of the specified attribute. Use imaq1394AttributeInquiry2 to enumerate the special modes that the camera supports.



















Parameter Discussion:
Attribute specifies the attribute whose value you want to set. In LabWindows/CVI, when you click the control a dialog box opens containing a hierarchical list of the available attributes. Attributes whose values cannot be obtained are dimmed. Help text is shown for each attribute. Select an attribute by double-clicking it or by selecting it and then pressing Enter.

If the attribute shown in this ring control has named constants as valid values, you can bring
up a list of them by moving to the Attribute Value control and pressing . If there is a
value shown in the bottom half of the Attribute Value control, the corresponding constant is
marked in the displayed list.
If the specified attribute is a camera attribute, the user may set one of the following values:
• IMG1394_AUTOMODE: Allows the camera to always control the selected camera attribute.
• IMG1394_ONEPUSHMODE: Allows the camera to control the selected camera attribute once,
and then return to the manual control state with adjusted values.
• IMG1394_OFFMODE: Disables the selected camera attribute.
• IMG1394_ABSOLUTEMODE: Sets the selected camera attribute to use 32-bit floating-point
numbers that map to real-world units. In this mode, the driver refers to the absolute camera
attribute for the control value.
• IMG1394_IGNOREMODE: Prevents the driver from writing the selected camera attribute to
the camera.

Return Value:
On success, this function returns IMG1394_ERR_GOOD. On failure, this function returns an error
code. You can obtain a more detailed error message with imaq1394ShowError or, if you are using
Microsoft Visual Basic, imaq1394ShowErrorCW.

The key to setting attributes using a text based language is to know that you have to call the imaq1394SetAttribute function twice. Once to put the attribute in the right mode and then again to set the value. The value is then either an unsigned long passed by value for relative mode or a double passed by reference for absolute mode.


Related Links: Product Manuals: NI-IMAQ for IEEE 1394 Cameras User Manual
Developer Zone Tutorial: Acquiring from Firewire Cameras using National Instruments NI-IMAQ for IEEE 1394

Attachments:





Report Date: 11/16/2006
Last Updated: 12/20/2006
Document ID: 43FILNP6

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit