Related products: Video Capture SDK .Net

Camera control and PTZ in Video Capture SDK .Net

Using Camera Control API you can set the following camera parameters (camera can support only some of them): Pan, Tilt, Roll, Zoom, Exposure, Iris, Focus.

Camera Control API should be used with started camera preview or capture.

In this tutorial we'll use Zoom command.

On form we using several checkboxes, labels and slider control. You can check Main Demo source code.

1. Read default values and command ranges.

int max;
int defaultValue;
int min;
int step;
VFCameraControlFlags flags;

if (VideoCapture1.Video_CaptureDevice_CameraControl_GetRange(
    VFCameraControlProperty.Zoom, out min, out max, out step, out defaultValue, out flags))
{
    // set slider range
    tbCCZoom.Minimum = min;
    tbCCZoom.Maximum = max;
    tbCCZoom.SmallChange = step;
    tbCCZoom.Value = defaultValue;

    // set min, max and current values on labels
    lbCCZoomMin.Text = "Min: " + Convert.ToString(min);
    lbCCZoomMax.Text = "Max: " + Convert.ToString(max);
    lbCCZoomCurrent.Text = "Current: " + Convert.ToString(defaultValue);

    // set command checkboxes
    cbCCZoomManual.Checked = (flags & VFCameraControlFlags.Manual) == VFCameraControlFlags.Manual;
    cbCCZoomAuto.Checked = (flags & VFCameraControlFlags.Auto) == VFCameraControlFlags.Auto;
    cbCCZoomRelative.Checked = (flags & VFCameraControlFlags.Relative) == VFCameraControlFlags.Relative;
}

If Auto flag set all other flags and values will be ignored.

2. Apply value set on slider (Auto checkbox should be disabled to set manual value or enabled to set camera default value).

VFCameraControlFlags flags = VFCameraControlFlags.None;

if (cbCCZoomManual.Checked)
{
    flags = flags | VFCameraControlFlags.Manual;
}

if (cbCCZoomAuto.Checked)
{
    flags = flags | VFCameraControlFlags.Auto;
}

if (cbCCZoomRelative.Checked)
{
    flags = flags | VFCameraControlFlags.Relative;
}

VideoCapture1.Video_CaptureDevice_CameraControl_Set(VFCameraControlProperty.Zoom, tbCCZoom.Value, flags);

VisioForge © 2006-2020

  • GitHub-Mark-64px
  • Twitter Социальные Иконка
  • VisioForge Facebook page
  • YouTube channel