Document Actions

How to control pan/tilt/zoom on Logitech cameras

Shows how to programmatically control the mechanical pan/tilt controls of the Logitech QuickCam Orbit/Sphere camera series as well as the digital pan/tilt/zoom controls of other Logitech QuickCam camera models.

Purpose

The Logitech QuickCam Orbit/Sphere camera series contain motors to mechanically control the pan and tilt angles of the camera lens. At the same time, most Logitech cameras support digital pan/tilt/zoom (PTZ) in addition to or instead of mechanical pan/tilt. This document explains how to control these features in your own applications using the standard DirectShow properties built into Windows.

Prerequisities

Hardware

You need a Logitech UVC camera connected to a Windows system to follow this how-to. Windows XP or Vista are recommended.

Any Logitech UVC camera will do for the digital pan/tilt/zoom functionality but in order to take full advantage of the mechanical pan/tilt feature you need a Logitech QuickCam Orbit/Sphere camera (all MP or AF models are fine).

Driver

Your camera needs to be running with the Logitech UVC driver version 11.1 or higher to follow this how-to. (Some versions of lvuvc.sys prior to 11.1 had a bug where negative pan/tilt angles were handled incorrectly.)

Please note that the Microsoft UVC driver will not work for the purpose of this how-to because it does not implement any of the digital or mechanical pan/tilt/zoom features.

Software

In order to compile the sample code you will need Visual Studio 2005 and a recent version of the Windows SDK (tested with 6.0 and 6.1).

There is nothing that intrinsically prevents you from following this how-to on older versions of these developer tools but you may have to change a few lines of (non webcam-specific) code, in particular because the sample uses some functions of the Visual Studio 2005 Safe C/C++ Libraries.

Logitech UVC driver versions 11.9 and below

Most of this section refers to the sample code for which you can find a link at the end of the article. The code archive also includes a pre-compiled binary in case you want to try the sample but you don't have the development tools at hand.

The sample uses the standard DirectShow API to enumerate all video input devices in the system and to access the corresponding camera control properties.

To see the sample in action, either run the provided PTZ.exe in the Release directory or compile the sample code and run the resulting PTZ.exe from a command line to see the output. In order to be able to see the effects of digital pan/tilt/zoom it is recommended to start a video stream in a video application like AMCap before running the tool. The mechanical pan/tilt obviously works whether the camera is streaming video or not.

We use the following DirectShow properties in the IAMCameraControl interface's PROPSETID_VIDCAP_CAMERACONTROL property set.

  • KSPROPERTY_CAMERACONTROL_PAN
  • KSPROPERTY_CAMERACONTROL_TILT
  • KSPROPERTY_CAMERACONTROL_ZOOM

These properties are generic properties defined by Microsoft. The following behavior, however, is specific to the Logitech UVC driver:

  • Specifying the KSPROPERTY_CAMERACONTROL_FLAGS_ABSOLUTE flag for the pan and tilt properties instructs the driver to use digital instead of mechanical pan/tilt.

Using these three controls you can control the following features:

  • Mechanical pan
  • Mechanical tilt
  • Digital pan
  • Digital tilt
  • Digital zoom

With this information and the documentation provided in the Further information section below you are able to control these features from your own application. Don't forget to look at the inline code comments and links.

Logitech UVC driver versions 12.0 and above

The sample code mentioned in the previous section was designed to work with UVC driver versions prior to 12.0. Starting with the UVC driver version 12.0 the implementation of the CameraControl property set has changed and a new property set has been introduced to improve many of the property interfaces, in particular the pan/tilt/zoom functionality.

The KSPROPERTY_CAMERACONTROL_PAN and KSPROPERTY_CAMERACONTROL_TILT properties of the PROPSETID_VIDCAP_CAMERACONTROL property set are now exclusively controlling hardware pan and tilt. This implies that they are unavailable on camera models that do not support hardware pan/tilt. The KSPROPERTY_CAMERACONTROL_ZOOM property is no longer supported as no current model supports optical zoom.

Digital pan, tilt, and zoom are now controlled through the Logitech Public Property Set (LP1). Please refer to the following document for more information:

Logitech UVC Driver public property sets

Further information

For further information on the DirectShow controls mentioned in this article, please refer to the MSDN documentation on DirectShow:

If you have questions or problems with this sample, you can post them in the Windows Webcam Development forum. We do not guarantee support for this sample but we will try to respond to your questions.

Attached files
by Martin Rubli last modified 2009-10-01 20:25
Powered by Plone CMS.