AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
detector.h
1 #ifndef DETECTOR_H
2 #define DETECTOR_H
3 
4 #include <iostream>
5 #include <vector>
6 
7 #include <opencv2/highgui/highgui.hpp>
8 #include <opencv2/imgcodecs.hpp>
9 #include <opencv2/imgproc.hpp>
10 
11 
12 class Detector
13 {
14 
15 public:
16 
17 
18 
19  static int templateMatching(cv::Mat img, std::vector<cv::Mat> templVector,
20  std::vector<std::vector<cv::Point>> *found4CornersVector, std::vector<double> *bestValues,
21  int templ_method = cv::TM_SQDIFF,
22  std::vector<double> scaleFactors = std::vector<double>(),
23  bool showDisplay = true);
24 
25  static int templateMatching(cv::Mat img, cv::Mat templ,
26  std::vector<cv::Point> *found4Corners, double* bestValue = NULL,
27  int templ_method = cv::TM_SQDIFF,
28  std::vector<double> scaleFactors = std::vector<double>(),
29  bool showDisplay = true);
30 
31  static void drawSquares( cv::Mat image, const std::vector<std::vector<cv::Point> > squares,
32  const char* wndname = "Square Detection Demo");
33 
34 
35  static int findSquare(cv::Mat &image, std::vector<std::vector<cv::Point>> *found4CornersVector,
36  int threshLevels = 11, int cannyThresh = 50);
37 
38 private:
39  // Disallow creating an instance of this object, it is useless since all functions are static
40  Detector();
41 
42  static void MatchingMethod(int match_method, cv::Mat img, cv::Mat templ,
43  cv::Point *bestMatch, double *minMaxVal);
44 
45 
46  static void _findSquares( const cv::Mat& image, std::vector<std::vector<cv::Point> >& squares,
47  int N, int thresh);
48  static int orderAngles(std::vector<std::vector<cv::Point>> angles, std::vector<std::vector<cv::Point>> *orderedAngles);
49  static int orderAngles(std::vector<cv::Point> angles, std::vector<cv::Point> *orderedAngles);
50  static cv::Point getCenter(std::vector<cv::Point> points);
51  static double angle( cv::Point pt1, cv::Point pt2, cv::Point pt0 );
52 
53 
54 };
55 
56 #endif // DETECTOR_H
static int findSquare(cv::Mat &image, std::vector< std::vector< cv::Point >> *found4CornersVector, int threshLevels=11, int cannyThresh=50)
Detector::findSquare find all square in images, exploiting functions of opencv. In practice is a blob...
Definition: detector.cpp:28
static void drawSquares(cv::Mat image, const std::vector< std::vector< cv::Point > > squares, const char *wndname="Square Detection Demo")
Detector::drawSquares function to draw square in images.
Definition: detector.cpp:53
static int templateMatching(cv::Mat img, std::vector< cv::Mat > templVector, std::vector< std::vector< cv::Point >> *found4CornersVector, std::vector< double > *bestValues, int templ_method=cv::TM_SQDIFF, std::vector< double > scaleFactors=std::vector< double >(), bool showDisplay=true)
Detector::templateMatching check function below, this one is used if multiple templates want be used...
Definition: detector.cpp:269