Added Camera::finished() signal
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@368 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
970b9e95aa
commit
cd8368f0de
@ -376,6 +376,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// [Camera] ---Image---> [FindObject]
|
// [Camera] ---Image---> [FindObject]
|
||||||
QObject::connect(&camera, SIGNAL(imageReceived(const cv::Mat &)), findObject, SLOT(detect(const cv::Mat &)));
|
QObject::connect(&camera, SIGNAL(imageReceived(const cv::Mat &)), findObject, SLOT(detect(const cv::Mat &)));
|
||||||
|
QObject::connect(&camera, SIGNAL(finished()), &app, SLOT(quit()));
|
||||||
|
|
||||||
//use camera in settings
|
//use camera in settings
|
||||||
setupQuitSignal();
|
setupQuitSignal();
|
||||||
|
|||||||
@ -32,6 +32,7 @@ public:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void imageReceived(const cv::Mat & image);
|
void imageReceived(const cv::Mat & image);
|
||||||
|
void finished();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void updateImageRate();
|
virtual void updateImageRate();
|
||||||
|
|||||||
@ -128,7 +128,8 @@ void Camera::takeImage()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// In case of a directory of images or a video
|
// In case of a directory of images or a video
|
||||||
Q_EMIT imageReceived(cv::Mat()); // empty image to notify that there are no more images
|
this->stop();
|
||||||
|
Q_EMIT finished(); // notify that there are no more images
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -221,6 +221,7 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren
|
|||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||||
|
disconnect(camera_, SIGNAL(finished()), this, SLOT(stopProcessing()));
|
||||||
camera_->stop();
|
camera_->stop();
|
||||||
qDeleteAll(objWidgets_);
|
qDeleteAll(objWidgets_);
|
||||||
objWidgets_.clear();
|
objWidgets_.clear();
|
||||||
@ -496,6 +497,7 @@ void MainWindow::showHideControls()
|
|||||||
void MainWindow::addObjectFromScene()
|
void MainWindow::addObjectFromScene()
|
||||||
{
|
{
|
||||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||||
|
disconnect(camera_, SIGNAL(finished()), this, SLOT(stopProcessing()));
|
||||||
AddObjectDialog * dialog;
|
AddObjectDialog * dialog;
|
||||||
bool resumeCamera = camera_->isRunning();
|
bool resumeCamera = camera_->isRunning();
|
||||||
if(camera_->isRunning() || sceneImage_.empty())
|
if(camera_->isRunning() || sceneImage_.empty())
|
||||||
@ -529,6 +531,7 @@ void MainWindow::addObjectFromScene()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)), Qt::UniqueConnection);
|
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)), Qt::UniqueConnection);
|
||||||
|
connect(camera_, SIGNAL(finished()), this, SLOT(stopProcessing()), Qt::UniqueConnection);
|
||||||
if(!sceneImage_.empty())
|
if(!sceneImage_.empty())
|
||||||
{
|
{
|
||||||
this->update(sceneImage_);
|
this->update(sceneImage_);
|
||||||
@ -779,6 +782,7 @@ void MainWindow::startProcessing()
|
|||||||
if(camera_->start())
|
if(camera_->start())
|
||||||
{
|
{
|
||||||
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)), Qt::UniqueConnection);
|
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)), Qt::UniqueConnection);
|
||||||
|
connect(camera_, SIGNAL(finished()), this, SLOT(stopProcessing()), Qt::UniqueConnection);
|
||||||
ui_->actionStop_camera->setEnabled(true);
|
ui_->actionStop_camera->setEnabled(true);
|
||||||
ui_->actionPause_camera->setEnabled(true);
|
ui_->actionPause_camera->setEnabled(true);
|
||||||
ui_->actionStart_camera->setEnabled(false);
|
ui_->actionStart_camera->setEnabled(false);
|
||||||
@ -835,6 +839,7 @@ void MainWindow::stopProcessing()
|
|||||||
if(camera_)
|
if(camera_)
|
||||||
{
|
{
|
||||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||||
|
disconnect(camera_, SIGNAL(finished()), this, SLOT(stopProcessing()));
|
||||||
camera_->stop();
|
camera_->stop();
|
||||||
}
|
}
|
||||||
ui_->actionStop_camera->setEnabled(false);
|
ui_->actionStop_camera->setEnabled(false);
|
||||||
@ -901,11 +906,6 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
if(image.empty())
|
if(image.empty())
|
||||||
{
|
{
|
||||||
UWARN("The image received is empty...");
|
UWARN("The image received is empty...");
|
||||||
if(!Settings::getCamera_6useTcpCamera())
|
|
||||||
{
|
|
||||||
UINFO("Stopping the camera...");
|
|
||||||
this->stopProcessing();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sceneImage_ = image.clone();
|
sceneImage_ = image.clone();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user