PDA

View Full Version : Reading and setting zoom (DFx 31AF03-Z)



ertem
January 5, 2010, 23:01:30
Hi Stefan et. al. ,

I am getting frustrated with this. I have read the help files but
can't figure out how to read (and to set) camera zoom values. I
want to do this in the overlay callback, I will be tracking the
zoom with ZoomNow and want to drive it via the DesiredZoom
global variables.

The code fragment is as below:

int ZoomNow, DesiredZoom; // these are globals, we like globals!

void COverlayCallback::overlayCallback( Grabber& param, smart_ptr<OverlayBitmap> pBitmap, const tsMediaSampleDesc &MediaSample ){

tIVCDPropertyItemsPtr pItems = param.getAvailableVCDProperties();
if( pItems != 0 )
{
tIVCDPropertyItemPtr pZoomItem = pItems->findItem( VCDID_Zoom );
if( pZoomItem != 0 ){
tIVCDPropertyElementPtr pZoomValueElement = pZoomItem->findElement( VCDElement_Value );
if( pZoomValueElement != 0 )
{

//What now????)

// ZoomNow = get current value
// also tell camera to set zoom to DesiredZoom (not every callback, whenever needed.

}
}
}



Thanks


PS: I have used your SetExposureAbsolute() code and it works. (My grabber is public: so I can get to it
from anywhere...) Just need to do the same with Zooom, but changing VCDID_Exposure to VCDID_Zoom
in that code does not work...

PPS: Yes, dvdevice.vda, tisdcam.vda, uvc_driver.vda and vcc_vp.vda are in the release directory.

Stefan Geissler
January 6, 2010, 08:47:36
Hi

I am very sorry that you are frustrated. This was not intended.


void CZoomControllerDlg::ZoomPlus()
{
if( m_cGrabber.isDevValid() )
{
tIVCDPropertyItemsPtr pItems = m_cGrabber.getAvailableVCDProperties();
if( pItems != 0 )
{

smart_com<IVCDPropertyInterface> pZoomInterface = pItems->findInterface(VCDID_Zoom,VCDElement_Value,VCDInter face_Range);

if( pZoomInterface != NULL)
{
tIVCDRangePropertyPtr pZoomRange;
pZoomInterface->QueryInterface( pZoomRange );

if( pZoomRange != NULL )
{
long Current = 0;
pZoomRange->get_Value(&Current);
if( Current < pZoomRange->getRangeMax() )
{
pZoomRange->setValue(Current +1 );
}
}
}
}
}
}


And this:


void CZoomControllerDlg::ZoomMinus()
{
if( m_cGrabber.isDevValid() )
{
tIVCDPropertyItemsPtr pItems = m_cGrabber.getAvailableVCDProperties();
if( pItems != 0 )
{

smart_com<IVCDPropertyInterface> pZoomInterface = pItems->findInterface(VCDID_Zoom,VCDElement_Value,VCDInter face_Range);

if( pZoomInterface != NULL)
{
tIVCDRangePropertyPtr pZoomRange;
pZoomInterface->QueryInterface( pZoomRange );

if( pZoomRange != NULL )
{
long Current = 0;
pZoomRange->get_Value(&Current);
if( Current > pZoomRange->getRangeMin() )
{
pZoomRange->setValue(Current -1 );
}
}
}
}

}
}


In case you want to perform a One Push Autofocus:


void CZoomControllerDlg::OnePushFocus()
{
if( m_cGrabber.isDevValid() )
{

tIVCDPropertyItemsPtr pItems = m_cGrabber.getAvailableVCDProperties();
if( pItems != 0 )
{
tIVCDPropertyItemPtr pFocusItem = pItems->findItem( VCDID_Focus );
if( pFocusItem != NULL)
{
tIVCDPropertyElementPtr pOnePushElement = pFocusItem->findElement( VCDElement_OnePush );

if( pOnePushElement != NULL )
{
DShowLib::tIVCDButtonPropertyPtr pFocusOnePush;
pOnePushElement->getInterfacePtr(pFocusOnePush);
pFocusOnePush->push();
}
}
}
}
}


I hope, this helps.

ertem
January 7, 2010, 14:18:12
Thank you Stefan, that was very useful! It ran nicely with your code and then after wading through more documentation I ended up with:



long GetFocus(DShowLib::Grabber *pGrabber){
return (pGrabber->getProperty(CameraControl_Focus));
}
long SetFocus(DShowLib::Grabber *pGrabber, long Focus){
pGrabber->setProperty(CameraControl_Focus,false); // force auto off
return (pGrabber->setProperty(CameraControl_Focus,Focus));
}
long GetZoom(DShowLib::Grabber *pGrabber){
return (pGrabber->getProperty(CameraControl_Zoom));
}
long SetZoom(DShowLib::Grabber *pGrabber, long Zoom){
pGrabber->setProperty(CameraControl_Zoom,Zoom);
SetFocus(pGrabber,532); //force to inf - tune number
return (pGrabber->getProperty(CameraControl_Zoom));
}
long ZoomMinus(DShowLib::Grabber *pGrabber){
long Next = GetZoom(pGrabber)-1;
if (Next<0) Next=0;
return(SetZoom(pGrabber,Next));
}
long ZoomPlus(DShowLib::Grabber *pGrabber){
long Next = GetZoom(pGrabber)+1;
if (Next>17) Next=17;
return(SetZoom(pGrabber,Next));
}

(The parameters 532 and 17 are hardcoded for my camera.)

It's running fine, but now I have another problem. The camera is stepping through the 17 zoom levels OK, but during the zooming it loses focus then recovers, even though I force the focus to infinity with each SetZoom. Is there any way to have it stay in focus while zooming?

It's working as a step zoom, and I'd like to smooth it out as much as possible during transitions. I know that the issue is probably due to optical design, but if there is any solution you know I would greatly appreciate it.

Thanks again for the wonderful support.

mce

Stefan Geissler
January 7, 2010, 14:25:10
Hi,

The zoom steps are defined in the camera's firmware, thus it is not possible to go more smooth. The camera sets a new focus after the zoom was changed, so the image should stay sharp.

Setting a value out of the range limitation of a property should have no effect, because it wont be set. I am not sure, whether 532 is in range of the focus parameter.

ertem
January 7, 2010, 14:32:35
A little more info, this is turning into an optics question... :-)

