38 #ifndef vpMbScanLine_HH
39 #define vpMbScanLine_HH
48 #include <visp3/core/vpColVector.h>
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/core/vpPoint.h>
51 #include <visp3/core/vpImagePoint.h>
52 #include <visp3/core/vpImage.h>
53 #include <visp3/core/vpImageConvert.h>
57 #if defined(DEBUG_DISP)
58 #include <visp3/core/vpDisplay.h>
61 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69 class VISP_EXPORT vpMbScanLine
81 typedef std::pair<vpColVector, vpColVector> vpMbScanLineEdge;
84 struct vpMbScanLineSegment
86 vpMbScanLineSegment() : type(START), edge(), p(0), P1(0), P2(0), Z1(0), Z2(0), ID(0), b_sample_Y(false) {};
87 vpMbScanLineType type;
88 vpMbScanLineEdge edge;
97 struct vpMbScanLineEdgeComparator
99 inline bool operator()(
const vpMbScanLineEdge &l0,
const vpMbScanLineEdge &l1)
const
101 for(
unsigned int i = 0 ; i < 3 ; ++i)
102 if (l0.first[i] < l1.first[i])
104 else if(l0.first[i] > l1.first[i])
106 for(
unsigned int i = 0 ; i < 3 ; ++i)
107 if (l0.second[i] < l1.second[i])
109 else if(l0.second[i] > l1.second[i])
116 struct vpMbScanLineSegmentComparator
118 inline bool operator()(
const vpMbScanLineSegment &a,
const vpMbScanLineSegment &b)
const
121 return (std::fabs(a.p - b.p) <= std::numeric_limits<double>::epsilon()) ? a.type < b.type : a.p < b.p;
124 inline bool operator()(
const std::pair<double,vpMbScanLineSegment> &a,
const std::pair<double, vpMbScanLineSegment> &b)
const
126 return a.first < b.first;
133 unsigned int maskBorder;
136 std::map<vpMbScanLineEdge, std::set<int>, vpMbScanLineEdgeComparator> visibility_samples;
137 double depthTreshold;
140 #if defined(DEBUG_DISP)
149 void drawScene(
const std::vector<std::vector<std::pair<vpPoint, unsigned int> > * > &polygons,
150 std::vector<int> listPolyIndices,
159 double getDepthTreshold() {
return depthTreshold; }
160 unsigned int getMaskBorder() {
return maskBorder; }
162 const vpImage<int>& getPrimitiveIDs()
const {
return primitive_ids; }
165 std::vector<std::pair<vpPoint, vpPoint> > &lines,
166 const bool &displayResults =
false);
174 void setDepthTreshold(
const double &treshold) { depthTreshold = treshold; }
175 void setMaskBorder(
const unsigned int &mb){ maskBorder = mb; }
179 void createScanLinesFromLocals(std::vector<std::vector<vpMbScanLineSegment> > &scanlines,
180 std::vector<std::vector<vpMbScanLineSegment> > &localScanlines,
181 const unsigned int &size);
185 const vpMbScanLineEdge &line_ID,
187 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
191 const vpMbScanLineEdge &line_ID,
193 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
195 void drawPolygonY(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
197 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
199 void drawPolygonX(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
201 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
204 static vpMbScanLineEdge makeMbScanLineEdge(
const vpPoint &a,
const vpPoint &b);
206 static double getAlpha(
double x,
double X0,
double Z0,
double X1,
double Z1);
207 static double mix(
double a,
double b,
double alpha);
212 #endif // doxygen should skip this
Class that defines generic functionnalities for display.
Class that defines what is a point.
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.