fixed #648 (build error without OctoMap dependency)

This commit is contained in:
matlabbe
2020-11-30 12:33:08 -05:00
parent 96c1c81e22
commit ee44adeb1f
5 changed files with 56 additions and 55 deletions

View File

@@ -168,9 +168,6 @@ class RtabmapColorOcTree : public octomap::OccupancyOcTreeBase <RtabmapColorOcTr
}; };
class RTABMAP_EXP OctoMap { class RTABMAP_EXP OctoMap {
public:
static void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v);
public: public:
OctoMap(const ParametersMap & parameters); OctoMap(const ParametersMap & parameters);
OctoMap(float cellSize = 0.1f, float occupancyThr = 0.5f, bool fullUpdate = false, float updateError=0.01f); OctoMap(float cellSize = 0.1f, float occupancyThr = 0.5f, bool fullUpdate = false, float updateError=0.01f);

View File

@@ -154,6 +154,8 @@ cv::Mat RTABMAP_EXP brightnessAndContrastAuto(
cv::Mat RTABMAP_EXP exposureFusion( cv::Mat RTABMAP_EXP exposureFusion(
const std::vector<cv::Mat> & images); const std::vector<cv::Mat> & images);
void RTABMAP_EXP HSVtoRGB( float *r, float *g, float *b, float h, float s, float v );
} // namespace util3d } // namespace util3d
} // namespace rtabmap } // namespace rtabmap

View File

@@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rtabmap/core/util3d_transforms.h> #include <rtabmap/core/util3d_transforms.h>
#include <rtabmap/core/util3d_filtering.h> #include <rtabmap/core/util3d_filtering.h>
#include <rtabmap/core/util3d_mapping.h> #include <rtabmap/core/util3d_mapping.h>
#include <rtabmap/core/util2d.h>
#include <pcl/common/transforms.h> #include <pcl/common/transforms.h>
namespace rtabmap { namespace rtabmap {
@@ -886,55 +887,6 @@ void OctoMap::updateMinMax(const octomap::point3d & point)
} }
} }
void OctoMap::HSVtoRGB( float *r, float *g, float *b, float h, float s, float v )
{
int i;
float f, p, q, t;
if( s == 0 ) {
// achromatic (grey)
*r = *g = *b = v;
return;
}
h /= 60; // sector 0 to 5
i = floor( h );
f = h - i; // factorial part of h
p = v * ( 1 - s );
q = v * ( 1 - s * f );
t = v * ( 1 - s * ( 1 - f ) );
switch( i ) {
case 0:
*r = v;
*g = t;
*b = p;
break;
case 1:
*r = q;
*g = v;
*b = p;
break;
case 2:
*r = p;
*g = v;
*b = t;
break;
case 3:
*r = p;
*g = q;
*b = v;
break;
case 4:
*r = t;
*g = p;
*b = v;
break;
default: // case 5:
*r = v;
*g = p;
*b = q;
break;
}
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr OctoMap::createCloud( pcl::PointCloud<pcl::PointXYZRGB>::Ptr OctoMap::createCloud(
unsigned int treeDepth, unsigned int treeDepth,
std::vector<int> * obstacleIndices, std::vector<int> * obstacleIndices,
@@ -1003,7 +955,7 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr OctoMap::createCloud(
// Gradiant color on z axis // Gradiant color on z axis
float H = (maxZ - pt.z())*299.0f/(maxZ-minZ); float H = (maxZ - pt.z())*299.0f/(maxZ-minZ);
float r,g,b; float r,g,b;
HSVtoRGB(&r, &g, &b, H, 1, 1); util2d::HSVtoRGB(&r, &g, &b, H, 1, 1);
(*cloud)[oi].r = r*255.0f; (*cloud)[oi].r = r*255.0f;
(*cloud)[oi].g = g*255.0f; (*cloud)[oi].g = g*255.0f;
(*cloud)[oi].b = b*255.0f; (*cloud)[oi].b = b*255.0f;

View File

@@ -2044,6 +2044,55 @@ cv::Mat exposureFusion(const std::vector<cv::Mat> & images)
return fusion; return fusion;
} }
void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v )
{
int i;
float f, p, q, t;
if( s == 0 ) {
// achromatic (grey)
*r = *g = *b = v;
return;
}
h /= 60; // sector 0 to 5
i = floor( h );
f = h - i; // factorial part of h
p = v * ( 1 - s );
q = v * ( 1 - s * f );
t = v * ( 1 - s * ( 1 - f ) );
switch( i ) {
case 0:
*r = v;
*g = t;
*b = p;
break;
case 1:
*r = q;
*g = v;
*b = p;
break;
case 2:
*r = p;
*g = v;
*b = t;
break;
case 3:
*r = p;
*g = q;
*b = v;
break;
case 4:
*r = t;
*g = p;
*b = v;
break;
default: // case 5:
*r = v;
*g = p;
*b = q;
break;
}
}
} }
} }

View File

@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rtabmap/utilite/UMath.h> #include <rtabmap/utilite/UMath.h>
#include <rtabmap/utilite/UConversion.h> #include <rtabmap/utilite/UConversion.h>
#include <rtabmap/utilite/UStl.h> #include <rtabmap/utilite/UStl.h>
#include <rtabmap/core/util2d.h>
#include <pcl/visualization/pcl_visualizer.h> #include <pcl/visualization/pcl_visualizer.h>
#include <pcl/common/transforms.h> #include <pcl/common/transforms.h>
#include <QMenu> #include <QMenu>
@@ -656,7 +657,7 @@ public:
else if(colormap_ == 2) else if(colormap_ == 2)
{ {
float r,g,b; float r,g,b;
OctoMap::HSVtoRGB(&r, &g, &b, colors[k*3+0]*299.0f/255.0f, 1.0f, 1.0f); util2d::HSVtoRGB(&r, &g, &b, colors[k*3+0]*299.0f/255.0f, 1.0f, 1.0f);
colors[k*3+0] = r*255.0f; colors[k*3+0] = r*255.0f;
colors[k*3+1] = g*255.0f; colors[k*3+1] = g*255.0f;
colors[k*3+2] = b*255.0f; colors[k*3+2] = b*255.0f;
@@ -1207,7 +1208,7 @@ bool CloudViewer::addOctomap(const OctoMap * octomap, unsigned int treeDepth, bo
// Gradiant color on z axis // Gradiant color on z axis
float H = (maxZ - pt.z())*299.0f/(maxZ-minZ); float H = (maxZ - pt.z())*299.0f/(maxZ-minZ);
float r,g,b; float r,g,b;
OctoMap::HSVtoRGB(&r, &g, &b, H, 1, 1); util2d::HSVtoRGB(&r, &g, &b, H, 1, 1);
pixel[0] = r*255.0f; pixel[0] = r*255.0f;
pixel[1] = g*255.0f; pixel[1] = g*255.0f;
pixel[2] = b*255.0f; pixel[2] = b*255.0f;