Skip to content

Commit

Permalink
add sharpness setter and getter
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxxel committed Jul 4, 2017
1 parent 5dacdbe commit ea3980a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions v4l2capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,43 @@ static PyObject *Video_device_get_focus_absolute(
#endif
}

static PyObject *Video_device_set_sharpness(
Video_device * self,
PyObject * args) {
#ifdef V4L2_CID_SHARPNESS
int sharpness;
if (!PyArg_ParseTuple(args, "i", &sharpness)) {
return NULL;
}

struct v4l2_control ctrl;
CLEAR(ctrl);
ctrl.id = V4L2_CID_SHARPNESS;
ctrl.value = sharpness;
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_sharpness(
Video_device * self) {
#ifdef V4L2_CID_SHARPNESS
struct v4l2_control ctrl;
CLEAR(ctrl);
ctrl.id = V4L2_CID_SHARPNESS;
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 @@ -966,6 +1003,13 @@ static PyMethodDef Video_device_methods[] = {
{"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. "},
{"set_sharpness", (PyCFunction) Video_device_set_focus_absolute, METH_VARARGS,
"set_sharpness(sharpness) -> sharpness \n\n"
"Request the video device to set the sharpness to the given value. The device may "
"choose another value than requested and will return its choice. "},
{"get_sharpness", (PyCFunction) Video_device_get_sharpness, METH_NOARGS,
"get_sharpness() -> sharpness \n\n"
"Request the video device to get the sharpness 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 ea3980a

Please sign in to comment.