arrow_detection.h
Go to the documentation of this file.
1  /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  ***************************************************************************************************/
27 
48 
52 
53 /************ proximo passo, ficar so com os quadrados q não têm nada à volta
54 * numa distancia da largura e cumprimento respectivamente deles
55 * ***************/
58 /*
59  *
60  * http://opencv-srf.blogspot.pt/2011/09/object-detection-tracking-using-contours.html
61  * */
62 
63  //colocar "assertes" no código! nas PRÈ condiçoes
64 
65  //colocar funcoes todas com a mesma nomenclatura! (primeira letra peq_segndas palavras.. grde!)
66 
68 
70 
71 //colocar um parametro na funcao principal para dizer qual a camara que quero
72 
76 
77 #ifndef _ARROW_DETECTION_H_
78 #define _ARROW_DETECTION_H_
79 
80 #include <stdlib.h>
81 #include <iostream>
82 #include <stdio.h>
83 #include <string>
84 #include <math.h>
85 #include <vector>
86 #include <map>
87 
88 //ROS
89 #include <ros/ros.h>
90 #include <std_msgs/String.h>
91 
92 #include <sstream>
93 #include <unistd.h>
94 #include <iostream>
95 #include <cmath>
96 
97 #include <sys/types.h>
98 #include <unistd.h>
99 #include <stdlib.h>
100 
101 #include <geometry_msgs/Point.h>
102 
103 
104 //Visp
105 #include <visp/vp1394CMUGrabber.h>
106 #include <visp/vp1394TwoGrabber.h>
107 #include <visp/vpDisplayGDI.h>
108 #include <visp/vpDisplayX.h>
109 #include <visp/vpDot2.h>
110 #include <visp/vpPixelMeterConversion.h>
111 #include <visp/vpPose.h>
112 
113 //OpenCV
114 #include <opencv2/features2d/features2d.hpp>
115 #include <opencv2/highgui/highgui.hpp>
116 #include <opencv2/imgproc/imgproc.hpp>
117 #include <opencv2/calib3d/calib3d.hpp>
118 #include <opencv2/nonfree/nonfree.hpp>
119 #include <opencv2/core/core.hpp>
120 #include <opencv2/opencv.hpp>
121 
122 
124 
128 
129 const unsigned int EROSION_SIZE=1;
130 const unsigned int EROSION_SIZE_MIN=1;
131 const unsigned int THRESH = 100;
132 const unsigned int MAX_THRESH = 255;//Trackbar
133 const unsigned int LINE_THICKNESS = 2;
134 
136 const unsigned short VAL_MAX_LENGTH= 500;
137 const unsigned short VAL_MIN_LENGTH = 100;
138 const float VAL_MIN_RELATION_LENGTH = 1.3;
139 const float VAL_MAX_RELATION_LENGTH = 3.1;
140 
142 const double BBCA_MIN = 1.3;//1.3;
143 const double BBCA_MAX = 1.9;//1.7;
144 const double BBCL_MIN = 7;//12;
145 const double BBCL_MAX = 35;//30;
146 const double CACL_MIN = 4;//6;
147 const double CACL_MAX = 22;//17;
148 const double AREA_MIN = 500;//17;
149 
151 const unsigned short CONVEX_HULL_CORNERS = 5;
152 
154 const unsigned short CONVEX_ARROW_CORNERS = 7;
155 
156 
157 // my files
158 //#include "rotate_image.cpp"
159 
160 //to avoid having to prepend 'cv::' to all openCV related stuff (although I put some of them)
161  using namespace cv;
162 //to avoid having to prepend 'std::' to all standard library related stuff (although I put some of them)
163  using namespace std;
164 
168 
169 //void thresh_callback(int, void* );
171 void boundig_box(Mat & src_tresh, Mat & dst);
172 
174 //vector<RotatedRect> boundig_box_small( Mat & src_tresh, Mat & threshold_output,vector<vector<cv::Point> > contours);
175 vector<RotatedRect> boundig_box_small( Mat & src_tresh, Mat & threshold_output,vector<vector<cv::Point> > contours,
176  cv::Point& src_centre,bool& havepoint);
177 
179 void Opening(Mat & src, Mat & dest,unsigned int erosion_size);
180 
182 void closing(Mat & src, Mat & dest,unsigned int erosion_size);
183 
185 //Point process_bbox_pnts_neighbors(vector<RotatedRect> pontos_retangulos);
187 vector<vector<cv::Point> > find_contours(Mat & src, Mat & dest,const unsigned int & line_thinckness,
188  const unsigned int & erosion_size_min);
189 
192  cv::Point find_arrow(void);
194  void ProcessMyImage(Mat & src, Mat & dest);
195 
197  void ProcessEdges(Mat & src, Mat & dest);
198 
199  void multiplymatrixbool(Mat & src, Mat & matbol);
200 
201  void descritor( Mat & img_object, Mat & img_scene);
202 
203 static bool validate_lengths(cv::Point2f rect_points[],
204  const unsigned short max_length= VAL_MAX_LENGTH,
205  const unsigned short min_length = VAL_MIN_LENGTH,
206  const float min_relation_length = VAL_MIN_RELATION_LENGTH ,
207  const float max_relation_length = VAL_MAX_RELATION_LENGTH
208  );
209 #endif
const unsigned short VAL_MAX_LENGTH
For validate_lengths function.
const double BBCL_MIN
const unsigned short VAL_MIN_LENGTH
const unsigned short CONVEX_HULL_CORNERS
Variable for validate_convexHull.
const float VAL_MIN_RELATION_LENGTH
const double BBCA_MIN
Variables for validate_contour_Area_Length function.
void Opening(Mat &src, Mat &dest, unsigned int erosion_size)
Morphological operation OPENING.
const unsigned int LINE_THICKNESS
void ProcessMyImage(Mat &src, Mat &dest)
Canny.
const double BBCL_MAX
const unsigned int MAX_THRESH
void ProcessEdges(Mat &src, Mat &dest)
Boundig box BW.
cv::Point find_arrow(void)
const unsigned short CONVEX_ARROW_CORNERS
Variable for validate_corners_arrow.
const double AREA_MIN
void multiplymatrixbool(Mat &src, Mat &matbol)
const double BBCA_MAX
const float VAL_MAX_RELATION_LENGTH
const unsigned int THRESH
void closing(Mat &src, Mat &dest, unsigned int erosion_size)
Morphological operation Closing.
static bool validate_lengths(cv::Point2f rect_points[], const unsigned short max_length=VAL_MAX_LENGTH, const unsigned short min_length=VAL_MIN_LENGTH, const float min_relation_length=VAL_MIN_RELATION_LENGTH, const float max_relation_length=VAL_MAX_RELATION_LENGTH)
const double CACL_MAX
void descritor(Mat &img_object, Mat &img_scene)
Find discriptors (Match points)
vector< RotatedRect > boundig_box_small(Mat &src_tresh, Mat &threshold_output, vector< vector< cv::Point > > contours, cv::Point &src_centre, bool &havepoint)
FIND THE SMALLEST BOUNDING BOX.
void boundig_box(Mat &src_tresh, Mat &dst)
FIND THE BOUDING BOX.
const unsigned int EROSION_SIZE
VERIFICAR SE o que esta a detetar é preto! e se é solido!!!!! (cor constante)
const unsigned int EROSION_SIZE_MIN
const double CACL_MIN
vector< vector< cv::Point > > find_contours(Mat &src, Mat &dest, const unsigned int &line_thinckness, const unsigned int &erosion_size_min)
See if the contour have neighbors! (arrow dont have!)


arrow_detection
Author(s): César Sousa
autogenerated on Mon Mar 2 2015 01:31:21