40 #ifndef vpMbScanLine_HH 41 #define vpMbScanLine_HH 50 #include <visp3/core/vpCameraParameters.h> 51 #include <visp3/core/vpColVector.h> 52 #include <visp3/core/vpImage.h> 53 #include <visp3/core/vpImageConvert.h> 54 #include <visp3/core/vpImagePoint.h> 55 #include <visp3/core/vpPoint.h> 59 #if defined(DEBUG_DISP) 60 #include <visp3/core/vpDisplay.h> 63 #ifndef DOXYGEN_SHOULD_SKIP_THIS 71 class VISP_EXPORT vpMbScanLine
76 typedef enum { START = 1, END = 0, POINT = 2 } vpMbScanLineType;
80 typedef std::pair<vpColVector, vpColVector> vpMbScanLineEdge;
83 struct vpMbScanLineSegment {
84 vpMbScanLineSegment() : type(START), edge(), p(0), P1(0), P2(0), Z1(0), Z2(0), ID(0), b_sample_Y(false) {}
85 vpMbScanLineType type;
86 vpMbScanLineEdge edge;
96 struct vpMbScanLineEdgeComparator {
97 inline bool operator()(
const vpMbScanLineEdge &l0,
const vpMbScanLineEdge &l1)
const 99 for (
unsigned int i = 0; i < 3; ++i)
100 if (l0.first[i] < l1.first[i])
102 else if (l0.first[i] > l1.first[i])
104 for (
unsigned int i = 0; i < 3; ++i)
105 if (l0.second[i] < l1.second[i])
107 else if (l0.second[i] > l1.second[i])
114 struct vpMbScanLineSegmentComparator {
115 inline bool operator()(
const vpMbScanLineSegment &a,
const vpMbScanLineSegment &b)
const 118 return (std::fabs(a.p - b.p) <= std::numeric_limits<double>::epsilon()) ? a.type < b.type : a.p < b.p;
121 inline bool operator()(
const std::pair<double, vpMbScanLineSegment> &a,
122 const std::pair<double, vpMbScanLineSegment> &b)
const 124 return a.first < b.first;
131 unsigned int maskBorder;
134 std::map<vpMbScanLineEdge, std::set<int>, vpMbScanLineEdgeComparator> visibility_samples;
135 double depthTreshold;
138 #if defined(DEBUG_DISP) 145 virtual ~vpMbScanLine();
147 void drawScene(
const std::vector<std::vector<std::pair<vpPoint, unsigned int> > *> &polygons,
148 std::vector<int> listPolyIndices,
const vpCameraParameters &K,
unsigned int w,
unsigned int h);
157 double getDepthTreshold() {
return depthTreshold; }
158 unsigned int getMaskBorder() {
return maskBorder; }
160 const vpImage<int> &getPrimitiveIDs()
const {
return primitive_ids; }
162 void queryLineVisibility(
const vpPoint &a,
const vpPoint &b, std::vector<std::pair<vpPoint, vpPoint> > &lines,
163 const bool &displayResults =
false);
172 void setDepthTreshold(
const double &treshold) { depthTreshold = treshold; }
173 void setMaskBorder(
const unsigned int &mb) { maskBorder = mb; }
176 void createScanLinesFromLocals(std::vector<std::vector<vpMbScanLineSegment> > &scanlines,
177 std::vector<std::vector<vpMbScanLineSegment> > &localScanlines,
178 const unsigned int &size);
181 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
184 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
186 void drawPolygonY(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
const int ID,
187 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
189 void drawPolygonX(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
const int ID,
190 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
193 static vpMbScanLineEdge makeMbScanLineEdge(
const vpPoint &a,
const vpPoint &b);
195 static double getAlpha(
double x,
double X0,
double Z0,
double X1,
double Z1);
196 static double mix(
double a,
double b,
double alpha);
201 #endif // doxygen should skip this Class that defines generic functionnalities for display.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.