Skip to content

Commit

Permalink
Added linux support for exposure (untested).
Browse files Browse the repository at this point in the history
  • Loading branch information
trcwm committed Jul 17, 2017
1 parent 185b9ee commit 2c53ca3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
37 changes: 34 additions & 3 deletions linux/platformstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,49 @@ uint32_t PlatformStream::getFOURCC()

bool PlatformStream::setExposure(int32_t value)
{
return false;
v4l2_control ctrl;
CLEAR(ctrl);

ctrl.id = V4L2_CID_EXPOSURE;
ctrl.value = value;
if (xioctl(m_deviceHandle, VIDIOC_S_CTRL, &ctrl)==-1)
{
LOG(LOG_ERR,"setAutoExposure failed on VIDIOC_S_CTRL (errno %d)\n", errno);
return false;
}
return true;
}


bool PlatformStream::setAutoExposure(bool enabled)
{
return false;
v4l2_control ctrl;
CLEAR(ctrl);

ctrl.id = V4L2_CID_AUTOGAIN;
ctrl.value = enabled ? 1 : 0;
if (xioctl(m_deviceHandle, VIDIOC_S_CTRL, &ctrl)==-1)
{
LOG(LOG_ERR,"setAutoExposure failed on VIDIOC_S_CTRL (errno %d)\n", errno);
return false;
}
return true;
}


bool PlatformStream::getExposureLimits(int32_t *emin, int32_t *emax)
{
return false;
v4l2_queryctrl ctrl;
CLEAR(ctrl);

ctrl.id = V4L2_CID_EXPOSURE;
if (xioctl(m_deviceHandle, VIDIOC_QUERYCTRL, &ctrl) == -1)
{
LOG(LOG_ERR,"getExposureLimited failed on VIDIOC_QUERYCTRL (errno %d)\n", errno);
return false;
}
*emin = ctrl.minimum;
*emax = ctrl.maximum;
return true;
}

2 changes: 1 addition & 1 deletion linux/platformstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PlatformStream : public Stream
v4l2_format m_fmt; ///< V4L2 frame format
bool m_quitThread; ///< if true, captureThreadFunction should return
std::thread *m_helperThread; ///< helper object threading control
MJPEGHelper m_mjpegHelper; ///< helper to convert MJPEG stream RGB
MJPEGHelper m_mjpegHelper; ///< helper to convert MJPEG stream to RGB
};

#endif

0 comments on commit 2c53ca3

Please sign in to comment.