vision
DnnDetector.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __DNN_DETECTOR_HPP__
4 #define __DNN_DETECTOR_HPP__
5 
6 #include <yarp/dev/DeviceDriver.h>
7 
8 #include <opencv2/dnn.hpp>
9 
10 #include "IDetector.hpp"
11 
12 namespace roboticslab
13 {
14 
20 class DnnDetector : public yarp::dev::DeviceDriver,
21  public IDetector
22 {
23 public:
24  bool open(yarp::os::Searchable & config) override;
25  bool detect(const yarp::sig::Image & inYarpImg, yarp::os::Bottle & detectedObjects) override;
26 
27 private:
28  cv::dnn::Net net;
29  std::vector<std::string> classes;
30  std::vector<std::string> outNames;
31 
32  float confThreshold; // Confidence threshold
33  float nmsThreshold; // Non-max supression threshold
34  float scale;
35  cv::Scalar mean;
36 
37  void preprocess(const cv::Mat & frame);
38  void postprocess(const cv::Size & size, const std::vector<cv::Mat> & outs, yarp::os::Bottle & detectedObjects);
39 };
40 
41 } // namespace roboticslab
42 
43 #endif // __DNN_DETECTOR_HPP__
Definition: DnnDetector.hpp:22
Interface for object detection.
Definition: IDetector.hpp:17
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:5