Go to the documentation of this file.
18 #include <mrpt/otherlibs/do_opencv_includes.h>
27 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
31 #define CASCADE (reinterpret_cast<CascadeClassifier*>(m_cascade))
32 #define CASCADE_CONST (reinterpret_cast<const CascadeClassifier*>(m_cascade))
41 #if !MRPT_HAS_OPENCV || MRPT_OPENCV_VERSION_NUM < 0x200
43 "CCascadeClassifierDetection class requires MRPT built against OpenCV "
54 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
66 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
68 m_options.cascadeFileName =
69 config.
read_string(
"CascadeClassifier",
"cascadeFilename",
"");
70 m_options.scaleFactor =
71 config.
read_double(
"DetectionOptions",
"scaleFactor", 1.1);
72 m_options.minNeighbors =
73 config.
read_int(
"DetectionOptions",
"minNeighbors", 3);
74 m_options.flags = config.
read_int(
"DetectionOptions",
"flags", 0);
75 m_options.minSize = config.
read_int(
"DetectionOptions",
"minSize", 30);
77 m_cascade =
new CascadeClassifier();
80 CASCADE->load(m_options.cascadeFileName);
83 if (
CASCADE->empty())
throw std::runtime_error(
"Incorrect cascade file.");
94 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
117 std::this_thread::sleep_for(2ms);
121 vector<Rect> objects;
127 const IplImage*
image = img_gray.
getAs<IplImage>();
131 cv::cvarrToMat(
image), objects, m_options.scaleFactor,
132 m_options.minNeighbors, m_options.flags,
133 Size(m_options.minSize, m_options.minSize));
135 unsigned int N = objects.size();
139 for (
unsigned int i = 0; i < N; i++)
143 objects[i].
x, objects[i].
y, objects[i].
height,
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
GLsizei GLsizei GLuint * obj
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img....
mrpt::img::CImage image
The image captured by the camera, that is, the main piece of information of this observation.
#define THROW_EXCEPTION(msg)
virtual ~CCascadeClassifierDetection()
This namespace contains representation of robot actions and observations.
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage".
mrpt::img::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
This class allows loading and storing values and vectors of different types from a configuration text...
virtual void detectObjects_Impl(const mrpt::obs::CObservation *obs, vector_detectable_object &detected)
Detect objects in a *CObservation.
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
virtual void init(const mrpt::config::CConfigFileBase &cfg)
Initialize cascade classifier detection.
std::shared_ptr< CDetectable2D > Ptr
GLenum GLsizei GLsizei height
std::shared_ptr< CDetectableObject > Ptr
A class for storing images as grayscale or RGB bitmaps.
@ FAST_REF_OR_CONVERT_TO_GRAY
std::vector< CDetectableObject::Ptr > vector_detectable_object
GLenum GLsizei GLenum GLenum const GLvoid * image
CCascadeClassifierDetection()
Declares a class that represents any robot's observation.
Declares a class derived from "CObservation" that encapsules an image from a camera,...
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |