Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

help with imgSetCameraAttribute

I'm having trouble programmatically adjusting camera integration and frame rate from within a C++ application. Some of this may be specific to my .icd file and camera (Adimec 1600m).

I am able to successfully set the integration time but the frame rate may be removed by one level by a 2nd attribute and I haven't been able to set its value.

for setting frame integration, this works successfully:
float ms = 10.0f;
ret = imgSetCameraAttributeNumeric(sessionID, "Integration time", (double)ms*1000.0);

in a similar manner, I'm trying to adjust frame rate (the current value is 4000):
ret = imgSetCameraAttributeNumeric(sessionID, "Frame Period", (double)5000);

and I've tried a few variations:
ret = imgSetCameraAttributeString(sessionID,"Frame Period","User Select");
ret = imgSetCameraAttributeNumeric(sessionID, "User Select", (double)3330);

and a few other variations.

I'm able to adjust with NI MAX and I'm trying to emulate that through a program.

I'm not changing camera attributes very frequently so I'm on some unfamiliar ground. Any help on this mechanism would be great.

Thanks,
Wes




here is the relevant section of the .icd file:

Attribute (Frame Period) {
Value (List) {
Name (Min) {
Action (Serial) {
Command (@FP0\r)
Response (\x06)
}
}
Name (User Select) {
Attribute (Value) {
Value (Integer) {
Min (1)
Max (4000)
Increment (1)
Display {
Multiplier (10.000000)
Offset (0.000000)
Precision (0)
Units (µs)
}
Default (500)
Current (4000)
Action (Serial) {
Command (@FP%d\r)
Response (\x06)
}
}
}
}
Default (Min)
Current (User Select)
}
0 Kudos
Message 1 of 3
(3,512 Views)
From the .icd file, the following command looks correct (your second guess):

ret = imgSetCameraAttributeString(sessionID,"Frame Period","User Select");
ret = imgSetCameraAttributeNumeric(sessionID, "User Select", (double)3330);

I wonder why the numeric value is converted to a double, when it is an integer in the icd file, but that doesn't really matter.

You can't set the value to 5000, because the limit is 4000 (from icd file).

The number you specify is the number of 10 usec intervals. For example, 4000 is equal to 40000 usec.

It may be useful for debugging purposes to read and display the values before and after changing them, to make sure they are changed the way you expect. The before value should match the default value in the icd file, and the after value should be what you tried to set it to.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 3
(3,505 Views)
Thanks Bruce for the above comments, they provide useful validation.

so - I screwed up.

I went back to the .icd file and the attribute is "Value" rather than the "User Select" that I thought it was...

This sequence now works -

// rate is in Hz.
float period = 1.0f/rate;

int ret = imgGetCameraAttributeString(sessionID, "Frame Period", text,256);
TRACE(" current frame period value: %s\n",text);

ret = imgGetCameraAttributeString(sessionID, "User Select", text,256);
ret = imgGetCameraAttributeString(sessionID, "Value", text,256);
TRACE(" %s\n",text);

float period = 1.0f/rate;
ret = imgSetCameraAttributeNumeric(sessionID, "Value", period*1000000.0);

this has just all been a bit awkward but I suppose this is good for flexibility.
The 10x multiplier, for example, applies to the values set under MAX; the value that I program doesn't go through that same 10x multiplier.

Which is fine if you know this going in...

I haven't worked extensively with the .icd files. If I had only checked the documentation on those .icd format...
0 Kudos
Message 3 of 3
(3,502 Views)