-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process additional properties in source point cloud for mesh generation #57
Comments
Hi Ahmad,
Unfortunately, there's no current way to have the vertices interpolate discrete data from the input points. (The current implementation only supports interpolating data that can be averaged together.)
…-- Misha
On April 25, 2018 5:36:18 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
Hello,
I have some colored point clouds and I use this code to generate the
mesh using the PoissonRecon and SurfaceTrimming codes.
I also have some material ids in the point cloud. For example each
point in the cloud has, position(x,y,z), color(r,g,b),
normals(nx,ny,nz) and Material ID(m_id). After the reconstruction I
surely lose the material ID. Could you please tell me what would be the
best way to keep the material id even after I construct the mesh?
It would be very useful because, I can get the material id while the
data is in image level and definitely can use a mapping to pass this
information till point cloud. If I could pass it though mesh generation
it would allow me having material maps in UV.
Thanks,
Ahmad
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#57
|
Thank for replying so fast. I could possibly change the Material id to some properties such as roughness value (0 to 1) or glossiness etc. which can be interpolated. In that case the point would be represented as position(x,y,z), color(r,g,b), normals(nx,ny,nz) and roughness_val. Is it doable in that case? If yes, could you please give me an idea how. Thanks, |
Yep. If you change the properties to something averageable, that should be easy to interpolate. I would have to look at the code, but I think it would be a couple of lines to change.
…On April 25, 2018 6:05:24 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
Thank for replying so fast. I could possibly change the Material id to
some properties such as roughness value (0 to 1) or glossiness etc.
which can be interpolated. In that case the point would be represented
as position(x,y,z), color(r,g,b), normals(nx,ny,nz) and roughness_val.
Is it doable in that case? If yes, could you please give me an idea
how.
Thanks,
Ahmad
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
That'll be amazing. Looking forward to your suggestion on where to make that change. Thanks a lot for the help. |
OK. So here is where you would need to make the changes.
1. In PointStreamData.h you can find definitions for NormalAndColor and NormalAndColorInfo. You would need to create your own versions, e.g. NormalColorAndRoughness and NormalColorAndRoughnessInfo.
a. NormalColorAndRoughness:
This is pretty simple – it should define what type of data the class stores, as well as how to do weighted averaging. (You would need to add member data “Real roughness” and modify the binary operators.
b. NormalColorAndRoughnessInfo:
This is a bit trickier – it should define how this data is read in from and written out to a file.
i. [read/write][ASCII/Binary]: should be reasonably straightforward.
ii. ValidPlyProperties: ensures that the expected ply parameters are defined
iii. VertexSetter::SetValue: defines how to set the weight in a Vertex object
iv. VertexSetter::SetData: defines how to set the normal/color/roughness in a Vertex object
v. ProcessDataWithConfidence/ProcessData: You should keep these as is, as confidence information is likely to be encoded in the magnitude of the normal
vi. Transform: You should keep this as is since applying a transformation should not affect the roughness component
2. In PoissonRecon.cpp, around line 667, you need to do two things:
a. Replace “NormalAndColorInfo” with “NormalColorAndRoughnessInfo” to indicate the type of data you will be reading in from the file
b. Replace FullPlyVertex with some other Vertex class that stores normal, color, and roughness (and is matched to the definitions of VertexSetter::SetValue and VertexSetter::SetData above
Hope this helps. Let me know if you have trouble and can I try to help guide you along.
…-- Misha
From: ahmadhasan2k8 <notifications@github.com>
Sent: Wednesday, April 25, 2018 6:18 PM
To: mkazhdan/PoissonRecon <PoissonRecon@noreply.github.com>
Cc: mkazhdan <misha@cs.jhu.edu>; Comment <comment@noreply.github.com>
Subject: Re: [mkazhdan/PoissonRecon] Process additional properties in source point cloud for mesh generation (#57)
That'll be amazing. Looking forward to your suggestion on where to make that change. Thanks a lot for the help.
—
You are receiving this because you commented.
Reply to this email directly, <#57 (comment)> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/AKXc5VS4XmNMaRc2kD5tXdVV4NLchH9Yks5tsPYWgaJpZM4TkMbc> mute the thread.
|
Thanks for the detailed information. I will try it out. I'll let you know how it goes. |
Sorry about the very large reply. But I'm having trouble getting the correct output and I'm not sure where should I fix. So, I followed your comment and made these changes. I'm also not sure if it's because the roughness value is only one number and the dimension 3 is appropriate here or not. PointStreamData.h
ply.h
PoissonRecon.cpp
So, with these put in place it compiles and runs but the output is somewhat like this: out.ply
As you can see, it has a property r with the red value replicated at the end. I was expecting rg with some other values. Could you please and take a look and tell me where am I going wrong? Thanks, |
The following line in your code is wrong:
static const int RoughnessOffset = ColorOffset + RoughnessCount;
It should be:
static const int RoughnessOffset = ColorOffset + ColorCount;
(The roughness offset is obtained by starting with the color offset and advancing by the number of color coordinates.)
…-- Misha
On May 1, 2018 7:35:36 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
Sorry about the very large reply. But I'm having trouble getting the
correct output and I'm not sure where should I fix. So, I followed your
comment and made these changes. I'm also not sure if it's because the
roughness value is only one number and the dimension 3 is appropriate
here or not.
PointStreamData.h
```
template <class Real, int Dim>
struct NormalColorAndRoughness
{
Point<Real, Dim> normal;
Color<Real> color;
Real roughness;
NormalColorAndRoughness(void)
{
;
}
NormalColorAndRoughness(Point<Real, Dim> n, Color<Real> c, Real rg)
: normal(n), color(c), roughness(rg)
{
;
}
NormalColorAndRoughness& operator+=(const NormalColorAndRoughness& p)
{
color += p.color, normal += p.normal, roughness += p.roughness;
return *this;
}
NormalColorAndRoughness& operator-=(const NormalColorAndRoughness& p)
{
color -= p.color, normal -= p.normal, roughness -= p.roughness;
return *this;
}
NormalColorAndRoughness& operator*=(Real s)
{
color *= s, normal *= s, roughness *= s;
return *this;
}
NormalColorAndRoughness& operator/=(Real s)
{
color /= s, normal /= s, roughness /= s;
return *this;
}
NormalColorAndRoughness operator+(const NormalColorAndRoughness& p)
const
{
return NormalColorAndRoughness(
normal + p.normal, color + p.color, roughness + p.roughness);
}
NormalColorAndRoughness operator-(const NormalColorAndRoughness& p)
const
{
return NormalColorAndRoughness(
normal - p.normal, color - p.color, roughness - p.roughness);
}
NormalColorAndRoughness operator*(Real s) const
{
return NormalColorAndRoughness(normal * s, color * s, roughness * s);
}
NormalColorAndRoughness operator/(Real s) const
{
return NormalColorAndRoughness(normal / s, color / s, roughness / s);
}
};
template <class Real, int Dim>
struct NormalColorAndRoughnessInfo
{
typedef NormalColorAndRoughness<Real, Dim> Type;
static Type ReadASCII(FILE* fp)
{
float n[3];
unsigned char c[3];
float rg;
if (fscanf(fp,
" %f %f %f %c %c %c %f ",
&n[0],
&n[1],
&n[2],
&c[0],
&c[1],
&c[2],
&rg) != 7)
fprintf(stderr, "[ERROR] Failed to read normal, color and roughness
\n"),
exit(0);
return Type(Point<Real, Dim>(n[0], n[1], n[2]),
Color<Real>((Real)c[0], (Real)c[1], (Real)c[2]),
(Real)rg);
};
static bool ReadBinary(FILE* fp, Point<Real, Dim>& p, Type& d)
{
struct TypeOnDisk
{
Point<float, Dim> point;
Point<float, Dim> normal;
unsigned char color[3];
float rg;
};
TypeOnDisk t;
if (fread(&t, sizeof(TypeOnDisk), 1, fp) != 1) return false;
p = Point<Real, Dim>(t.point);
d.normal = Point<Real, Dim>(t.normal);
d.roughness = t.rg;
for (int c = 0; c < 3; c++) d.color[c] = (Real)t.color[c];
return true;
}
static void WriteASCII(FILE* fp, const Type& d)
{
unsigned char c[3];
SetColorValues(d.color, c);
fprintf(fp,
" %f %f %f %d %d %d %f ",
d.normal[0],
d.normal[1],
d.normal[2],
c[0],
c[1],
c[2],
d.roughness);
};
static void WriteBinary(FILE* fp, const Point<Real, Dim>& p, const
Type& d)
{
struct TypeOnDisk
{
Point<float, Dim> point;
Point<float, Dim> normal;
unsigned char color[3];
float rg;
};
TypeOnDisk t;
t.point = Point<float, Dim>(p), t.normal = Point<float, Dim>(d.normal);
SetColorValues(d.color, t.color);
t.roughness = d.rg;
fwrite(&t, sizeof(TypeOnDisk), 1, fp);
}
static bool ValidPlyProperties(const bool* props)
{
return (props[0] && props[1] && props[2]) &&
((props[3] || props[6]) && (props[4] || props[7]) &&
(props[5] || props[8]) && props[9]);
}
const static PlyProperty PlyProperties[];
const static int PlyPropertyNum = 10;
template <class Vertex>
struct VertexSetter
{
static void SetValue(Vertex& v, Real w)
{
}
static void SetData(Vertex& v, const Type& nc)
{
}
};
template <bool HasNormal, bool HasValue, bool HasColor, bool
HasRoughness>
struct VertexSetter<PlyVertexWithMaterial<float,
Dim,
HasNormal,
HasValue,
HasColor,
HasRoughness> >
{
typedef PlyVertexWithMaterial<float,
Dim,
HasNormal,
HasValue,
HasColor,
HasRoughness>
Vertex;
static void SetValue(Vertex& v, Real w)
{
if (HasValue) v.value() = (float)w;
}
static void SetData(Vertex& v, const Type& nc)
{
if (HasNormal) v.normal() = Point<Real, Dim>(nc.normal);
if (HasColor) SetColorValues(nc.color, v.color());
if (HasRoughness) v.roughness() = nc.roughness;
}
};
static Real ProcessDataWithConfidence(const Point<Real, Dim>& p, Type&
data)
{
Real l = (Real)Length(data.normal);
if (!l || l != l) return (Real)-1.;
return l;
}
static Real ProcessData(const Point<Real, Dim>& p, Type& data)
{
Real l = (Real)Length(data.normal);
if (!l || l != l) return (Real)-1.;
data.normal /= l;
return (Real)1.;
}
struct Transform
{
Transform(const XForm<Real, Dim + 1>& xForm) : _pointXForm(xForm)
{
for (int i = 0; i < Dim; i++)
for (int j = 0; j < Dim; j++) _normalXForm(i, j) = _pointXForm(i, j);
_normalXForm = _normalXForm.transpose().inverse();
_normalXForm /= (Real)pow(fabs(_normalXForm.determinant()), 1. / Dim);
}
void operator()(Point<Real, Dim>& p, Type& nc) const
{
p = _pointXForm * p, nc.normal = _normalXForm * nc.normal;
}
protected:
XForm<Real, Dim + 1> _pointXForm;
XForm<Real, Dim> _normalXForm;
};
};
template <>
const PlyProperty NormalColorAndRoughnessInfo<float,
3>::PlyProperties[] = {
{"nx",
PLY_FLOAT,
PLY_FLOAT,
int(offsetof(Type, normal.coords[0])),
0,
0,
0,
0},
{"ny",
PLY_FLOAT,
PLY_FLOAT,
int(offsetof(Type, normal.coords[1])),
0,
0,
0,
0},
{"nz",
PLY_FLOAT,
PLY_FLOAT,
int(offsetof(Type, normal.coords[2])),
0,
0,
0,
0},
{"r",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[0])),
0,
0,
0,
0},
{"g",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[1])),
0,
0,
0,
0},
{"b",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[2])),
0,
0,
0,
0},
{"red",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[0])),
0,
0,
0,
0},
{"green",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[1])),
0,
0,
0,
0},
{"blue",
PLY_UCHAR,
PLY_FLOAT,
int(offsetof(Type, color.coords[2])),
0,
0,
0,
0},
{"rg", PLY_FLOAT, PLY_FLOAT, int(offsetof(Type, roughness)), 0, 0, 0,
0}};
template <>
const PlyProperty NormalColorAndRoughnessInfo<double,
3>::PlyProperties[] = {
{"nx",
PLY_FLOAT,
PLY_DOUBLE,
int(offsetof(Type, normal.coords[0])),
0,
0,
0,
0},
{"ny",
PLY_FLOAT,
PLY_DOUBLE,
int(offsetof(Type, normal.coords[1])),
0,
0,
0,
0},
{"nz",
PLY_FLOAT,
PLY_DOUBLE,
int(offsetof(Type, normal.coords[2])),
0,
0,
0,
0},
{"r",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[0])),
0,
0,
0,
0},
{"g",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[1])),
0,
0,
0,
0},
{"b",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[2])),
0,
0,
0,
0},
{"red",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[0])),
0,
0,
0,
0},
{"green",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[1])),
0,
0,
0,
0},
{"blue",
PLY_UCHAR,
PLY_DOUBLE,
int(offsetof(Type, color.coords[2])),
0,
0,
0,
0},
{"rg", PLY_FLOAT, PLY_FLOAT, int(offsetof(Type, roughness)), 0, 0, 0,
0}};
```
ply.h
```
///////////////////
// PlyVertWithMaterial //
///////////////////
template <class _Real,
int Dim,
bool HasNormal,
bool HasValue,
bool HasColor,
bool HasRoughness>
class PlyVertexWithMaterial
{
public:
typedef _Real Real;
protected:
static PlyProperty _Properties[];
static const int _NormalSize = HasNormal ? sizeof(Point<Real, Dim>)
: 0;
static const int _ValueSize = HasValue ? sizeof(Real) : 0;
static const int _ColorSize = HasColor ? sizeof(RGBColor) : 0;
static const int _RoughnessSize = HasRoughness ? sizeof(Real) : 0;
static const int _Size =
_NormalSize + _ValueSize + _ColorSize + _RoughnessSize;
static const int _NormalOffset = 0;
static const int _ValueOffset = _NormalOffset + _NormalSize;
static const int _ColorOffset = _ValueOffset + _ValueSize;
static const int _RoughnessOffset = _ColorOffset + _RoughnessSize;
char _vertexData[_Size == 0 ? 1 : _Size];
public:
struct _PlyVertexWithMaterial
{
static const int PointCount = Dim;
static const int NormalCount = (HasNormal ? Dim : 0);
static const int ValueCount = (HasValue ? 1 : 0);
static const int ColorCount = (HasColor ? 3 : 0);
static const int RoughnessCount = (HasRoughness ? 1 : 0);
static const int Count =
NormalCount + ValueCount + ColorCount + RoughnessCount;
static const int NormalOffset = 0;
static const int ValueOffset = NormalOffset + NormalCount;
static const int ColorOffset = ValueOffset + ValueCount;
static const int RoughnessOffset = ColorOffset + RoughnessCount;
Point<Real, Count == 0 ? 1 : Count> vertexData;
Point<Real, Dim> point;
Point<Real, Dim> &normal(void)
{
return *((Point<Real, Dim> *)(&vertexData[0] + NormalOffset));
}
Real &value(void)
{
return *((Real *)(&vertexData[0] + ValueOffset));
}
Point<Real, 3> &color(void)
{
return *((Point<Real, 3> *)(&vertexData[0] + ColorOffset));
}
Real &roughness(void)
{
return *((Real *)(&vertexData[0] + RoughnessOffset));
}
const Point<Real, Dim> &normal(void) const
{
return *((Point<Real, Dim> *)(&vertexData[0] + NormalOffset));
}
const Real &value(void) const
{
return *((Real *)(&vertexData[0] + ValueOffset));
}
const Point<Real, 3> &color(void) const
{
return *((Point<Real, 3> *)(&vertexData[0] + ColorOffset));
}
const Real &roughness(void) const
{
return *((Real *)(&vertexData[0] + RoughnessOffset));
}
_PlyVertexWithMaterial(void)
{
;
}
_PlyVertexWithMaterial(Point<Real, Dim> p, Point<Real, Count> vData)
{
point = p, vertexData = vData;
}
_PlyVertexWithMaterial(PlyVertexWithMaterial p)
{
point = p.point;
if (HasNormal)
for (int i = 0; i < Dim; i++)
vertexData[NormalOffset + i] = p.normal()[i];
if (HasValue) vertexData[ValueOffset] = p.value();
if (HasRoughness) vertexData[RoughnessOffset] = p.roughness();
if (HasColor)
for (int i = 0; i < 3; i++)
vertexData[ColorOffset + i] = (Real)p.color()[i];
}
operator PlyVertexWithMaterial()
{
PlyVertexWithMaterial p;
p.point = point;
if (HasNormal)
for (int i = 0; i < Dim; i++)
p.normal()[i] = vertexData[NormalOffset + i];
if (HasValue) p.value() = vertexData[ValueOffset];
if (HasRoughness) p.roughness() = vertexData[RoughnessOffset];
if (HasColor)
for (int i = 0; i < 3; i++)
p.color()[i] = (unsigned char)std::max<int>(
0, std::min<int>(255, (int)(vertexData[ColorOffset + i] + 0.5)));
return p;
}
_PlyVertexWithMaterial &operator+=(const _PlyVertexWithMaterial &p)
{
point += p.point, vertexData += p.vertexData;
return *this;
}
_PlyVertexWithMaterial &operator-=(const _PlyVertexWithMaterial &p)
{
point -= p.point, vertexData -= p.vertexData;
return *this;
}
_PlyVertexWithMaterial &operator*=(Real s)
{
point *= s, vertexData *= s;
return *this;
}
_PlyVertexWithMaterial &operator/=(Real s)
{
point /= s, vertexData /= s;
return *this;
}
_PlyVertexWithMaterial operator+(const _PlyVertexWithMaterial &p) const
{
return _PlyVertexWithMaterial(point + p.point, vertexData +
p.vertexData);
}
_PlyVertexWithMaterial operator-(const _PlyVertexWithMaterial &p) const
{
return _PlyVertexWithMaterial(point - p.point, vertexData -
p.vertexData);
}
_PlyVertexWithMaterial operator*(Real s) const
{
return _PlyVertexWithMaterial(point * s, vertexData * s);
}
_PlyVertexWithMaterial operator/(Real s) const
{
return _PlyVertexWithMaterial(point / s, vertexData / s);
}
};
typedef _PlyVertexWithMaterial Wrapper;
const static int ReadComponents = Dim + (HasNormal ? Dim : 0) +
(HasValue ? 1 : 0) +
(HasRoughness ? 1 : 0) + (HasColor ? 6 : 0);
const static int WriteComponents =
Dim + (HasNormal ? Dim : 0) + (HasValue ? 1 : 0) +
(HasRoughness ? 1 : 0) + (HasColor ? 3 : 0);
static PlyProperty *Properties(void);
Point<Real, Dim> point;
Point<Real, Dim> &normal(void)
{
return *((Point<Real, Dim> *)(_vertexData + _NormalOffset));
}
Real &value(void)
{
return *((Real *)(_vertexData + _ValueOffset));
}
RGBColor &color(void)
{
return *((RGBColor *)(_vertexData + _ColorOffset));
}
Real &roughness(void)
{
return *((Real *)(_vertexData + _RoughnessOffset));
}
PlyVertexWithMaterial(void)
{
memset(_vertexData, 0, _Size);
}
PlyVertexWithMaterial(Point<Real, Dim> p) : PlyVertexWithMaterial()
{
point = p;
}
PlyVertexWithMaterial(const PlyVertexWithMaterial &v)
: PlyVertexWithMaterial()
{
point = v.point, memcpy(_vertexData, v._vertexData, _Size);
}
PlyVertexWithMaterial &operator=(const PlyVertexWithMaterial &v)
{
point = v.point, memcpy(_vertexData, v._vertexData, _Size);
return *this;
}
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///
///
///
///
template <class Real,
int Dim,
bool HasNormal,
bool HasValue,
bool HasColor,
bool HasRoughness,
class _Real>
PlyVertexWithMaterial<Real, Dim, HasNormal, HasValue, HasColor,
HasRoughness>
operator*(XForm<_Real, Dim + 1> xForm,
PlyVertexWithMaterial<Real,
Dim,
HasNormal,
HasValue,
HasColor,
HasRoughness> p)
{
PlyVertexWithMaterial<Real, Dim, HasNormal, HasValue, HasColor,
HasRoughness>
_p = p;
_p.point = xForm * p.point;
if (HasNormal) _p.normal() = xForm.inverse().transpose() * p.normal();
return _p;
}
template <class Real,
int Dim,
bool HasNormal,
bool HasValue,
bool HasColor,
bool HasRoughness>
PlyProperty PlyVertexWithMaterial<
Real,
Dim,
HasNormal,
HasValue,
HasColor,
HasRoughness>::_Properties[PlyVertexWithMaterial::ReadComponents];
template <class Real,
int Dim,
bool HasNormal,
bool HasValue,
bool HasColor,
bool HasRoughness>
PlyProperty *
PlyVertexWithMaterial<Real, Dim, HasNormal, HasValue, HasColor,
HasRoughness>::
Properties(void)
{
int idx = 0;
// Primary values (for writing)
int vertexDataOffset = (size_t)(&(((PlyVertexWithMaterial
*)0)->_vertexData));
int pointOffset = (size_t)(&(((PlyVertexWithMaterial
*)0)->point));
for (int d = 0; d < Dim; d++)
_Properties[idx++] = MakePlyProperty(PlyPositionNames[d],
PLYType<Real>(),
PLYType<Real>(),
pointOffset + sizeof(Real) * d);
if (HasNormal)
for (int d = 0; d < Dim; d++)
_Properties[idx++] =
MakePlyProperty(PlyNormalNames[d],
PLYType<Real>(),
PLYType<Real>(),
vertexDataOffset + _NormalOffset + sizeof(Real) * d);
if (HasValue)
_Properties[idx++] = MakePlyProperty(PlyValueNames[0],
PLYType<Real>(),
PLYType<Real>(),
vertexDataOffset + _ValueOffset);
if (HasColor)
for (int c = 0; c < 3; c++)
_Properties[idx++] = MakePlyProperty(
PlyColorNames[c],
PLYType<unsigned char>(),
PLYType<unsigned char>(),
vertexDataOffset + _ColorOffset + sizeof(unsigned char) * c);
// Alternative values (for reading or writing)
if (HasColor)
for (int c = 0; c < 3; c++)
_Properties[idx++] = MakePlyProperty(
PlyAlternateColorNames[c],
PLYType<unsigned char>(),
PLYType<unsigned char>(),
vertexDataOffset + _ColorOffset + sizeof(unsigned char) * c);
if (HasRoughness)
_Properties[idx++] = MakePlyProperty(PlyRoughnessNames[0],
PLYType<Real>(),
PLYType<Real>(),
vertexDataOffset + _RoughnessOffset);
return _Properties;
}
template <class Real, int Dim>
using PlyVertex = PlyVertexWithMaterial<Real, Dim, false, false, false,
false>;
template <class Real, int Dim>
using PlyOrientedVertex =
PlyVertexWithMaterial<Real, Dim, true, false, false, false>;
template <class Real, int Dim>
using PlyValueVertex =
PlyVertexWithMaterial<Real, Dim, false, true, false, false>;
template <class Real, int Dim>
using PlyColorVertex =
PlyVertexWithMaterial<Real, Dim, false, false, true, false>;
template <class Real, int Dim>
using PlyOrientedColorVertex =
PlyVertexWithMaterial<Real, Dim, true, false, true, false>;
template <class Real, int Dim>
using PlyColorAndValueVertex =
PlyVertexWithMaterial<Real, Dim, false, true, true, false>;
template <class Real, int Dim>
using PlyAllVertex = PlyVertexWithMaterial<Real, Dim, true, true, true,
true>;
```
PoissonRecon.cpp
```
#ifdef FAST_COMPILE
static const int Degree = DEFAULT_FEM_DEGREE;
static const BoundaryType BType = DEFAULT_FEM_BOUNDARY;
typedef IsotropicUIntPack<DIMENSION,
FEMDegreeAndBType<Degree, BType>::Signature>
FEMSigs;
fprintf(
stderr,
"[WARNING] Compiled for degree-%d, boundary-%s, %s-precision _only_\n",
Degree,
BoundaryNames[BType],
sizeof(Real) == 4 ? "single" : "double");
if (!PointWeight.set)
PointWeight.value = DefaultPointWeightMultiplier * Degree;
Execute<Real,
NormalColorAndRoughnessInfo<Real, DIMENSION>,
PlyVertexWithMaterial<float, DIMENSION, true, true, true, true> >(
num_options, options, FEMSigs());
#else // !FAST_COMPILE
if (!PointWeight.set)
PointWeight.value = DefaultPointWeightMultiplier * Degree.value;
Execute<DIMENSION,
Real,
NormalColorAndRoughnessInfo<Real, DIMENSION>,
PlyVertexWithMaterial<float, DIMENSION, true, true, true, true> >(
num_options, options);
#endif // FAST_COMPILE
```
So, with these put in place it compiles and runs but the output is
somewhat like this:
out.ply
```
ly
format ascii 1.0
comment *************************************************************
comment *************************************************************
comment ** Running Screened Poisson Reconstruction (Version 10.00) **
comment *************************************************************
comment *************************************************************
comment --degree 2
comment --bType 3
comment --in
/home/hypevr/Poisson/PoissonReconTest/Bin/Linux/eagle.pointsout.ply
comment --depth 10
comment --out /home/hypevr/Poisson/PoissonReconTest/Bin/Linux/out.ply
comment --scale 1.100000
comment --samplesPerNode 1.000000
comment --ascii
comment --pointWeight 4.000000
comment --threads 8
comment --density
comment --iters 8
comment --data 64.000000
comment --colors
comment --tempDir /home/hypevr/Poisson/PoissonRecon/
element vertex 2101267
property float x
property float y
property float z
property float nx
property float ny
property float nz
property float value
property uchar red
property uchar green
property uchar blue
property uchar r
element face 4202399
property list uchar int vertex_indices
end_header
-0.102389 6.97199 -1.96725 0.0270562 -0.0934122 -0.00174214 5.61052 139
134 124 139
0.194098 6.98196 -1.96725 0.0191461 -0.0913949 -0.00700025 5.74068 107
100 96 107
0.34234 7.03687 -1.96725 0.0166826 -0.0884893 -0.00972046 5.48095 120
110 105 120
0.213423 6.98797 -1.96725 0.0189661 -0.09098 -0.00735419 5.7171 109 101
98 109
-0.0282671 6.95023 -1.96725 0.0240336 -0.0926715 -0.0036984 5.74028 127
121 113 127
-0.115223 6.98797 -1.96725 0.0269436 -0.0933955 -0.00186054 5.55044 139
134 124 139
0.400588 7.06209 -1.96725 0.0144693 -0.08759 -0.0108486 5.35833 125 115
109 125
0.268219 7.00708 -1.96725 0.0182788 -0.0898554 -0.008354 5.63402 113
105 101 113
```
As you can see, it has a property r with the red value replicated at
the end. I was expecting rg with some other values. Could you please
and take a look and tell me where am I going wrong?
Thanks,
Ahmad
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
Thanks for the reply. I tried the fix but the output is still similar. |
Also, I believe you need to re-order your properties in the implementation of PlyVertexWithMaterial::Properties so that the alternate color names are described after all the primary names.
…On May 1, 2018 7:56:56 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
Thanks for the reply. I tried the fix but the output is still similar.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
PS This has to do with how reading/writing is implemented. I/O shares the same list of properties, but whereas reading uses all of them (to support reading in properties with different names, e.g. "red" vs "r"), writing uses only the non-alternate version. The (unstated) assumption is that all non-alternate properties come first, so they can be identified by just using the first WriteComponents in the Properties list.
In your case, you put the alternate properties before the roughness, so instead of getting the write property for roughness, you got the write property for the first alternate color name ("r").
…On May 1, 2018 7:56:56 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
Thanks for the reply. I tried the fix but the output is still similar.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
Thanks, I'll try to do that. |
I know it's not the right way to do it, but only for the sake of testing I changed
to
Although it prints all the properties but rg values are all nan.
Do you think there is something else that I did wrong? |
Wanna send me the data and I can try to take a stab at it?
…On May 4, 2018 9:27:07 PM EDT, ahmadhasan2k8 ***@***.***> wrote:
I know it's not the right way to do it, but only for the sake of
testing I changed
```
const static int WriteComponents =
Dim + (HasNormal ? Dim : 0) + (HasValue ? 1 : 0) +
(HasRoughness ? 1 : 0) + (HasColor ? 3 : 0);
```
to
```
const static int WriteComponents =
Dim + (HasNormal ? Dim : 0) + (HasValue ? 1 : 0) +
(HasRoughness ? 1 : 0) + (HasColor ? 6 : 0);
```
Although it prints all the properties but rg values are all none.
```
ply
format ascii 1.0
comment *************************************************************
comment *************************************************************
comment ** Running Screened Poisson Reconstruction (Version 10.00) **
comment *************************************************************
comment *************************************************************
comment --degree 2
comment --bType 3
comment --in
/home/hypevr/Poisson/PoissonReconTest/Bin/Linux/eagle.pointsout.ply
comment --depth 10
comment --out /home/hypevr/Poisson/PoissonReconTest/Bin/Linux/out.ply
comment --scale 1.100000
comment --samplesPerNode 1.000000
comment --ascii
comment --pointWeight 4.000000
comment --threads 8
comment --density
comment --iters 8
comment --data 64.000000
comment --colors
comment --tempDir /home/hypevr/Poisson/PoissonRecon/
element vertex 2101260
property float x
property float y
property float z
property float nx
property float ny
property float nz
property float value
property uchar red
property uchar green
property uchar blue
property uchar r
property uchar g
property uchar b
property float rg
element face 4202385
property list uchar int vertex_indices
end_header
-0.102389 6.97199 -1.96725 0.0270562 -0.0934122 -0.00174213 5.61052 139
134 124 139 134 124 -nan
0.34234 7.03687 -1.96725 0.0166826 -0.0884893 -0.00972046 5.48095 120
110 105 120 110 105 -nan
0.194098 6.98196 -1.96725 0.0191461 -0.0913949 -0.00700025 5.74068 107
100 96 107 100 96 -nan
-0.0282671 6.95023 -1.96725 0.0240336 -0.0926715 -0.0036984 5.74028 127
121 113 127 121 113 -nan
0.400588 7.06209 -1.96725 0.0144693 -0.08759 -0.0108486 5.35833 125 115
109 125 115 109 -nan
-0.115224 6.98797 -1.96725 0.0269435 -0.0933955 -0.00186054 5.55044 139
134 124 139 134 124 -nan
0.213424 6.98797 -1.96725 0.0189661 -0.09098 -0.00735419 5.7171 109 101
98 109 101 98 -nan
0.0458546 6.95319 -1.96725 0.0219048 -0.0921286 -0.0051143 5.79101 118
112 106 118 112 106 -nan
0.416462 7.06925 -1.96725 0.0140666 -0.0872701 -0.0111891 5.35394 126
116 110 126 116 110 -nan
-0.116352 7.06209 -1.96725 0.0266744 -0.0931716 -0.00232576 5 139 134
124 139 134 124 -nan
0.268219 7.00708 -1.96725 0.0182788 -0.0898554 -0.008354 5.63402 113
105 101 113 105 101 -nan
```
Do you think there is something else that I did wrong?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
Thanks for the reply. I can definitively send you the data. Although I probably can't do it today, but tomorrow for sure. Although it's the eagle data and I just put rg and all 1 at the end of each vertices for testing. I will upload it tomorrow. |
Here's the data. Thanks. |
In your default constructor for NormalColorAndRoughness, you need to explicit initialize roughness to be equal to zero (since POD are not initialized in the constructor).
…-- Misha
From: ahmadhasan2k8 <notifications@github.com>
Sent: Sunday, May 6, 2018 5:40 PM
To: mkazhdan/PoissonRecon <PoissonRecon@noreply.github.com>
Cc: mkazhdan <misha@cs.jhu.edu>; Comment <comment@noreply.github.com>
Subject: Re: [mkazhdan/PoissonRecon] Process additional properties in source point cloud for mesh generation (#57)
Here's the data. Thanks.
eagle.pointsout.zip <https://github.com/mkazhdan/PoissonRecon/files/1978055/eagle.pointsout.zip>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#57 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AKXc5UAMndSpVIVEpB0SG3tLwJH-IrJBks5tv22SgaJpZM4TkMbc> . <https://github.com/notifications/beacon/AKXc5TOHPPk6RGuIKH2fFtOU5OOUav99ks5tv22SgaJpZM4TkMbc.gif>
|
Thank you very much. It worked. Also, for the offset correction, I have made the following changes,
Now the output is exactly as I expected.
|
I want to do the same thing with Surface Trimmer. I haven't started that yet. So, I'd like to keep this issue open till I finish that because I believe it's related. |
So, I changed PlyColorAndValueVertex to PlyAllVertex as defined in Ply.h
in SurfaceTrimmer.cpp as
And it works. Thanks a lot for your help. I am closing the issue. |
Hello,
I have some colored point clouds and I use this code to generate the mesh using the PoissonRecon and SurfaceTrimming codes.
I also have some material ids in the point cloud. For example each point in the cloud has, position(x,y,z), color(r,g,b), normals(nx,ny,nz) and Material ID(m_id). After the reconstruction I surely lose the material ID. Could you please tell me what would be the best way to keep the material id even after I construct the mesh?
It would be very useful because, I can get the material id while the data is in image level and definitely can use a mapping to pass this information till point cloud. If I could pass it though mesh generation it would allow me having material maps in UV.
Thanks,
Ahmad
The text was updated successfully, but these errors were encountered: