25 #ifndef INCLUDED_EdgeHoleBasedLedExtractor_h_GUID_225A962F_C636_4CA5_2D16_964D63A0571A 26 #define INCLUDED_EdgeHoleBasedLedExtractor_h_GUID_225A962F_C636_4CA5_2D16_964D63A0571A 30 #undef OSVR_USE_REALTIME_LAPLACIAN 39 #include <opencv2/core/core.hpp> 40 #include <opencv2/imgproc/imgproc.hpp> 48 #if defined(OSVR_OPENCV_3PLUS) && defined(OSVR_USE_REALTIME_LAPLACIAN) 49 #undef OSVR_USE_REALTIME_LAPLACIAN 56 #undef OSVR_PERMIT_OPENCL 58 #if defined(OSVR_OPENCV_3PLUS) && defined(OSVR_PERMIT_OPENCL) 59 #define OSVR_EDGEHOLE_UMAT 1 61 #define OSVR_EDGEHOLE_UMAT 0 67 class RealtimeLaplacian;
69 enum class RejectReason { Area, CenterPointValue, Circularity, Convexity };
72 #if OSVR_EDGEHOLE_UMAT 73 using MatType = cv::UMat;
74 using ExternalMatGetterReturn = cv::Mat;
76 using MatType = cv::Mat;
77 using ExternalMatGetterReturn = cv::Mat
const &;
82 LedMeasurementVec
const &operator()(cv::Mat
const &gray,
84 bool verboseBlobOutput =
false);
87 using ContourId = std::size_t;
89 using RejectType = std::tuple<ContourId, RejectReason, cv::Point2d>;
90 using RejectList = std::vector<RejectType>;
94 ExternalMatGetterReturn getInputGrayImage()
const {
95 return externalMatGetter(gray_);
97 ExternalMatGetterReturn getEdgeDetectedImage()
const {
98 return externalMatGetter(edge_);
100 ExternalMatGetterReturn getEdgeDetectedBinarizedImage()
const {
101 return externalMatGetter(edgeBinary_);
103 ContourList
const &getContours()
const {
return contours_; }
104 LedMeasurementVec
const &getMeasurements()
const {
105 return measurements_;
107 RejectList
const &getRejectList()
const {
return rejectList_; }
110 #if OSVR_EDGEHOLE_UMAT 111 static ExternalMatGetterReturn externalMatGetter(MatType
const &input) {
112 return input.getMat(cv::ACCESS_READ);
115 static ExternalMatGetterReturn externalMatGetter(MatType
const &input) {
119 void checkBlob(ContourType &&contour,
BlobParams const &p);
120 void addToRejectList(ContourId
id, RejectReason reason,
122 rejectList_.emplace_back(
id, reason, data.center);
128 std::uint8_t minBeaconCenterVal_ = 127;
150 std::vector<ContourType> contoursTempStorage_;
151 std::vector<cv::Vec4i> hierarchyTempStorage_;
156 cv::Mat compressionArtifactRemovalKernel_;
158 cv::Ptr<cv::FilterEngine> compressionArtifactRemoval_;
161 #ifdef OSVR_USE_REALTIME_LAPLACIAN 162 std::unique_ptr<RealtimeLaplacian> laplacianImpl_;
165 ContourList contours_;
166 LedMeasurementVec measurements_;
167 RejectList rejectList_;
168 bool verbose_ =
false;
170 ContourId contourId_ = 0;
174 #endif // INCLUDED_EdgeHoleBasedLedExtractor_h_GUID_225A962F_C636_4CA5_2D16_964D63A0571A
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: BlobParams.h:93
Data structure with a lot of info about a contour.
Definition: BlobExtractor.h:45
Blob detection configuration parameters.
Definition: BlobParams.h:40
Header defining a few simple preprocessor macros for dealing with OpenCV 2 and 3 compatibility.