Fixed PCL extract indices filter workaround for PointNormal type (not defined in current released PCL). Compression: Fixed OpenCV memory leak when converting uncompressed depth image to 32F format.

This commit is contained in:
matlabbe
2018-02-13 12:36:23 -05:00
parent 4c0a612ab5
commit c6e5f1c9f8
6 changed files with 32 additions and 25 deletions

View File

@@ -125,7 +125,7 @@ public:
double stamp = 0.0,
const cv::Mat & userData = cv::Mat());
virtual ~SensorData() {}
virtual ~SensorData();
bool isValid() const {
return !(_id == 0 &&

View File

@@ -564,10 +564,11 @@ pcl::IndicesPtr RTABMAP_EXP extractIndices(
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative);
pcl::IndicesPtr RTABMAP_EXP extractIndices(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative);
// PCL default lacks of pcl::PointNormal type support
//pcl::IndicesPtr RTABMAP_EXP extractIndices(
// const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
// const pcl::IndicesPtr & indices,
// bool negative);
pcl::IndicesPtr RTABMAP_EXP extractIndices(
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
const pcl::IndicesPtr & indices,
@@ -587,11 +588,12 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_EXP extractIndices(
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized);
pcl::PointCloud<pcl::PointNormal>::Ptr RTABMAP_EXP extractIndices(
const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,
bool negative,
bool keepOrganized);
// PCL default lacks of pcl::PointNormal type support
//pcl::PointCloud<pcl::PointNormal>::Ptr RTABMAP_EXP extractIndices(
// const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
// const pcl::IndicesPtr & indices,
// bool negative,
// bool keepOrganized);
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_EXP extractIndices(
const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
const pcl::IndicesPtr & indices,

View File

@@ -139,7 +139,11 @@ cv::Mat uncompressImage(const cv::Mat & bytes)
#endif
if(image.type() == CV_8UC4)
{
image = cv::Mat(image.size(), CV_32FC1, image.data).clone();
// Using clone() or copyTo() caused a memory leak !?!?
// image = cv::Mat(image.size(), CV_32FC1, image.data).clone();
cv::Mat depth(image.size(), CV_32FC1);
memcpy(depth.data, image.data, image.total()*image.elemSize());
image = depth;
}
}
return image;

View File

@@ -277,12 +277,7 @@ void OccupancyGrid::createLocalMap(
// update viewpoint
viewPoint = cv::Point3f(t.x(), t.y(), t.z());
if(scan.channels() == 6)
{
pcl::PointCloud<pcl::PointNormal>::Ptr cloud = util3d::laserScanToPointCloudNormal(scan, t);
createLocalMap<pcl::PointNormal>(cloud, node.getPose(), groundCells, obstacleCells, emptyCells, viewPoint);
}
else if(scan.channels() == 7)
if(scan.channels() == 6 || scan.channels() == 7)
{
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud = util3d::laserScanToPointCloudRGBNormal(scan, t);
createLocalMap<pcl::PointXYZRGBNormal>(cloud, node.getPose(), groundCells, obstacleCells, emptyCells, viewPoint);

View File

@@ -427,6 +427,10 @@ SensorData::SensorData(
}
}
SensorData::~SensorData()
{
}
void SensorData::setUserDataRaw(const cv::Mat & userDataRaw)
{
if(!userDataRaw.empty() && !_userDataRaw.empty())

View File

@@ -1420,10 +1420,11 @@ pcl::IndicesPtr extractIndices(const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud
{
return extractIndicesImpl<pcl::PointXYZ>(cloud, indices, negative);
}
pcl::IndicesPtr extractIndices(const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative)
{
return extractIndicesImpl<pcl::PointNormal>(cloud, indices, negative);
}
// PCL default lacks of pcl::PointNormal type support
//pcl::IndicesPtr extractIndices(const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative)
//{
// return extractIndicesImpl<pcl::PointNormal>(cloud, indices, negative);
//}
pcl::IndicesPtr extractIndices(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative)
{
return extractIndicesImpl<pcl::PointXYZRGB>(cloud, indices, negative);
@@ -1457,10 +1458,11 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr extractIndices(const pcl::PointCloud<pcl:
{
return extractIndicesImpl<pcl::PointXYZRGB>(cloud, indices, negative, keepOrganized);
}
pcl::PointCloud<pcl::PointNormal>::Ptr extractIndices(const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative, bool keepOrganized)
{
return extractIndicesImpl<pcl::PointNormal>(cloud, indices, negative, keepOrganized);
}
// PCL default lacks of pcl::PointNormal type support
//pcl::PointCloud<pcl::PointNormal>::Ptr extractIndices(const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative, bool keepOrganized)
//{
// return extractIndicesImpl<pcl::PointNormal>(cloud, indices, negative, keepOrganized);
//}
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr extractIndices(const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud, const pcl::IndicesPtr & indices, bool negative, bool keepOrganized)
{
return extractIndicesImpl<pcl::PointXYZRGBNormal>(cloud, indices, negative, keepOrganized);