Go to the documentation of this file.
21 #include <mrpt/examples_config.h>
36 string myDataDir(MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"detectors_face/"));
38 MRPT_EXAMPLES_BASE_DIRECTORY +
39 string(
"detectors_face/FACE_DETECTION_TEST.INI"));
49 vector<std::vector<uint32_t>>
ignored;
52 #ifdef MRPT_OPENCV_SRC_DIR
66 cout <<
"Close the window to exit." << endl;
72 win3D.setCameraElevationDeg(20);
73 win3D.setCameraZoom(6.0);
74 win3D.setCameraPointingToPoint(2.5, 0, 0);
80 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
81 gl_points->setPointSize(4.5);
84 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
85 gl_points2->setPointSize(4.5);
88 scene->insert(gl_points);
89 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
92 win3D.unlockAccess3DScene();
106 scene2->insert(gl_points2);
107 scene2->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
119 if (!counter) tictac.
Tic();
125 o = std::dynamic_pointer_cast<CObservation3DRangeScan>(
126 cam->getNextFrame());
142 if (detected.size() > 0)
144 for (
unsigned int i = 0; i < detected.size(); i++)
148 std::dynamic_pointer_cast<CDetectable3D>(detected[i]);
156 win2.showImage(
face.intensityImage);
164 if (!o->hasConfidenceImage)
172 vector<float> xs, ys, zs;
174 for (
unsigned int j = 0;
175 j <
face.confidenceImage.getHeight(); j++)
176 for (
unsigned int k = 0;
177 k <
face.confidenceImage.getWidth();
181 *(
face.confidenceImage.get_unsafe(
186 xs.push_back(
face.points3D_x[i]);
187 ys.push_back(
face.points3D_y[i]);
188 zs.push_back(
face.points3D_z[i]);
195 gl_points2->loadFromPointsMap(&pntsMap);
202 o->intensityImage.rectangle(
212 win.showImage(o->intensityImage);
217 win3D.get3DSceneAndLock();
222 gl_points->loadFromPointsMap(&pntsMap);
223 win3D.unlockAccess3DScene();
228 double t = tictac.
Tac();
229 cout <<
"Frame Rate: " << counter /
t <<
" fps" << endl;
230 fps.push_back(counter /
t);
233 std::this_thread::sleep_for(2ms);
236 cout <<
"Fps mean: " << fps.sumAll() / fps.size() << endl;
240 cout <<
"Closing..." << endl;
252 cerr <<
"The user didn't pick any camera. Exiting." << endl;
267 cout <<
"Close the window to exit." << endl;
274 if (!counter) tictac.
Tic();
279 obs = cam->getNextFrame();
293 std::dynamic_pointer_cast<CObservationImage>(obs);
294 for (
unsigned int i = 0; i < detected.size(); i++)
298 std::dynamic_pointer_cast<CDetectable2D>(detected[i]);
304 win.showImage(o->image);
312 std::dynamic_pointer_cast<CObservationStereoImages>(obs);
314 for (
unsigned int i = 0; i < detected.size(); i++)
318 std::dynamic_pointer_cast<CDetectable2D>(detected[i]);
319 o->imageRight.rectangle(
324 win.showImage(o->imageRight);
329 double t = tictac.
Tac();
330 cout <<
"Frame Rate: " << counter /
t <<
" fps" << endl;
333 std::this_thread::sleep_for(2ms);
336 cout <<
"Closing..." << endl;
349 for (
int i = 1; i < argc; i++)
351 string fileName(argv[i]);
355 cerr <<
"Cannot load " <<
myDataDir + fileName << endl;
365 cout <<
"Detection time: " << tictac.
Tac() <<
" s" << endl;
367 for (
unsigned int i = 0; i < detected.size(); i++)
371 std::dynamic_pointer_cast<CDetectable2D>(detected[i]);
385 vector<double> frame_rates;
387 for (
size_t i = 0; i <
rawlogs.size(); i++)
393 cout <<
"Processing Rawlog [" << i + 1 <<
"/" <<
rawlogs.size()
394 <<
"]: " <<
rawlogs[i] << endl;
396 const unsigned int size = rawlog.
size();
402 for (
unsigned int j = 1; j <
size; j++)
404 if (!counter) tictac.
Tic();
407 std::dynamic_pointer_cast<CObservation3DRangeScan>(
418 double t = tictac.
Tac();
419 frame_rates.push_back(counter /
t);
423 std::this_thread::sleep_for(2ms);
426 unsigned int falsePositivesDeleted, realFacesDeleted;
430 cout <<
"False positives deleted: " << falsePositivesDeleted << endl;
431 cout <<
"Real faces delted: " << realFacesDeleted << endl << endl;
434 cout <<
"Mean frame rate: " <<
sum(frame_rates) / frame_rates.size();
441 void mySplit(
const string& str)
445 cstr =
new char[str.size() + 1];
446 strcpy(cstr, str.c_str());
468 int classifierType = cfg.read_int(
"Example",
"classifierType", 0);
470 if (classifierType == 0)
472 "CascadeClassifier",
"cascadeFileName",
474 "/data/haarcascades/haarcascade_frontalface_alt2.xml");
475 else if (classifierType == 1)
477 "CascadeClassifier",
"cascadeFileName",
480 throw std::runtime_error(
"Incorrect cascade classifier type.");
483 batchMode = cfg.read_bool(
"Example",
"batchMode",
false);
487 string str = cfg.read_string(
"Example",
"rawlogs",
"noRawlogs");
490 size_t numRawlogs =
rawlogs.size();
494 for (
size_t i = 0; i < numRawlogs; i++)
497 rawlogs[i],
"falsePositives", std::vector<uint32_t>(),
503 rawlogsDir = cfg.read_string(
"Example",
"rawlogsDir",
"");
512 int main(
int argc,
char* argv[])
534 catch (std::exception& e)
536 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
541 printf(
"Untyped exception!!");
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
std::shared_ptr< CObservation > Ptr
This class stores a rawlog (robotic datasets) in one of two possible formats:
void registerClass(const mrpt::rtti::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CObject" descendents.
static string OPENCV_SRC_DIR
A map of 2D/3D points with individual colours (RGB).
TColourOptions colorScheme
The options employed when inserting laser scans in the map.
void setWindowTitle(const std::string &str) override
Changes the window title.
A high-performance stopwatch, with typical resolution of nanoseconds.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Specific class for face detection.
GLsizei GLsizei GLuint * obj
void setCameraZoom(float zoom)
Changes the camera parameters programmatically.
Contains classes for various device interfaces.
mrpt::opengl::COpenGLScene::Ptr & get3DSceneAndLock()
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introductio...
vector< std::vector< uint32_t > > falsePositives
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERT_(f)
Defines an assertion mechanism.
std::shared_ptr< CPointCloudColoured > Ptr
void resize(unsigned int width, unsigned int height) override
Resizes the window, stretching the image to fit into the display area.
This namespace contains representation of robot actions and observations.
struct mrpt::detectors::CFaceDetection::TOptions m_options
double Tac() noexcept
Stops the stopwatch.
void detectObjects(const mrpt::obs::CObservation::Ptr obs, vector_detectable_object &detected)
std::shared_ptr< CDetectable3D > Ptr
void TestPrepareDetector()
std::shared_ptr< CObservationStereoImages > Ptr
CCameraSensor::Ptr prepareVideoSourceFromUserSelection()
Show to the user a list of possible camera drivers and creates and open the selected camera.
bool loadFromRawLogFile(const std::string &fileName, bool non_obs_objects_are_legal=false)
Load the contents from a file containing one of these possibilities:
void setCameraPointingToPoint(float x, float y, float z)
Changes the camera parameters programmatically.
void unlockAccess3DScene()
Unlocks the access to the internal 3D scene.
void setAllPoints(const std::vector< float > &X, const std::vector< float > &Y, const std::vector< float > &Z)
Set all the points at once from vectors with X,Y and Z coordinates.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
mrpt::gui::CDisplayWindow3D::Ptr win
char * strtok(char *str, const char *strDelimit, char **context) noexcept
An OS-independent method for tokenizing a string.
size_t size() const
Returns the number of actions / observations object in the sequence.
std::shared_ptr< CObservationImage > Ptr
void setCameraElevationDeg(float deg)
Changes the camera parameters programmatically.
#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 the object with parameters loaded from the given config source.
void Tic() noexcept
Starts the stopwatch.
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
std::shared_ptr< CDetectable2D > Ptr
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
Classes for creating GUI windows for 2D and 3D visualization.
A class for storing images as grayscale or RGB bitmaps.
std::vector< CDetectableObject::Ptr > vector_detectable_object
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
Used in mrpt::serialization::CArchive.
virtual void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
void TestCamera3DFaceDetection(CCameraSensor::Ptr cam)
std::shared_ptr< CObservation3DRangeScan > Ptr
This class allows loading and storing values and vectors of different types from "....
This base provides a set of functions for maths stuff.
CFaceDetection faceDetector
std::shared_ptr< COpenGLScene > Ptr
Base class that contains common atributes and functions of detectable objects.
std::shared_ptr< CCameraSensor > Ptr
string myInitFile(MRPT_EXAMPLES_BASE_DIRECTORY+string("detectors_face/FACE_DETECTION_TEST.INI"))
vector< std::vector< uint32_t > > ignored
void setCameraAzimuthDeg(float deg)
Changes the camera parameters programmatically.
void repaint()
Repaints the window.
CObservation::Ptr getAsObservation(size_t index) const
Returns the i'th element in the sequence, as being an observation, where index=0 is the first object.
GLenum GLuint GLint GLenum face
void debug_returnResults(const std::vector< uint32_t > &falsePositives, const std::vector< uint32_t > &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted)
void TestImagesFaceDetection(int argc, char *argv[])
bool showEachDetectedFace
Declares a class derived from "CObservation" that encapsules an image from a camera,...
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
void experimental_showMeasurements()
void TestCameraFaceDetection()
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
void mySplit(const string &str)
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 | |