Updated the camera virtual interface
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@45 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
d3d90bc6a9
commit
708cfa9cff
@ -25,7 +25,7 @@ Camera::~Camera()
|
|||||||
|
|
||||||
void Camera::stop()
|
void Camera::stop()
|
||||||
{
|
{
|
||||||
cameraTimer_.stop();
|
stopTimer();
|
||||||
if(capture_)
|
if(capture_)
|
||||||
{
|
{
|
||||||
cvReleaseCapture(&capture_);
|
cvReleaseCapture(&capture_);
|
||||||
@ -75,28 +75,43 @@ bool Camera::start()
|
|||||||
{
|
{
|
||||||
if(!capture_)
|
if(!capture_)
|
||||||
{
|
{
|
||||||
if(!capture_)
|
capture_ = cvCaptureFromCAM(Settings::getCamera_deviceId().toInt());
|
||||||
|
if(capture_)
|
||||||
{
|
{
|
||||||
capture_ = cvCaptureFromCAM(Settings::getCamera_deviceId().toInt());
|
cvSetCaptureProperty(capture_, CV_CAP_PROP_FRAME_WIDTH, double(Settings::getCamera_imageWidth().toInt()));
|
||||||
if(capture_)
|
cvSetCaptureProperty(capture_, CV_CAP_PROP_FRAME_HEIGHT, double(Settings::getCamera_imageHeight().toInt()));
|
||||||
{
|
|
||||||
cvSetCaptureProperty(capture_, CV_CAP_PROP_FRAME_WIDTH, double(Settings::getCamera_imageWidth().toInt()));
|
|
||||||
cvSetCaptureProperty(capture_, CV_CAP_PROP_FRAME_HEIGHT, double(Settings::getCamera_imageHeight().toInt()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!capture_)
|
|
||||||
{
|
|
||||||
printf("Failed to create a capture object!\n");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!capture_)
|
||||||
|
{
|
||||||
|
printf("Failed to create a capture object!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cameraTimer_.start(1000/Settings::getCamera_imageRate().toInt());
|
startTimer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Camera::startTimer()
|
||||||
|
{
|
||||||
|
updateImageRate();
|
||||||
|
cameraTimer_.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::stopTimer()
|
||||||
|
{
|
||||||
|
cameraTimer_.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void Camera::updateImageRate()
|
void Camera::updateImageRate()
|
||||||
{
|
{
|
||||||
cameraTimer_.setInterval(1000/Settings::getCamera_imageRate().toInt());
|
if(Settings::getCamera_imageRate().toInt())
|
||||||
|
{
|
||||||
|
cameraTimer_.setInterval(1000/Settings::getCamera_imageRate().toInt());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cameraTimer_.setInterval(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,15 +20,20 @@ public:
|
|||||||
|
|
||||||
virtual bool start();
|
virtual bool start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
virtual bool isRunning() {return cameraTimer_.isActive();}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void imageReceived(const cv::Mat & image);
|
void imageReceived(const cv::Mat & image);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateImageRate();
|
virtual void updateImageRate();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void takeImage();
|
virtual void takeImage();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void startTimer();
|
||||||
|
void stopTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CvCapture * capture_;
|
CvCapture * capture_;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user