Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Change camera attributes in Visual Basic

Hi,
I'm using this simple code to set the shutter Attribute of my FireWire camera (Avt Guppy B/W):

Dim Value as string =  "CameraAttributes::Shutter::Value"

CWIMAQdx.OpenCamera("cam0", CWIMAQdx.CameraControlMode.Controller, Session)
CWIMAQdx.IsAttributeWritable(Session, Value, rw)
CWIMAQdx.SetAttribute(Session, Value, CWIMAQdx.ValueType.F64, 120)
CWIMAQdx.CloseCamera(Session)

But it has no effect infact, debugging, I can see that the property is writable, but the setAttribute function returns error "1074360319 (Internal error)". Reading the same attribute give me no error and always the old value (the one I've set in MAX).
All this settings (shutter, gain, etc...) work well in MAX.

Any suggestion?
Thanks


Message Edited by simonerom on 03-20-2007 11:26 AM

--
Simone
0 Kudos
Message 1 of 13
(5,291 Views)
 

Hi Simonerom,

There is was known issue in IMAQdx 3.0 regarding SetAttribute under the VB and .NET interfaces. This issue has been fixed in IMAQdx 3.01 (included with Vision Acquisition 8.2.2). This version is a free upgrade if you are currently using 3.0. There are other fixes, improvements, and new features as well, so I would highly suggest upgrading. You can download Vision Acquisition 8.2.1 here: http://digital.ni.com/softlib.nsf/websearch/92E5F0214C4B3A04862572950061384B 

Thanks,

-Eric G

0 Kudos
Message 2 of 13
(5,271 Views)
Thank you for the tip, with the update driver I can set attributes but, when I close the current camera session the setting are lost!

How can I stor the Attribute in the camera?
--
Simone
0 Kudos
Message 3 of 13
(5,265 Views)
I found a solution using the CWIMAQDdx.Read/writeAttributes function (not documented in the reference help)

It works well (but not if the camera is configured as "continuos" acquisition).
--
Simone
0 Kudos
Message 4 of 13
(5,264 Views)

Hi ,

I've got the same problem with ImaqDXSetAttributeCW , also with ImaqDxGetAttributeIncrement , i'm going to download the latest ImaqDX version to fix this trouble .

Maybe I will have problem with Max 4.2 ?

Bye

 

0 Kudos
Message 5 of 13
(5,243 Views)

Hi, upgrading to the last version of vision acquisition software (8.2.2) you get the setAttribute function work but,  only in the current session  of OpenCamera. In the end, I wrote  the code for storing all attribute of interest for me to disk and to reload them every time I opne the camera.
--
Simone
0 Kudos
Message 6 of 13
(5,242 Views)
Maury,
 
Your problem with ImaqDXSetAttributeCW should be fixed with Vision Acquisition 8.2.2 as you mentioned you were going to try. ImaqDxGetAttributeIncrement should not have any problems on either version. If you are getting an error, it may be that the attribute type does not have any increment (such as a String type or Enumeration).
 
Simonerom,
 
You are correct in that SetAttribute only affects attributes for the duration of your session. You are expected to use WriteAttributes() if you want your settings to persist past the session. I'm not sure what you mean that it fails when the camera is configured as in "continuous" mode. Do you mean that it fails when you call ReadAttributes() after starting an acquisition? If that is the case, this behavior is by design because many attributes become read-only while you are running, such as attributes that change the basic format/size of the image. You must stop the acquisition before trying to load the attributes from a file.
 
Eric G
Message 7 of 13
(5,236 Views)
Yes, you understand well.
But, in the end, I was not able to correctly save and restore attributes from file with readAttributes/writeAttributes. Maybe because I don't understand well how this functions work.
For example, I can't use "c:\anyname.ext" as a filename in writeAttributes, but it seems to work if I use the string "CAM0.ICD" as filename. Also, I don't understand when to call this functions, may I have an example (I can't find mention opf this functions in the help)?

--
Simone
0 Kudos
Message 8 of 13
(5,210 Views)

Hello ,

Finally with NI-IMAQDX 3.01 I  can have access to camera attributes , it works , to save the attribute I simply write it into camera's .icd file.

How to use offsetX OffsetY Width and Height camera attributes   in order to resize the acquisition ROI ?

It is mainly not possible to resize it to something different to left=0 and top = 0 , even with Max 4.2 ( save and reopen )

Thank you for help

 

 

0 Kudos
Message 9 of 13
(5,148 Views)
Hi Maury,
 
My guess is that the OffsetX and OffsetY are not adjustable on your camera in the current video mode. What kind of camera are you using? If its firewire, do you have it in Format 7 mode? Also, does MAX let you change the ROI or does it disable those controls?
 
-Eric G
0 Kudos
Message 10 of 13
(5,141 Views)