Fixed camera openni-PCL stopping after only one grab

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1390 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-06-16 18:07:51 +00:00
parent 9c20c20300
commit f6ce17012a
3 changed files with 18 additions and 8 deletions

View File

@@ -94,7 +94,8 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant
CameraOpenni::CameraOpenni(const std::string & deviceId, float imageRate, const Transform & localTransform) : CameraOpenni::CameraOpenni(const std::string & deviceId, float imageRate, const Transform & localTransform) :
CameraRGBD(imageRate, localTransform), CameraRGBD(imageRate, localTransform),
interface_(0), interface_(0),
deviceId_(deviceId) deviceId_(deviceId),
depthConstant_(0.0f)
{ {
} }
@@ -122,6 +123,8 @@ void CameraOpenni::image_cb (
{ {
UScopeMutex s(dataMutex_); UScopeMutex s(dataMutex_);
bool notify = rgb_.empty();
cv::Mat rgbFrame(rgb->getHeight(), rgb->getWidth(), CV_8UC3); cv::Mat rgbFrame(rgb->getHeight(), rgb->getWidth(), CV_8UC3);
rgb->fillRGB(rgb->getWidth(), rgb->getHeight(), rgbFrame.data); rgb->fillRGB(rgb->getWidth(), rgb->getHeight(), rgbFrame.data);
cv::cvtColor(rgbFrame, rgb_, CV_RGB2BGR); cv::cvtColor(rgbFrame, rgb_, CV_RGB2BGR);
@@ -131,7 +134,7 @@ void CameraOpenni::image_cb (
depthConstant_ = constant; depthConstant_ = constant;
if(dataReady_.value() <= 0) if(notify)
{ {
dataReady_.release(); dataReady_.release();
} }
@@ -184,7 +187,7 @@ void CameraOpenni::captureImage(cv::Mat & rgb, cv::Mat & depth, float & depthCon
depth_ = cv::Mat(); depth_ = cv::Mat();
rgb_ = cv::Mat(); rgb_ = cv::Mat();
depthConstant_ = 0; depthConstant_ = 0.0f;
} }
} }

View File

@@ -122,7 +122,14 @@ void CameraThread::mainLoop()
} }
else if(!this->isKilled()) else if(!this->isKilled())
{ {
UDEBUG("no more images..."); if(_cameraRGBD)
{
UERROR("Retrieved data is empty! Stopping the camera...");
}
else
{
UWARN("no more images...");
}
this->kill(); this->kill();
this->post(new CameraEvent()); this->post(new CameraEvent());
} }

View File

@@ -2856,7 +2856,7 @@ void MainWindow::savePointClouds()
_initProgressDialog->setAutoClose(true, 1); _initProgressDialog->setAutoClose(true, 1);
_initProgressDialog->resetProgress(); _initProgressDialog->resetProgress();
_initProgressDialog->show(); _initProgressDialog->show();
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()*2+1); _initProgressDialog->setMaximumSteps(int(_currentPosesMap.size())*2+1);
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds; std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds;
if(button == QMessageBox::Yes) if(button == QMessageBox::Yes)
@@ -2898,7 +2898,7 @@ void MainWindow::saveMeshes()
_initProgressDialog->setAutoClose(true, 1); _initProgressDialog->setAutoClose(true, 1);
_initProgressDialog->resetProgress(); _initProgressDialog->resetProgress();
_initProgressDialog->show(); _initProgressDialog->show();
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()*2+1); _initProgressDialog->setMaximumSteps(int(_currentPosesMap.size())*2+1);
std::map<int, pcl::PolygonMesh::Ptr> meshes; std::map<int, pcl::PolygonMesh::Ptr> meshes;
if(button == QMessageBox::Yes) if(button == QMessageBox::Yes)
@@ -2956,7 +2956,7 @@ void MainWindow::viewPointClouds()
_initProgressDialog->setAutoClose(true, 1); _initProgressDialog->setAutoClose(true, 1);
_initProgressDialog->resetProgress(); _initProgressDialog->resetProgress();
_initProgressDialog->show(); _initProgressDialog->show();
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()+1); _initProgressDialog->setMaximumSteps(int(_currentPosesMap.size())+1);
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds; std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds;
if(button == QMessageBox::Yes) if(button == QMessageBox::Yes)
@@ -3032,7 +3032,7 @@ void MainWindow::viewMeshes()
_initProgressDialog->setAutoClose(true, 1); _initProgressDialog->setAutoClose(true, 1);
_initProgressDialog->resetProgress(); _initProgressDialog->resetProgress();
_initProgressDialog->show(); _initProgressDialog->show();
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()+1); _initProgressDialog->setMaximumSteps(int(_currentPosesMap.size())+1);
std::map<int, pcl::PolygonMesh::Ptr> meshes; std::map<int, pcl::PolygonMesh::Ptr> meshes;
if(button == QMessageBox::Yes) if(button == QMessageBox::Yes)