PDA

View Full Version : Get value of Exposure when ExposureAuto=True



odissey1
January 26, 2007, 04:40:06
Hi,

1. I use DFK 41AF02 camera with IC v3.0. When CImagingControl1.ExposureAuto is set to True, then value returned by ICImagingControl1.Exposure becomes '0' (zero). Is there any way to get an actual value of the ICImagingControl1.Exposure used by the camera in this case?

2. I noticed that with CImagingControl1.ExposureAuto=True and very low light conditions, Exposure time is automatically increased by the camera, so at certain point it can even become longer that a frame period (7.5 Hz). Then camera hangs up (at least in my program). Is there any way to limit the exposure time to some sane value, e.g 1/8sec (even on the expence of the under-exposing images)?

Sincerely,
Boris

Stefan Geissler
January 26, 2007, 10:18:43
Hi Boris,


1. I use DFK 41AF02 camera with IC v3.0. When CImagingControl1.ExposureAuto is set to True, then value returned by ICImagingControl1.Exposure becomes '0' (zero). Is there any way to get an actual value of the ICImagingControl1.Exposure used by the camera in this case?

While exposure auto is enabled, the camera does not deliver the currently used values. This is simply not supported and I guess it will never be supported.


2. I noticed that with CImagingControl1.ExposureAuto=True and very low light conditions, Exposure time is automatically increased by the camera, so at certain point it can even become longer that a frame period (7.5 Hz). Then camera hangs up (at least in my program). Is there any way to limit the exposure time to some sane value, e.g 1/8sec (even on the expence of the under-exposing images)?


The camera should not hang up, but the frame rate is lowered. You may send me the serial number of the camera, thus I can retrieve the firmware revision. If it is too old, we can update the firmware per software.
The only way to influence the auto exposure algorithm it to manipulate the "Auto Exposure Reference" value. This value determines the brightness of the images.

Shih-Schon Lin
May 10, 2007, 12:37:39
Hi Boris,


While exposure auto is enabled, the camera does not deliver the currently used values. This is simply not supported and I guess it will never be supported.




The camera should not hang up, but the frame rate is lowered. You may send me the serial number of the camera, thus I can retrieve the firmware revision. If it is too old, we can update the firmware per software.
The only way to influence the auto exposure algorithm it to manipulate the "Auto Exposure Reference" value. This value determines the brightness of the images.


Please plan to support this feature of reading back exposure value even when "Auto=true". There are many applications out there that desparately need this function. I am coding up a system that requires absolute brightness value all the time so we need the exposure value for each image captures in order to compare the real brightness strength. However in outdoor condition the lighting change is so big we want the camera to be able to adapt otherwise the picture would be saturated or too dark. The adaptation can only be done automatically with "auto=true", however we lose the ability to read back the actual exposure value so we cannot know how the actual brightness of a point from two pictures are related.

