Skip to content

Commit

Permalink
add focues_absolute getter/ setter
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxxel committed Jun 2, 2017
1 parent e562f7f commit 5dacdbe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from distutils.core import Extension, setup
setup(
name = "v4l2capture",
version = "1.5",
version = "1.6",
author = "Fredrik Portstrom",
author_email = "[email protected]",
url = "http://fredrik.jemla.eu/v4l2capture",
Expand Down
44 changes: 44 additions & 0 deletions v4l2capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,43 @@ static PyObject *Video_device_get_focus_auto(
#endif
}

static PyObject *Video_device_set_focus_absolute(
Video_device * self,
PyObject * args) {
#ifdef V4L2_CID_FOCUS_ABSOLUTE
int focus_absolute;
if (!PyArg_ParseTuple(args, "i", &focus_absolute)) {
return NULL;
}

struct v4l2_control ctrl;
CLEAR(ctrl);
ctrl.id = V4L2_CID_FOCUS_ABSOLUTE;
ctrl.value = focus_absolute;
if (my_ioctl(self->fd, VIDIOC_S_CTRL, &ctrl)) {
return NULL;
}
return Py_BuildValue("i", ctrl.value);
#else
return NULL;
#endif
}

static PyObject *Video_device_get_focus_absolute(
Video_device * self) {
#ifdef V4L2_CID_FOCUS_ABSOLUTE
struct v4l2_control ctrl;
CLEAR(ctrl);
ctrl.id = V4L2_CID_FOCUS_ABSOLUTE;
if (my_ioctl(self->fd, VIDIOC_G_CTRL, &ctrl)) {
return NULL;
}
return Py_BuildValue("i", ctrl.value);
#else
return NULL;
#endif
}

static PyObject *Video_device_start(
Video_device * self) {
ASSERT_OPEN;
Expand Down Expand Up @@ -922,6 +959,13 @@ static PyMethodDef Video_device_methods[] = {
{"get_focus_auto", (PyCFunction) Video_device_get_focus_auto, METH_NOARGS,
"get_focus_auto() -> autofocus \n\n"
"Request the video device to get auto focus value. "},
{"set_focus_absolute", (PyCFunction) Video_device_set_focus_absolute, METH_VARARGS,
"set_focus_absolute(focus_absolute) -> focus_absolute \n\n"
"Request the video device to set the focus to the given value. The device may "
"choose another value than requested and will return its choice. "},
{"get_focus_absolute", (PyCFunction) Video_device_get_focus_absolute, METH_NOARGS,
"get_focus_absolute() -> focus_absolute \n\n"
"Request the video device to get the focus value. "},
{"get_framesizes", (PyCFunction) Video_device_get_framesizes, METH_VARARGS,
"get_framesizes() -> framesizes \n\n"
"Request the framesizes suported by the device. "},
Expand Down

0 comments on commit 5dacdbe

Please sign in to comment.