Further cleaning up and factorization of the stuff for the raster outline packer
This commit is contained in:
parent
319f8404ea
commit
a814a0b265
|
@ -1,11 +1,9 @@
|
||||||
|
#include "Outline2ToQImage.h"
|
||||||
|
|
||||||
#include "PolyToQImage.h"
|
|
||||||
#include <wrap/qt/col_qt_convert.h>
|
#include <wrap/qt/col_qt_convert.h>
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void PolyDumper::rectSetToOutline2Vec(vector< Box2f > &rectVec, vector< vector<Point2f> > &outline2Vec)
|
void Outline2Dumper::rectSetToOutline2Vec(vector< Box2f > &rectVec, vector< vector<Point2f> > &outline2Vec)
|
||||||
{
|
{
|
||||||
outline2Vec.clear();
|
outline2Vec.clear();
|
||||||
for(size_t i=0;i<rectVec.size();++i)
|
for(size_t i=0;i<rectVec.size();++i)
|
||||||
|
@ -20,7 +18,7 @@ void PolyDumper::rectSetToOutline2Vec(vector< Box2f > &rectVec, vector< vector<P
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolyDumper::multiRectSetToSingleOutline2Vec(vector< Box2f > &rectVec,
|
void Outline2Dumper::multiRectSetToSingleOutline2Vec(vector< Box2f > &rectVec,
|
||||||
vector<Similarity2f> &trVec, vector<int> &indVec,
|
vector<Similarity2f> &trVec, vector<int> &indVec,
|
||||||
int ind, vector< vector<Point2f> > &outline2Vec,
|
int ind, vector< vector<Point2f> > &outline2Vec,
|
||||||
vector<Similarity2f> &trOutline2Vec)
|
vector<Similarity2f> &trOutline2Vec)
|
||||||
|
@ -41,7 +39,7 @@ void PolyDumper::multiRectSetToSingleOutline2Vec(vector< Box2f > &rectVec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::multiOutline2VecToSingleOutline2Vec(const std::vector< std::vector<Point2f> > &multiPolyVec,
|
void Outline2Dumper::multiOutline2VecToSingleOutline2Vec(const std::vector< std::vector<Point2f> > &multiPolyVec,
|
||||||
const std::vector<Similarity2f> &multiTrVec,
|
const std::vector<Similarity2f> &multiTrVec,
|
||||||
const std::vector<int> &indVec, int ind,
|
const std::vector<int> &indVec, int ind,
|
||||||
std::vector< std::vector<Point2f> > &singlePolyVec,
|
std::vector< std::vector<Point2f> > &singlePolyVec,
|
||||||
|
@ -60,7 +58,7 @@ void PolyDumper::multiOutline2VecToSingleOutline2Vec(const std::vector< std::vec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
void Outline2Dumper::dumpOutline2VecSVG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, Outline2Dumper::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)
|
||||||
|
@ -71,7 +69,7 @@ void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector<Point
|
||||||
dumpOutline2VecSVG(imageName,polyVecVec,trVec,pp);
|
dumpOutline2VecSVG(imageName,polyVecVec,trVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpOutline2VecPNG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
void Outline2Dumper::dumpOutline2VecPNG(const char * imageName, vector< vector<Point2f> > &polyVec, vector<Similarity2f> &trVec, Outline2Dumper::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)
|
||||||
|
@ -82,13 +80,13 @@ void PolyDumper::dumpOutline2VecPNG(const char * imageName, vector< vector<Point
|
||||||
dumpOutline2VecPNG(imageName,polyVecVec,trVec,pp);
|
dumpOutline2VecPNG(imageName,polyVecVec,trVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpOutline2VecPNG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
void Outline2Dumper::dumpOutline2VecPNG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, Outline2Dumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector<string> labelVec;
|
vector<string> labelVec;
|
||||||
dumpOutline2VecPNG(imageName,polyVecVec,trVec,labelVec,pp);
|
dumpOutline2VecPNG(imageName,polyVecVec,trVec,labelVec,pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, PolyDumper::Param &pp)
|
void Outline2Dumper::dumpOutline2VecSVG(const char * imageName, vector< vector< vector<Point2f> > > &polyVecVec, vector<Similarity2f> &trVec, Outline2Dumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector<string> labelVec(polyVecVec.size());
|
vector<string> labelVec(polyVecVec.size());
|
||||||
dumpOutline2VecSVG(imageName,polyVecVec,trVec,labelVec,pp);
|
dumpOutline2VecSVG(imageName,polyVecVec,trVec,labelVec,pp);
|
||||||
|
@ -96,7 +94,7 @@ void PolyDumper::dumpOutline2VecSVG(const char * imageName, vector< vector< vect
|
||||||
|
|
||||||
///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
|
||||||
void PolyDumper::DrawPolygonMask(const vector< vector<Point2f> > &polyVec,
|
void Outline2Dumper::DrawPolygonMask(const vector< vector<Point2f> > &polyVec,
|
||||||
QImage &img,
|
QImage &img,
|
||||||
Similarity2f &ret,
|
Similarity2f &ret,
|
||||||
const Similarity2f &trans)
|
const Similarity2f &trans)
|
||||||
|
@ -161,7 +159,7 @@ void PolyDumper::DrawPolygonMask(const vector< vector<Point2f> > &polyVec,
|
||||||
|
|
||||||
///return the max radius of a point inside a polygon ,given the mask image
|
///return the max radius of a point inside a polygon ,given the mask image
|
||||||
///actually it evaluate the maximum bounding box
|
///actually it evaluate the maximum bounding box
|
||||||
int PolyDumper::getMaxMaskRadius(int x,int y,QImage &img)
|
int Outline2Dumper::getMaxMaskRadius(int x,int y,QImage &img)
|
||||||
{
|
{
|
||||||
int sizeY=img.size().height();
|
int sizeY=img.size().height();
|
||||||
int sizeX=img.size().width();
|
int sizeX=img.size().width();
|
||||||
|
@ -197,7 +195,7 @@ int PolyDumper::getMaxMaskRadius(int x,int y,QImage &img)
|
||||||
|
|
||||||
///return the point inside the polygon with the bigger distance to the border,
|
///return the point inside the polygon with the bigger distance to the border,
|
||||||
///this is used to write labels within the polygon, it handle polygons with holes too
|
///this is used to write labels within the polygon, it handle polygons with holes too
|
||||||
vcg::Point2f PolyDumper::GetIncenter(const vector< vector<Point2f> > &polyVec,
|
vcg::Point2f Outline2Dumper::GetIncenter(const vector< vector<Point2f> > &polyVec,
|
||||||
const Similarity2f &tra1,
|
const Similarity2f &tra1,
|
||||||
int &radius,
|
int &radius,
|
||||||
int resolution)
|
int resolution)
|
||||||
|
@ -263,7 +261,7 @@ 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::dumpOutline2VecPNG(const char * imageName,
|
void Outline2Dumper::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,
|
||||||
|
@ -336,13 +334,13 @@ void PolyDumper::dumpOutline2VecPNG(const char * 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::dumpOutline2VecSVG(const char * imageName,
|
void Outline2Dumper::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,
|
||||||
PolyDumper::Param &pp)
|
Outline2Dumper::Param &pp)
|
||||||
{
|
{
|
||||||
assert(polyVecVec.size() == trVec.size());
|
assert(polyVecVec.size() == trVec.size());
|
||||||
|
|
||||||
|
@ -430,11 +428,11 @@ void PolyDumper::dumpOutline2VecSVG(const char * imageName,
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDumper::dumpOutline2VecSVG(const char * imageName,
|
void Outline2Dumper::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,
|
||||||
PolyDumper::Param &pp)
|
Outline2Dumper::Param &pp)
|
||||||
{
|
{
|
||||||
vector< vector< string> > labelVecVec(labelVec.size());
|
vector< vector< string> > labelVecVec(labelVec.size());
|
||||||
vector< vector<Point2f> > labelPosVec;
|
vector< vector<Point2f> > labelPosVec;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
///parameters to the polygonal dumper
|
///parameters to the polygonal dumper
|
||||||
|
|
||||||
///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 Outline2Dumper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Param
|
class Param
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
#include "qtpolyrasterizer.h"
|
#include <wrap/qt/outline2_rasterizer.h>
|
||||||
#include <wrap/qt/col_qt_convert.h>
|
#include <wrap/qt/col_qt_convert.h>
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include <QDebug>
|
|
||||||
#include <vcg/space/color4.h>
|
#include <vcg/space/color4.h>
|
||||||
#include <wrap/qt/col_qt_convert.h>
|
#include <wrap/qt/col_qt_convert.h>
|
||||||
#include <new_polypacker.h>
|
|
||||||
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void QtPolyRasterizer::rasterize(RasterizedOutline2 &poly,
|
void QtOutline2Rasterizer::rasterize(RasterizedOutline2 &poly,
|
||||||
float scale,
|
float scale,
|
||||||
int rast_i,
|
int rast_i,
|
||||||
int rotationNum,
|
int rotationNum,
|
||||||
|
@ -164,7 +162,7 @@ void QtPolyRasterizer::rasterize(RasterizedOutline2 &poly,
|
||||||
|
|
||||||
// rotates the grid 90 degree clockwise (by simple swap)
|
// rotates the grid 90 degree clockwise (by simple swap)
|
||||||
// used to lower the cost of rasterization.
|
// used to lower the cost of rasterization.
|
||||||
vector<vector<int> > QtPolyRasterizer::rotateGridCWise(vector< vector<int> >& inGrid) {
|
vector<vector<int> > QtOutline2Rasterizer::rotateGridCWise(vector< vector<int> >& inGrid) {
|
||||||
vector<vector<int> > outGrid(inGrid[0].size());
|
vector<vector<int> > outGrid(inGrid[0].size());
|
||||||
for (int i = 0; i < inGrid[0].size(); i++) {
|
for (int i = 0; i < inGrid[0].size(); i++) {
|
||||||
outGrid[i].reserve(inGrid.size());
|
outGrid[i].reserve(inGrid.size());
|
||||||
|
|
|
@ -8,15 +8,10 @@
|
||||||
#include <vcg/space/color4.h>
|
#include <vcg/space/color4.h>
|
||||||
#include <vcg/space/box2.h>
|
#include <vcg/space/box2.h>
|
||||||
#include <vcg/math/similarity2.h>
|
#include <vcg/math/similarity2.h>
|
||||||
|
#include <vcg/space/rasterized_outline2_packer.h>
|
||||||
///this class is used to pass global
|
|
||||||
///parameters to the polygonal dumper
|
|
||||||
namespace vcg{
|
|
||||||
class RasterizedOutline2;
|
|
||||||
}
|
|
||||||
|
|
||||||
///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 QtPolyRasterizer
|
class QtOutline2Rasterizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void rasterize(vcg::RasterizedOutline2 &poly,
|
static void rasterize(vcg::RasterizedOutline2 &poly,
|
||||||
|
|
Loading…
Reference in New Issue