40 #ifndef vpMbScanLine_HH
41 #define vpMbScanLine_HH
50 #include <visp3/core/vpConfig.h>
51 #include <visp3/core/vpCameraParameters.h>
52 #include <visp3/core/vpColVector.h>
53 #include <visp3/core/vpImage.h>
54 #include <visp3/core/vpImageConvert.h>
55 #include <visp3/core/vpImagePoint.h>
56 #include <visp3/core/vpPoint.h>
60 #if defined(DEBUG_DISP)
61 #include <visp3/core/vpDisplay.h>
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
73 class VISP_EXPORT vpMbScanLine
78 typedef enum { START = 1, END = 0, POINT = 2 } vpMbScanLineType;
82 typedef std::pair<vpColVector, vpColVector> vpMbScanLineEdge;
85 struct vpMbScanLineSegment
87 vpMbScanLineSegment() : type(START), edge(), p(0), P1(0), P2(0), Z1(0), Z2(0), ID(0), b_sample_Y(false) { }
88 vpMbScanLineType type;
89 vpMbScanLineEdge edge;
99 struct vpMbScanLineEdgeComparator
101 inline bool operator()(
const vpMbScanLineEdge &l0,
const vpMbScanLineEdge &l1)
const
103 for (
unsigned int i = 0; i < 3; ++i)
104 if (l0.first[i] < l1.first[i])
106 else if (l0.first[i] > l1.first[i])
108 for (
unsigned int i = 0; i < 3; ++i)
109 if (l0.second[i] < l1.second[i])
111 else if (l0.second[i] > l1.second[i])
118 struct vpMbScanLineSegmentComparator
120 inline bool operator()(
const vpMbScanLineSegment &a,
const vpMbScanLineSegment &b)
const
123 return (std::fabs(a.p - b.p) <= std::numeric_limits<double>::epsilon()) ? a.type < b.type : a.p < b.p;
126 inline bool operator()(
const std::pair<double, vpMbScanLineSegment> &a,
127 const std::pair<double, vpMbScanLineSegment> &b)
const
129 return a.first < b.first;
136 unsigned int maskBorder;
139 std::map<vpMbScanLineEdge, std::set<int>, vpMbScanLineEdgeComparator> visibility_samples;
140 double depthTreshold;
143 #if defined(DEBUG_DISP)
150 virtual ~vpMbScanLine();
152 void drawScene(
const std::vector<std::vector<std::pair<vpPoint, unsigned int> > *> &polygons,
153 std::vector<int> listPolyIndices,
const vpCameraParameters &K,
unsigned int w,
unsigned int h);
162 double getDepthTreshold() {
return depthTreshold; }
163 unsigned int getMaskBorder() {
return maskBorder; }
165 const vpImage<int> &getPrimitiveIDs()
const {
return primitive_ids; }
167 void queryLineVisibility(
const vpPoint &a,
const vpPoint &b, std::vector<std::pair<vpPoint, vpPoint> > &lines,
168 const bool &displayResults =
false);
177 void setDepthTreshold(
const double &treshold) { depthTreshold = treshold; }
178 void setMaskBorder(
const unsigned int &mb) { maskBorder = mb; }
181 void createScanLinesFromLocals(std::vector<std::vector<vpMbScanLineSegment> > &scanlines,
182 std::vector<std::vector<vpMbScanLineSegment> > &localScanlines,
183 const unsigned int &size);
186 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
189 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
191 void drawPolygonY(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
const int ID,
192 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
194 void drawPolygonX(
const std::vector<std::pair<vpPoint, unsigned int> > &polygon,
const int ID,
195 std::vector<std::vector<vpMbScanLineSegment> > &scanlines);
198 static vpMbScanLineEdge makeMbScanLineEdge(
const vpPoint &a,
const vpPoint &b);
200 static double getAlpha(
double x,
double X0,
double Z0,
double X1,
double Z1);
201 static double mix(
double a,
double b,
double alpha);
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class that defines generic functionalities for display.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...