Refactored classes to dump a set of outlines onto a png or a svg. Cleared naming and parameters. At least partially...
This commit is contained in:
parent
ea5c88be1a
commit
013857b8fe
|
@ -5,42 +5,47 @@
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void PolyDumper::rectSetToPolySet(vector< Box2f > &rectVec, vector< vector<Point2f> > &polyVec)
|
void PolyDumper::rectSetToOutline2Vec(vector< Box2f > &rectVec, vector< vector<Point2f> > &outline2Vec)
|
||||||
{
|
{
|
||||||
polyVec.clear();
|
outline2Vec.clear();
|
||||||
for(size_t i=0;i<rectVec.size();++i)
|
for(size_t i=0;i<rectVec.size();++i)
|
||||||
{
|
{
|
||||||
Box2f &b=rectVec[i];
|
Box2f &b=rectVec[i];
|
||||||
polyVec.resize(polyVec.size()+1);
|
outline2Vec.resize(outline2Vec.size()+1);
|
||||||
polyVec.back().push_back(b.min);
|
outline2Vec.back().push_back(b.min);
|
||||||
polyVec.back().push_back(Point2f(b.max[0],b.min[1]));
|
outline2Vec.back().push_back(Point2f(b.max[0],b.min[1]));
|
||||||
polyVec.back().push_back(b.max);
|
outline2Vec.back().push_back(b.max);
|
||||||
polyVec.back().push_back(Point2f(b.min[0],b.max[1]));
|
outline2Vec.back().push_back(Point2f(b.min[0],b.max[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolyDumper::multiRectSetToSinglePolySet(vector< Box2f > &rectVec, vector<Similarity2f> &trVec, vector<int> &indVec,
|
void PolyDumper::multiRectSetToSingleOutline2Vec(vector< Box2f > &rectVec,
|
||||||
int ind, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trPolyVec)
|
vector<Similarity2f> &trVec, vector<int> &indVec,
|
||||||
|
int ind, vector< vector<Point2f> > &outline2Vec,
|
||||||
|
vector<Similarity2f> &trOutline2Vec)
|
||||||
{
|
{
|
||||||
polyVec.clear();
|
outline2Vec.clear();
|
||||||
trPolyVec.clear();
|
trOutline2Vec.clear();
|
||||||
|
|
||||||
for(size_t i=0;i<rectVec.size();++i)
|
for(size_t i=0;i<rectVec.size();++i)
|
||||||
if(indVec[i]==ind)
|
if(indVec[i]==ind)
|
||||||
{
|
{
|
||||||
trPolyVec.push_back(trVec[i]);
|
trOutline2Vec.push_back(trVec[i]);
|
||||||
Box2f &b=rectVec[i];
|
Box2f &b=rectVec[i];
|
||||||
polyVec.resize(polyVec.size()+1);
|
outline2Vec.resize(outline2Vec.size()+1);
|
||||||
polyVec.back().push_back(b.min);
|
outline2Vec.back().push_back(b.min);
|
||||||
polyVec.back().push_back(Point2f(b.max[0],b.min[1]));
|
outline2Vec.back().push_back(Point2f(b.max[0],b.min[1]));
|
||||||
polyVec.back().push_back(b.max);
|
outline2Vec.back().push_back(b.max);
|
||||||
polyVec.back().push_back(Point2f(b.min[0],b.max[1]));
|
outline2Vec.back().push_back(Point2f(b.min[0],b.max[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::multiPolySetToSinglePolySet(std::vector< std::vector<Point2f> > &multiPolyVec, std::vector<Similarity2f> &multiTrVec, std::vector<int> &indVec,
|
void PolyDumper::multiOutline2VecToSingleOutline2Vec(std::vector< std::vector<Point2f> > &multiPolyVec,
|
||||||
int ind, std::vector< std::vector<Point2f> > &singlePolyVec, std::vector<Similarity2f> &singleTrVec)
|
std::vector<Similarity2f> &multiTrVec,
|
||||||
|
std::vector<int> &indVec, int ind,
|
||||||
|
std::vector< std::vector<Point2f> > &singlePolyVec,
|
||||||
|
std::vector<Similarity2f> &singleTrVec)
|
||||||
{
|
{
|
||||||
singlePolyVec.clear();
|
singlePolyVec.clear();
|
||||||
singleTrVec.clear();
|
singleTrVec.clear();
|
||||||
|
@ -55,7 +60,7 @@ void PolyDumper::multiPolySetToSinglePolySet(std::vector< std::vector<Point2f> >
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolyDumper::dumpPolySetSVG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumperParam &pp)
|
void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector< vector< vector<Point2f> > > polyVecVec(polyVec.size());
|
vector< vector< vector<Point2f> > > polyVecVec(polyVec.size());
|
||||||
for(size_t i=0;i<polyVec.size();++i)
|
for(size_t i=0;i<polyVec.size();++i)
|
||||||
|
@ -63,10 +68,10 @@ void PolyDumper::dumpPolySetSVG(const char * imageName, vector< vector<Point2f>
|
||||||
polyVecVec[i].resize(1);
|
polyVecVec[i].resize(1);
|
||||||
polyVecVec[i][0]=polyVec[i];
|
polyVecVec[i][0]=polyVec[i];
|
||||||
}
|
}
|
||||||
dumpPolySetSVG(imageName,polyVecVec,trVec,pp);
|
dumpOutline2VecSVG(imageName,polyVecVec,trVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpPolySetPNG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumperParam &pp)
|
void PolyDumper::dumpOutline2VecPNG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector< vector< vector<Point2f> > > polyVecVec(polyVec.size());
|
vector< vector< vector<Point2f> > > polyVecVec(polyVec.size());
|
||||||
for(size_t i=0;i<polyVec.size();++i)
|
for(size_t i=0;i<polyVec.size();++i)
|
||||||
|
@ -74,19 +79,19 @@ void PolyDumper::dumpPolySetPNG(const char * imageName, vector< vector<Point2f>
|
||||||
polyVecVec[i].resize(1);
|
polyVecVec[i].resize(1);
|
||||||
polyVecVec[i][0]=polyVec[i];
|
polyVecVec[i][0]=polyVec[i];
|
||||||
}
|
}
|
||||||
dumpPolySetPNG(imageName,polyVecVec,trVec,pp);
|
dumpOutline2VecPNG(imageName,polyVecVec,trVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpPolySetPNG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumperParam &pp)
|
void PolyDumper::dumpOutline2VecPNG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector<string> labelVec(polyVecVec.size());
|
vector<string> labelVec;
|
||||||
dumpPolySetPNG(imageName,polyVecVec,trVec,labelVec,pp);
|
dumpOutline2VecPNG(imageName,polyVecVec,trVec,labelVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpPolySetSVG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumperParam &pp)
|
void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector<string> labelVec(polyVecVec.size());
|
vector<string> labelVec(polyVecVec.size());
|
||||||
dumpPolySetSVG(imageName,polyVecVec,trVec,labelVec,pp);
|
dumpOutline2VecSVG(imageName,polyVecVec,trVec,labelVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
///this class draw a black mask fora given polygon, cenetered and scaled to fit with
|
///this class draw a black mask fora given polygon, cenetered and scaled to fit with
|
||||||
|
@ -199,7 +204,7 @@ vcg::Point2f PolyDumper::GetIncenter(const vector< vector<Point2f> > &polyVec,
|
||||||
{
|
{
|
||||||
///INITIALIZE THE IMAGE
|
///INITIALIZE THE IMAGE
|
||||||
QImage img(resolution,resolution,QImage::Format_RGB32);
|
QImage img(resolution,resolution,QImage::Format_RGB32);
|
||||||
img.fill(vcg::ColorConverter::ToQColor(vcg::Color4b(255,255,255,255)).rgb());
|
img.fill(vcg::ColorConverter::ToQColor(vcg::Color4b::White));
|
||||||
Similarity2f tra0;
|
Similarity2f tra0;
|
||||||
///DRAW THE MASK
|
///DRAW THE MASK
|
||||||
DrawPolygonMask(polyVec,img,tra0,tra1);
|
DrawPolygonMask(polyVec,img,tra0,tra1);
|
||||||
|
@ -258,86 +263,86 @@ vcg::Point2f PolyDumper::GetIncenter(const vector< vector<Point2f> > &polyVec,
|
||||||
///write a polygon on a PNG file, format of the polygon is vector of vector of contours...nested contours are holes
|
///write a polygon on a PNG file, format of the polygon is vector of vector of contours...nested contours are holes
|
||||||
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
||||||
///the label to be written and the global parameter for drawing style
|
///the label to be written and the global parameter for drawing style
|
||||||
void PolyDumper::dumpPolySetPNG(const char * imageName,
|
void PolyDumper::dumpOutline2VecPNG(const char * imageName,
|
||||||
vector< vector< vector<Point2f> > > &polyVecVec,
|
vector< vector< vector<Point2f> > > &polyVecVec,
|
||||||
vector<Similarity2f> &trVec,
|
vector<Similarity2f> &trVec,
|
||||||
vector<string> &labelVec,
|
vector<string> &labelVec,
|
||||||
PolyDumperParam &pp)
|
Param &pp)
|
||||||
{
|
{
|
||||||
///SET THE FONT
|
///SET THE FONT
|
||||||
assert(polyVecVec.size() == trVec.size());
|
assert(polyVecVec.size() == trVec.size());
|
||||||
int fontSize=ceil(std::max(pp.width,pp.height)/100.0);
|
int fontSize=ceil(std::max(pp.width,pp.height)/100.0);
|
||||||
QFont qf("courier",fontSize);
|
QFont qf("courier",fontSize);
|
||||||
|
|
||||||
///SET THE DRAWING SIZE
|
///SET THE DRAWING SIZE
|
||||||
QImage img(pp.width,pp.height,QImage::Format_RGB32);
|
QImage img(pp.width,pp.height,QImage::Format_RGB32);
|
||||||
img.fill(vcg::ColorConverter::ToQColor( pp.backgroundColor).rgb());
|
img.fill(vcg::ColorConverter::ToQColor( pp.backgroundColor).rgb());
|
||||||
|
|
||||||
///SETUP OF DRAWING PROCEDURE
|
///SETUP OF DRAWING PROCEDURE
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&img);
|
painter.begin(&img);
|
||||||
QBrush bb;
|
QBrush bb;
|
||||||
if (pp.fill)
|
if (pp.fill)
|
||||||
bb.setStyle(Qt::SolidPattern);
|
bb.setStyle(Qt::SolidPattern);
|
||||||
QPen qp;
|
QPen qp;
|
||||||
qp.setWidthF(0);
|
qp.setWidthF(0);
|
||||||
|
|
||||||
for(size_t i=0;i<polyVecVec.size();++i)
|
for(size_t i=0;i<polyVecVec.size();++i)
|
||||||
{
|
{
|
||||||
///SET THE CURRENT TRANSFORMATION
|
///SET THE CURRENT TRANSFORMATION
|
||||||
painter.resetTransform();
|
painter.resetTransform();
|
||||||
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
||||||
painter.rotate(math::ToDeg(trVec[i].rotRad));
|
painter.rotate(math::ToDeg(trVec[i].rotRad));
|
||||||
painter.scale(trVec[i].sca,trVec[i].sca);
|
painter.scale(trVec[i].sca,trVec[i].sca);
|
||||||
QPainterPath QPP;
|
QPainterPath QPP;
|
||||||
|
|
||||||
for(size_t jj=0;jj<polyVecVec[i].size();++jj)
|
for(size_t jj=0;jj<polyVecVec[i].size();++jj)
|
||||||
{
|
{
|
||||||
QVector<QPointF> ppQ;
|
QVector<QPointF> ppQ;
|
||||||
for(size_t j=0;j<polyVecVec[i][jj].size();++j)
|
for(size_t j=0;j<polyVecVec[i][jj].size();++j)
|
||||||
{
|
{
|
||||||
Point2f pp=polyVecVec[i][jj][j];
|
Point2f pp=polyVecVec[i][jj][j];
|
||||||
ppQ.push_back(QPointF(pp[0],pp[1]));
|
ppQ.push_back(QPointF(pp[0],pp[1]));
|
||||||
}
|
}
|
||||||
ppQ.push_back(QPointF(polyVecVec[i][jj][0][0],polyVecVec[i][jj][0][1]));
|
ppQ.push_back(QPointF(polyVecVec[i][jj][0][0],polyVecVec[i][jj][0][1]));
|
||||||
QPP.addPolygon(QPolygonF(ppQ));
|
QPP.addPolygon(QPolygonF(ppQ));
|
||||||
}
|
}
|
||||||
///FIND THE BARYCENTER
|
|
||||||
int radius;
|
|
||||||
Point2f bc;
|
|
||||||
bc=GetIncenter(polyVecVec[i],trVec[i],radius,10);
|
|
||||||
|
|
||||||
if (pp.randomColor)
|
if (pp.randomColor)
|
||||||
bb.setColor(vcg::ColorConverter::ToQColor(Color4b::Scatter(polyVecVec.size(),i)));
|
bb.setColor(vcg::ColorConverter::ToQColor(Color4b::Scatter(polyVecVec.size(),i)));
|
||||||
else
|
else
|
||||||
bb.setColor(vcg::ColorConverter::ToQColor(pp.FillColor));
|
bb.setColor(vcg::ColorConverter::ToQColor(pp.FillColor));
|
||||||
|
|
||||||
painter.setBrush(bb);
|
painter.setBrush(bb);
|
||||||
painter.setPen(qp);
|
painter.setPen(qp);
|
||||||
painter.drawPath(QPP);
|
painter.drawPath(QPP);
|
||||||
|
if(!labelVec.empty())
|
||||||
///DRAW THE TEXT
|
{
|
||||||
painter.setFont(qf);
|
///FIND THE BARYCENTER
|
||||||
painter.resetTransform();
|
int radius;
|
||||||
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
Point2f bc=GetIncenter(polyVecVec[i],trVec[i],radius,10);
|
||||||
|
///DRAW THE TEXT
|
||||||
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString(labelVec[i].c_str()));
|
painter.setFont(qf);
|
||||||
}
|
painter.resetTransform();
|
||||||
painter.end();
|
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
||||||
img.save(imageName);
|
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString(labelVec[i].c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
painter.end();
|
||||||
|
img.save(imageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///write a polygon on a SVG file, format of the polygon is vector of vector of contours...nested contours are holes
|
///write a polygon on a SVG file, format of the polygon is vector of vector of contours...nested contours are holes
|
||||||
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
||||||
///the label to be written and the global parameter for drawing style
|
///the label to be written and the global parameter for drawing style
|
||||||
void PolyDumper::dumpPolySetSVG(const char * imageName,
|
void PolyDumper::dumpOutline2VecSVG(const char * imageName,
|
||||||
vector< vector< vector<Point2f> > > &polyVecVec,
|
vector< vector< vector<Point2f> > > &polyVecVec,
|
||||||
vector<Similarity2f> &trVec,
|
vector<Similarity2f> &trVec,
|
||||||
vector< vector< string> > &labelVecVec,
|
vector< vector< string> > &labelVecVec,
|
||||||
vector<vector<Point2f> > &labelPosVecVec,
|
vector<vector<Point2f> > &labelPosVecVec,
|
||||||
vector<vector<float> >&labelRadVecVec,
|
vector<vector<float> >&labelRadVecVec,
|
||||||
PolyDumperParam &pp)
|
PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
assert(polyVecVec.size() == trVec.size());
|
assert(polyVecVec.size() == trVec.size());
|
||||||
|
|
||||||
|
@ -425,11 +430,11 @@ void PolyDumper::dumpPolySetSVG(const char * imageName,
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpPolySetSVG(const char * imageName,
|
void PolyDumper::dumpOutline2VecSVG(const char * imageName,
|
||||||
vector< vector< vector<Point2f> > > &polyVecVec,
|
vector< vector< vector<Point2f> > > &polyVecVec,
|
||||||
vector<Similarity2f> &trVec,
|
vector<Similarity2f> &trVec,
|
||||||
vector< string > &labelVec,
|
vector< string > &labelVec,
|
||||||
PolyDumperParam &pp)
|
PolyDumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector< vector< string> > labelVecVec(labelVec.size());
|
vector< vector< string> > labelVecVec(labelVec.size());
|
||||||
vector< vector<Point2f> > labelPosVec;
|
vector< vector<Point2f> > labelPosVec;
|
||||||
|
@ -438,6 +443,6 @@ void PolyDumper::dumpPolySetSVG(const char * imageName,
|
||||||
{
|
{
|
||||||
labelVecVec[i].push_back(labelVec[i]);
|
labelVecVec[i].push_back(labelVec[i]);
|
||||||
}
|
}
|
||||||
dumpPolySetSVG(imageName,polyVecVec,trVec,labelVecVec,labelPosVec,labelRadVec,pp);
|
dumpOutline2VecSVG(imageName,polyVecVec,trVec,labelVecVec,labelPosVec,labelRadVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,53 +10,55 @@
|
||||||
|
|
||||||
///this class is used to pass global
|
///this class is used to pass global
|
||||||
///parameters to the polygonal dumper
|
///parameters to the polygonal dumper
|
||||||
class PolyDumperParam
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// the backgrround color
|
|
||||||
vcg::Color4b backgroundColor;
|
|
||||||
/// true if the polygons must be filled with color
|
|
||||||
bool fill;
|
|
||||||
/// true if the filling color is random
|
|
||||||
bool randomColor;
|
|
||||||
/// the filling color of polygons, used only if randomColor==false
|
|
||||||
vcg::Color4b FillColor;
|
|
||||||
/// The size of the font. If zero (default) it is automatically chosen.
|
|
||||||
int fontSize;
|
|
||||||
/// dimension of the image (in PNG are pixels, while in SVG is the workspace in points)
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
/// DPI resolution, used only for SVG
|
|
||||||
int dpi;
|
|
||||||
|
|
||||||
///Handy function for setting the size of the drawing
|
|
||||||
void SetSVGDimInMm(float widthMM,float heightMM,float _dpi=72)
|
|
||||||
{
|
|
||||||
dpi=_dpi;
|
|
||||||
float widthInch = float(widthMM / 25.4f);
|
|
||||||
float heightInch = float(heightMM / 25.4f);
|
|
||||||
width = widthInch * _dpi;
|
|
||||||
height = heightInch * _dpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
///default constructor
|
|
||||||
PolyDumperParam()
|
|
||||||
{
|
|
||||||
backgroundColor = vcg::Color4b::Gray;
|
|
||||||
width=1024;
|
|
||||||
height=1024;
|
|
||||||
dpi=72;
|
|
||||||
fontSize=0;
|
|
||||||
fill=false;
|
|
||||||
randomColor=true;
|
|
||||||
FillColor=vcg::Color4b(0,0,0,255);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
///this class is used to draw polygons on an image could be vectorial or not
|
///this class is used to draw polygons on an image could be vectorial or not
|
||||||
class PolyDumper
|
class PolyDumper
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
class Param
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// the backgrround color
|
||||||
|
vcg::Color4b backgroundColor;
|
||||||
|
/// true if the polygons must be filled with color
|
||||||
|
bool fill;
|
||||||
|
/// true if the filling color is random
|
||||||
|
bool randomColor;
|
||||||
|
/// the filling color of polygons, used only if randomColor==false
|
||||||
|
vcg::Color4b FillColor;
|
||||||
|
/// The size of the font. If zero (default) it is automatically chosen.
|
||||||
|
int fontSize;
|
||||||
|
/// dimension of the image (in PNG are pixels, while in SVG is the workspace in points)
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
/// DPI resolution, used only for SVG
|
||||||
|
int dpi;
|
||||||
|
|
||||||
|
///Handy function for setting the size of the drawing
|
||||||
|
void SetSVGDimInMm(float widthMM,float heightMM,float _dpi=72)
|
||||||
|
{
|
||||||
|
dpi=_dpi;
|
||||||
|
float widthInch = float(widthMM / 25.4f);
|
||||||
|
float heightInch = float(heightMM / 25.4f);
|
||||||
|
width = widthInch * _dpi;
|
||||||
|
height = heightInch * _dpi;
|
||||||
|
}
|
||||||
|
|
||||||
|
///default constructor
|
||||||
|
Param()
|
||||||
|
{
|
||||||
|
backgroundColor = vcg::Color4b::Gray;
|
||||||
|
width=1024;
|
||||||
|
height=1024;
|
||||||
|
dpi=72;
|
||||||
|
fontSize=0;
|
||||||
|
fill=false;
|
||||||
|
randomColor=true;
|
||||||
|
FillColor=vcg::Color4b(0,0,0,255);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private:
|
||||||
///this class draw a black mask fora given polygon, cenetered and scaled to fit with
|
///this class draw a black mask fora given polygon, cenetered and scaled to fit with
|
||||||
///the image size, it return the transformation to tranform back the polygon to 2D space
|
///the image size, it return the transformation to tranform back the polygon to 2D space
|
||||||
static void DrawPolygonMask(const std::vector< std::vector<vcg::Point2f> > &polyVec,QImage &img,
|
static void DrawPolygonMask(const std::vector< std::vector<vcg::Point2f> > &polyVec,QImage &img,
|
||||||
|
@ -72,37 +74,37 @@ class PolyDumper
|
||||||
const vcg::Similarity2f &tra1,int &radius,int resolution=100);
|
const vcg::Similarity2f &tra1,int &radius,int resolution=100);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void rectSetToPolySet(std::vector< vcg::Box2f > &rectVec, std::vector< std::vector<vcg::Point2f> > &polyVec);
|
static void rectSetToOutline2Vec(std::vector< vcg::Box2f > &rectVec, std::vector< std::vector<vcg::Point2f> > &polyVec);
|
||||||
static void multiRectSetToSinglePolySet(std::vector< vcg::Box2f > &rectVec, std::vector<vcg::Similarity2f> &trVec, std::vector<int> &indVec,
|
static void multiRectSetToSingleOutline2Vec(std::vector< vcg::Box2f > &rectVec, std::vector<vcg::Similarity2f> &trVec, std::vector<int> &indVec,
|
||||||
int ind, std::vector< std::vector<vcg::Point2f> > &polyVec, std::vector<vcg::Similarity2f> &trPolyVec);
|
int ind, std::vector< std::vector<vcg::Point2f> > &polyVec, std::vector<vcg::Similarity2f> &trPolyVec);
|
||||||
static void multiPolySetToSinglePolySet(std::vector< std::vector< vcg::Point2f> > &multipolyVec, std::vector< vcg::Similarity2f> &trVec, std::vector<int> &indVec,
|
static void multiOutline2VecToSingleOutline2Vec(std::vector< std::vector< vcg::Point2f> > &multipolyVec, std::vector< vcg::Similarity2f> &trVec, std::vector<int> &indVec,
|
||||||
int ind, std::vector< std::vector< vcg::Point2f> > &polyVec, std::vector< vcg::Similarity2f> &trPolyVec);
|
int ind, std::vector< std::vector< vcg::Point2f> > &polyVec, std::vector< vcg::Similarity2f> &trPolyVec);
|
||||||
|
|
||||||
///write a polygon on a PNG file, format of the polygon is vector of vector of contours...nested contours are holes
|
///write a polygon on a PNG file, format of the polygon is vector of vector of contours...nested contours are holes
|
||||||
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
||||||
///the label to be written and the global parameter for drawing style
|
///the label to be written and the global parameter for drawing style
|
||||||
static void dumpPolySetPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, std::vector<std::vector<std::string> > &labelVecVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, std::vector<std::vector<std::string> > &labelVecVec, Param &pp);
|
||||||
//write a polygon on a SVG file, format of the polygon is vector of vector of contours...nested contours are holes
|
//write a polygon on a SVG file, format of the polygon is vector of vector of contours...nested contours are holes
|
||||||
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
|
||||||
///the label to be written and the global parameter for drawing style
|
///the label to be written and the global parameter for drawing style
|
||||||
static void dumpPolySetSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, std::vector< std::vector<std::string> > &labelVecVec,
|
std::vector<vcg::Similarity2f> &trVec, std::vector< std::vector<std::string> > &labelVecVec,
|
||||||
std::vector<std::vector< vcg::Point2f> > &labelPosVec, std::vector<std::vector<float> > &labelRadVec, PolyDumperParam &pp);
|
std::vector<std::vector< vcg::Point2f> > &labelPosVec, std::vector<std::vector<float> > &labelRadVec, Param &pp);
|
||||||
|
|
||||||
static void dumpPolySetPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, std::vector<std::string> &labelVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, std::vector<std::string> &labelVec, Param &pp);
|
||||||
static void dumpPolySetSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, std::vector<std::string> &labelVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, std::vector<std::string> &labelVec, Param &pp);
|
||||||
|
|
||||||
static void dumpPolySetPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecPNG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, Param &pp);
|
||||||
static void dumpPolySetSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
static void dumpOutline2VecSVG(const char * imageName, std::vector< std::vector< std::vector<vcg::Point2f> > > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, Param &pp);
|
||||||
|
|
||||||
static void dumpPolySetPNG(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVecVec,
|
static void dumpOutline2VecPNG(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, Param &pp);
|
||||||
static void dumpPolySetSVG(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVecVec,
|
static void dumpOutline2VecSVG(const char * imageName, std::vector< std::vector<vcg::Point2f> > &polyVecVec,
|
||||||
std::vector<vcg::Similarity2f> &trVec, PolyDumperParam &pp);
|
std::vector<vcg::Similarity2f> &trVec, Param &pp);
|
||||||
};
|
};
|
||||||
#endif // POLYTOQIMAGE_H
|
#endif // POLYTOQIMAGE_H
|
||||||
|
|
Loading…
Reference in New Issue