We have tried to implement our own auto adaptation (meaning that we leave "auto=off" and try to adjust the brightness based on some analysis of grabbed images" but it turns out that this would seriously hurt usable frame rate. One problem is that once we issue a new exposure to the camera via VCD properties we find that the new exposure would not take effect until after several frames. Do you have a reason why this is so? Is there hardware or software limitation why the change in exposure cannot take effect right in the next frame?

Stefan Geissler
May 10, 2007, 13:27:13
Hello,


We have tried to implement our own auto adaptation (meaning that we leave "auto=off" and try to adjust the brightness based on some analysis of grabbed images" but it turns out that this would seriously hurt usable frame rate. One problem is that once we issue a new exposure to the camera via VCD properties we find that the new exposure would not take effect until after several frames. Do you have a reason why this is so? Is there hardware or software limitation why the change in exposure cannot take effect right in the next frame

This is still an issue of the hardware. A new exposure value will be affect not the current frame, but the next frame. May be there is a little time the electronic needs to adjust the new exposure value, but this should be forgetable.

Shih-Schon Lin
May 10, 2007, 16:07:26
Hello,



This is still an issue of the hardware. A new exposure value will be affect not the current frame, but the next frame. May be there is a little time the electronic needs to adjust the new exposure value, but this should be forgetable.



I can understand that the new exposure value not in effect for the current frame since the integration process has started.
However the new value would still NOT be in effect in the Next frame, and still NOT be in effect in the 2nd next frame. I have found that the new value would only be in effect after the 3rd next frame. I have program that plot the pixel value for each frame after the new exposure value is issued and it always shows that the 2 frames following the new exposure value is issued the pixel value remains the old values.


What I cannot understand is that why the hardware have to wait for 2 more frames until it use the new exposure value? Can that be improved in the hardware?


I have also found that other VCD properties, like gain and brightness also has this delay but they have less delay. They take one extra frame following the new value is set before the new value takes effect.

Stefan Geissler
May 10, 2007, 16:11:58
Hello,


What I cannot understand is that why the hardware have to wait for 2 more frames until it use the new exposure value? Can that be improved in the hardware?

No, it can not be improved. This is camera internal stuff.


I have also found that other VCD properties, like gain and brightness also has this delay but they have less delay. They take one extra frame following the new value is set before the new value takes effect.

Brightness and gain have no direct influence on the CCD and the analogue front end in the camera like exposure. Thus you can see their effects earlier.

odissey1
May 14, 2007, 17:59:37
Hi Shih-Schon Lin,

I ended up with implementing of 'Auto exposure' algorithm by myself. Basically, I evaluate selective pixels brightness after each image received, and set a new exposure. In my case I need frame rate 1Hz and camera adjusts OK (tested good up to 2 Hz frame rate). If necessary, I can upload a code (written in Delphi). The other solution I consider is Auto-iris lens with some little extra electronics - this may be even better solution for outdoor (aerial) imaging, where brightness variations are wide and sudden.

Regards,
Bob

meltemii
July 29, 2007, 21:43:24
Bob,
I am also trying to replace auto iris lens capability with new firewire cameras without auto iris. I am very interested in your code, Delphi is great. Or any other solutions you have found successful.

Thanks!

odissey1
July 30, 2007, 21:06:20
Hi meltmeii,

The easy way for me would be to send you the whole application w/sourcecode. Send me your e-mail addres to:<bt_@_lasen_inc.com> (remove all '_' in actual address).

I will post extracted code here this afernoon.

Regards,
Bob

waterman
August 20, 2007, 16:15:38
Hi,
May be the following is possible in your application:
Gain and Exposure values can be read if you change the Automation to False for a short time,
read the value, then change Automation to True again.
For the gain value this works perfect, For the Exposure value the closed loop is disurbed,
but the Exposure vale is read correct.
See the short codesequence below:

If ICImagingControl1.GainAuto Then
ICImagingControl1.GainAuto = False
sldrGain.Value = ICImagingControl1.Gain
ICImagingControl1.GainAuto = True
txtGainValue.Text = sldrGain.Value
End If

hope it helps
horst

Sascha Schmidt
August 21, 2007, 12:16:34
Hallo,

in order to get the exposure value, while auto is enabled, you have to use the VCDProperty - Interface.
Also you must update the property using .Update():



Dim AbsValItf As VCDAbsoluteValueProperty
Set AbsValItf = ICImagingControl1.VCDPropertyItems.FindInterface(V CDID_Exposure + ":" + VCDElement_Value + ":" + VCDInterface_AbsoluteValue)
AbsValItf.Update

Label1.Caption = Str(AbsValItf.Value)

odissey1
August 27, 2007, 19:32:23
Hi,

This is an example of exposure auto-adjust after each image capture.
Works OK at up to 2 images/sec

regards,
odissey1

-----------------------------------------------------------------------

var
Nav2: integer;
Znorm2: integer;
ExposureMin: integer=0;//(1/8192sec)
ExposureMax: integer=1069;//(1/4sec) - this may not work with Timer1.Interval=500
ExposureBak: integer;

...

procedure TFormImaging.ICImagingControl1ImageAvailable(ASend er: TObject; BufferIndex: Integer);
var CurrentBuffer: ImageBuffer;
begin

ICImagingControl1.LiveCapturePause:=True; //stop acquiring images (until next trigger event)

CurrentBuffer := ICImagingControl1.ImageBuffers[BufferIndex];
CurrentBuffer.Lock;

ICImagingControl1.DisplayImageBuffer(CurrentBuffer );

AdjustCameraExposure(CurrentBuffer);

// SaveImage(CurrentBuffer, FormatImageName(ImgCounter));

CurrentBuffer.Unlock;

end;

procedure TFormImaging.AdjustCameraExposure(aBuffer: ImageBuffer);
begin
GetPartialHist(aBuffer);
AddjustExposureByPID;
end;

procedure TFormImaging.GetPartialHist(aBuffer: ImageBuffer);
var
i,x,y,sx,sy,B,G,R,Grsc: integer;
xOffset,yOffset: integer;
sx1,sx2: integer;
pBuffer: PChar;
pPixel : PChar;
N2tot: integer;
A2: array [0..255] of integer;
const
G3=1/3;
//get 9 horizontal scans across whole height of the image->
// Yk: array [0..8] of integer= (0,120,240,360,480,600,720,840,960-1);//todo: make sure image height is 960
//get 9 horizontal scans across central 1/2 height of the image->
//Yk: array [0..8] of integer= (240,300,360,420,480,540,600,660,720);//todo: make sure image height is 960
//get 9 horizontal scans across TOP half of the image->
Yk: array [0..8] of integer= (480,540,600,660,720,780,840,900,960-1);
begin
//get partial histogram->

fillchar(A2,Sizeof(A2),#0);//zero
N2tot:=0;

sx := ICImagingControl1.ImageWidth;
sy := ICImagingControl1.ImageHeight;
sx1:=0;
sx2:=sx;
// sx1:=round(0.25*sx);//for partial histogram we subsample only
// sx2:=round(0.75*sx);// central 0.5X x 0.5Y part of the image

// Znorm2:=sx * Succ(High(Yk));
Znorm2:=Succ(sx2-sx1) * Succ(High(Yk));

pBuffer := PChar(ABuffer.ImageDataPtr);//get pointer to ImageBuffer

for i := 0 to High(Yk) do
begin
y:=Yk[i];//scan only partial lines

xOffset:=0;
yOffset:=y*(sx+sx+sx);//sx*3
pPixel := pBuffer + yOffset + xOffset;

// for x:=0 to sx-1 do begin
for x:=sx1 to Pred(sx2) do begin
B := byte((pPixel)^); inc(pPixel); //B
G := byte((pPixel)^); inc(pPixel); //G
R := byte((pPixel)^); inc(pPixel); //R
Grsc:=round(G3*(B+G+R));

Inc(A2[Grsc]);
Inc(N2tot,Grsc);
end;
end;
Nav2:=round(N2tot/Znorm2);

end;

procedure TFormImaging.AddjustExposureByPID;
var
Exp: integer;
E,E1: double;
begin
ExposureBak :=ICImagingControl1.Exposure;//record current exposure setting for logging
Exp:=ExposureBak;

//proportional scaling approach->
//set new exposure based on previous values of Exposure and brigtness
//set new value of exposure Exp by extrapolating proportionally toward average brightness of '128'.
if Nav2= 0 then Nav2:=1; //not to divide by 0
if Exp = 0 then Exp:=1; //not to stuck at 0

Exp:=round(Exp * 128 / Nav2); //Nav2 is average brightness obtained in GetPartialHist(..)

//can limit resulting exposure values to some pre-defined values
if Exp < ExposureMin then Exp := ExposureMin else
if Exp > ExposureMax then Exp := ExposureMax;

if Exp <> ExposureBak then //update exposure in ICImagingControl1
ICImagingControl1.Exposure:=Exp; //(real value in camera will be updated in ~0.5 sec)

end;