The DemoApp is doing the same behavior when I move the Zoom slider
in the Device Properties dialog.

It's hunting for the focus and ends up pretty much in the same place,
between 530 and 600 for far field focus. If I could just lock down the
focus to a value while the lens(es) are moving.

If I have focus setting 532 at zoom level 16 and then change to
zoom 14 keeping focus at 532, is there any way to keep the motion
of the lenses synchronized? How many elements in the optic train
move anyway?

Thanks...

mce

ertem
January 7, 2010, 14:35:02
We crossed messages...

Yes, the 532 is in range. I used the DemoApp Device properties to check for
the hard values...

Thanks for the help...

If a USB zoom camera comes out, please consider that firmware upgrade as a
desired feature for a new camera... :-)

mce

Stefan Geissler
January 7, 2010, 14:36:18
Well,

USB does not provide enough power to drive the zoom lens. A USB Zoom camera would need an external power supply :-(

ertem
January 7, 2010, 14:55:33
Agree... Never mind about the USB. :-)

But if they update firmware, synchronized lens movement would really help.

c

Stefan Geissler
January 7, 2010, 14:57:10
Hi

But if they update firmware, synchronized lens movement would really help.
I understand. But I do not know, whether we can workaround the limiations of the lens ... The DFx 31AF03-Z2 has another lens, but is uses zoom steps too.

ertem
January 7, 2010, 15:21:04
I can live with steps, as long as in between steps it stays in focus, while lenses are moving.

Best regards... mce