View Full Version : DFK AFU130-L53 AutoFocus

March 9, 2016, 00:35:09
What's the secret to getting autofocus to run as smoothly as it does in the property page?

I've researched the forum posts and understand that the camera has to be set at a 30fps video format and that this specific camera doesn't support the onepushrunning so I have to pause for a couple of seconds.

I do all this but I still can't get reliable focusing but when I bring up the property page and run it there, it runs quickly and almost every time focuses correctly.

It's like there's a setting or mode I need to put it in for it to run beyond just the 30fps.

Is the source available anywhere? What's going on under the hood? Or maybe just the portion of code that runs the focus beyond just the push(VCDID_Focus).



Stefan Geissler
March 9, 2016, 11:55:43
Hello Greg

What's the secret to getting autofocus to run as smoothly as it does in the property page?

I am not allowed to tell the secret :-)

First of all, you are right. The video format must allow 30 fps, otherwise the focus one push will not run well.

Code for one push focus is:

void Push_Focus_One_Push(Grabber* pGrabber)
if( pGrabber->isDevValid() )
tIVCDButtonPropertyPtr pButtonItf;
tIVCDPropertyItemsPtr pItems = pGrabber->getAvailableVCDProperties();
pItems->findInterfacePtr(VCDID_Focus, VCDElement_OnePush ,pButtonItf);

if( pButtonItf != NULL )

March 9, 2016, 16:46:01
I implemented the CSimplePropertyAccess approach for setting values, pushing, etc. but even substituting in your code, it still doesn't work reliably.

Any settings changed to the camera upon entry to the dialog? I set the videoformat to the lowest resolution (640 x 480) before running the one push. Anything else I need to do?

Stefan Geissler
March 9, 2016, 16:54:02
Please describe ", it still doesn't work reliably"
This one push code does nothing different to what is being done in the dialog.

March 9, 2016, 18:26:13
It is unreliable in that it gives a non-focused image instead of a focused image much of the time whereas the focus in the dialog gives a focused image almost every time.

I have improved my success rate by the following steps (although I'm not sure why these help) but it's slower than dialog focus and can still result in out of focus.

1. Switch to 640 x 480 video format.
2. Set all camera properties (exposure, hue, saturation, etc.)
3. Running live for 1.5secs (startlive, then sleep(1500))
4. stoplive
5. perform focus push

Stefan Geissler
March 10, 2016, 10:23:44
Hello Greg

First of all, we have no influence on the auto focus of this sensor. We even do not know, how it works internally. Also we have no focus values. The firmware in the sensor is not from us, it is from SONY. The only thing we can do is commanding the sensor to perform the auto focus.

I wonder, why you stop the live video before doing the focus one push. IMHO this does not give a result, because the sensor is stopped.
So you should do:

Stop Live
Switch to 640 x 480 video format. Or use YUY2 (1920x1080) format
Start Live
Auto Focus one Push. Now you must see the focus being in progess, Image becomes blurred and sharp.
Wait 2 Seconds
Switch back to high res YUY2 (4128x3096)
Start Live

Usually the sequence is running always in the 30 fps video formats. So the camera can do auto focus, exposure, white balance etc. If an High Res image is needed, then stop, change video format, take an image, stop, swith to low res, start video.

In case you own a smart phone, then you see exactly this behavior if you take a photo. The sensor of your camera is used in smartphones too.