Skip to content

Commit

Permalink
Merge pull request #72 from openhumanoids/mf-minor-collections-fix
Browse files Browse the repository at this point in the history
minor collections fix: have viewer choose the color of the collection
  • Loading branch information
Maurice Fallon authored Jul 4, 2016
2 parents 5c1cc4c + 23ab1c0 commit 5c4435a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pronto-utils/src/pronto_math/pronto_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct obj_cfg{

struct ptcld_cfg{
ptcld_cfg(int id, std::string name, int type, bool reset,
int obj_coll, bool use_rgb, std::vector<float> rgb ):
int obj_coll, int use_rgb, std::vector<float> rgb ):
id(id), name(name), type(type), reset(reset),
obj_coll(obj_coll), use_rgb(use_rgb), rgb(rgb) {}
int id;
Expand All @@ -32,7 +32,7 @@ struct ptcld_cfg{
//int64_t obj_id; // which object in the pose collection is it relative to | was "element_id"
//float rgba[4];

bool use_rgb; // use this single color [0] or use colors in the cloud itself [0]
int use_rgb; // [-1] send no colors and have view pick, [0] use a single color, [-1] use colors in the XYZRGB cloud itself
std::vector <float> rgb; // 3 vals 0->1
// inline specification: http://live.boost.org/doc/libs/1_36_0/libs/assign/doc/index.html
};
Expand Down
28 changes: 21 additions & 7 deletions pronto-utils/src/pronto_vis/pronto_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ void pronto_vis::ptcld_collection_to_lcm(ptcld_cfg pcfg, std::vector< pronto::Po
this_plist->npoints = npts;
// 3.2: colors:
vs_color_t* colors = new vs_color_t[npts];
this_plist->ncolors = npts;
// TODO: this sends the points, but they are not used. Should avoid sending altogether
if (pcfg.use_rgb == -1)
this_plist->ncolors = 0; // have viewer pick the color
else
this_plist->ncolors = npts;
// 3.3: normals:
this_plist->nnormals = 0;
this_plist->normals = NULL;
Expand All @@ -224,7 +228,7 @@ void pronto_vis::ptcld_collection_to_lcm(ptcld_cfg pcfg, std::vector< pronto::Po

float rgba[4];
for(size_t j=0; j<npts; j++) { //Nransac
if ( pcfg.use_rgb){// use the rgb value
if ( pcfg.use_rgb == 1){// use the rgb value
rgba[0] = pcfg.rgb[0];
rgba[1] = pcfg.rgb[1];
rgba[2] = pcfg.rgb[2];
Expand Down Expand Up @@ -287,7 +291,12 @@ void pronto_vis::ptcld_to_lcm(ptcld_cfg pcfg, pronto::PointCloud &cloud, int64_t
this_plist->npoints = npts;
// 3.2: colors:
vs_color_t* colors = new vs_color_t[npts];
this_plist->ncolors = npts;

// TODO: this sends the points, but they are not used. Should avoid sending altogether
if ( pcfg.use_rgb == -1 )
this_plist->ncolors = 0; // have the viewer choose the colors.
else
this_plist->ncolors = npts;
// 3.3: normals:
this_plist->nnormals = 0;
this_plist->normals = NULL;
Expand All @@ -297,7 +306,7 @@ void pronto_vis::ptcld_to_lcm(ptcld_cfg pcfg, pronto::PointCloud &cloud, int64_t

float rgba[4];
for(int j=0; j<npts; j++) { //Nransac
if ( pcfg.use_rgb){// use the rgb value
if ( pcfg.use_rgb == 1){// use the rgb value
//rgba[3] = ptcoll_cfg.rgba[3];
rgba[0] = pcfg.rgb[0];
rgba[1] = pcfg.rgb[1];
Expand Down Expand Up @@ -541,10 +550,15 @@ void pronto_vis::mesh_to_lcm(ptcld_cfg pcfg, pcl::PolygonMesh::Ptr mesh,
points->npointids = 0;
points->pointids = NULL;

points->ncolors = N_points;
vs_color_t* colors = new vs_color_t[N_points];
points->npoints = N_points;
// TODO: this sends the points, but they are not used. Should avoid sending altogether
if ( pcfg.use_rgb == -1)
points->ncolors = 0;
else
points->ncolors = N_points;

vs_point3d_t* entries = new vs_point3d_t[N_points];
points->npoints = N_points;

points->id = i; // ... still i - not k
points->collection = pcfg.obj_coll;//PoseCollID;//collection.objectCollectionId();
Expand All @@ -557,7 +571,7 @@ void pronto_vis::mesh_to_lcm(ptcld_cfg pcfg, pcl::PolygonMesh::Ptr mesh,
entries[j].y =(float) tmp(1);
entries[j].z =(float) tmp(2);
// r,g,b: input is ints 0->255, opengl wants floats 0->1
if ( pcfg.use_rgb){// use the rgb value
if ( pcfg.use_rgb == 1){// use the rgb value
rgba[0] = pcfg.rgb[0];
rgba[1] = pcfg.rgb[1];
rgba[2] = pcfg.rgb[2];
Expand Down

0 comments on commit 5c4435a

Please sign in to comment.