Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow for variable grab count

  • Loading branch information...
commit 6b40c7b224a69fca4882ececa0abdcc89e6f6cc8 1 parent 665f343
@bmcdorman bmcdorman authored
View
4 include/kovan/camera.h
@@ -51,6 +51,10 @@ int camera_open();
*/
int camera_open_device(int number);
+void set_camera_grab_count(int grabs);
+
+int get_camera_grab_count();
+
/**
* Loads the config file specified by name.
* \param name The configuration to load. Configuration file names are case sensitive.
View
3  include/kovan/camera.hpp
@@ -172,6 +172,8 @@ namespace Camera
void setWidth(const unsigned &width);
void setHeight(const unsigned &height);
+ void setGrabCount(unsigned char grabs);
+ unsigned char grabCount() const;
const ChannelPtrVector &channels() const;
@@ -191,6 +193,7 @@ namespace Camera
cv::VideoCapture *m_capture;
ChannelPtrVector m_channels;
ChannelImplManager *m_channelImplManager;
+ unsigned char m_grabCount;
cv::Mat m_image;
timeval m_lastUpdate;
};
View
18 src/camera.cpp
@@ -261,6 +261,18 @@ void Camera::Device::setHeight(const unsigned &height)
m_capture->set(CV_CAP_PROP_FRAME_HEIGHT, height);
}
+void Camera::Device::setGrabCount(unsigned char grabs)
+{
+ if(grabs < 1) grabs = 1;
+ else if(grabs > 5) grabs = 5;
+ m_grabCount = grabs;
+}
+
+unsigned char Camera::Device::grabCount() const
+{
+ return m_grabCount;
+}
+
void Camera::Device::close()
{
if(!m_capture->isOpened()) return;
@@ -271,9 +283,9 @@ bool Camera::Device::update()
{
// Get new image
bool success = true;
- success &= m_capture->grab();
- success &= m_capture->grab();
- success &= m_capture->grab();
+ for(unsigned char i = 0; i < m_grabCount; ++i) {
+ success &= m_capture->grab();
+ }
success &= m_capture->retrieve(m_image);
if(!success) return false;
View
10 src/camera_c.cpp
@@ -23,6 +23,16 @@ int camera_open_device(int number)
return DeviceSingleton::instance()->open(number) ? 1 : 0;
}
+void set_camera_grab_count(int grabs)
+{
+ DeviceSingleton::instance()->setGrabCount(grabs);
+}
+
+int get_camera_grab_count()
+{
+ return DeviceSingleton::instance()->grabCount();
+}
+
int camera_load_config(const char *name)
{
Config *config = Config::load(Camera::ConfigPath::path(name));
Please sign in to comment.
Something went wrong with that request. Please try again.