mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 08:47:45 +08:00
refactored how freenect ready is done
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1391 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
+13
-22
@@ -568,22 +568,12 @@ class FreenectDevice : public UThread {
|
|||||||
if(this->isRunning())
|
if(this->isRunning())
|
||||||
{
|
{
|
||||||
dataReady_.acquire();
|
dataReady_.acquire();
|
||||||
{
|
|
||||||
UScopeMutex s1(rgbMutex_);
|
UScopeMutex s(dataMutex_);
|
||||||
if(!rgbLastFrame_.empty())
|
rgb = rgbLastFrame_;
|
||||||
{
|
depth = depthLastFrame_;
|
||||||
rgb = rgbLastFrame_;
|
rgbLastFrame_ = cv::Mat();
|
||||||
rgbLastFrame_ = cv::Mat();
|
depthLastFrame_= cv::Mat();
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
UScopeMutex s2(depthMutex_);
|
|
||||||
if(!depthLastFrame_.empty())
|
|
||||||
{
|
|
||||||
depth = depthLastFrame_;
|
|
||||||
depthLastFrame_= cv::Mat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,9 +582,10 @@ private:
|
|||||||
void VideoCallback(void* rgb)
|
void VideoCallback(void* rgb)
|
||||||
{
|
{
|
||||||
UASSERT(rgbBuffer_.data == rgb);
|
UASSERT(rgbBuffer_.data == rgb);
|
||||||
UScopeMutex s1(rgbMutex_);
|
UScopeMutex s(dataMutex_);
|
||||||
|
bool notify = rgbLastFrame_.empty();
|
||||||
cv::cvtColor(rgbBuffer_, rgbLastFrame_, CV_RGB2BGR);
|
cv::cvtColor(rgbBuffer_, rgbLastFrame_, CV_RGB2BGR);
|
||||||
if(!depthLastFrame_.empty() && dataReady_.value() <= 0)
|
if(!depthLastFrame_.empty() && notify)
|
||||||
{
|
{
|
||||||
dataReady_.release();
|
dataReady_.release();
|
||||||
}
|
}
|
||||||
@@ -604,9 +595,10 @@ private:
|
|||||||
void DepthCallback(void* depth)
|
void DepthCallback(void* depth)
|
||||||
{
|
{
|
||||||
UASSERT(depthBuffer_.data == depth);
|
UASSERT(depthBuffer_.data == depth);
|
||||||
UScopeMutex s2(depthMutex_);
|
UScopeMutex s(dataMutex_);
|
||||||
|
bool notify = depthLastFrame_.empty();
|
||||||
depthLastFrame_ = depthBuffer_.clone();
|
depthLastFrame_ = depthBuffer_.clone();
|
||||||
if(!rgbLastFrame_.empty() && dataReady_.value() <= 0)
|
if(!rgbLastFrame_.empty() && notify)
|
||||||
{
|
{
|
||||||
dataReady_.release();
|
dataReady_.release();
|
||||||
}
|
}
|
||||||
@@ -669,8 +661,7 @@ private:
|
|||||||
freenect_device * device_;
|
freenect_device * device_;
|
||||||
cv::Mat depthBuffer_;
|
cv::Mat depthBuffer_;
|
||||||
cv::Mat rgbBuffer_;
|
cv::Mat rgbBuffer_;
|
||||||
UMutex depthMutex_;
|
UMutex dataMutex_;
|
||||||
UMutex rgbMutex_;
|
|
||||||
cv::Mat depthLastFrame_;
|
cv::Mat depthLastFrame_;
|
||||||
cv::Mat rgbLastFrame_;
|
cv::Mat rgbLastFrame_;
|
||||||
float depthFocal_;
|
float depthFocal_;
|
||||||
|
|||||||
Reference in New Issue
Block a user