Skip to content

Commit 4890022

Browse files
author
Dinar Ahmatnurov
committed
Merge branch 'master' of https://github.com/Itseez/opencv_contrib into latentsvm_caskade
2 parents c915bd4 + 08699f1 commit 4890022

File tree

101 files changed

+2272
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2272
-414
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ If you prefer using the gui version of cmake (cmake-gui), then, you can add `ope
4545
6. press the `configure` button followed by the `generate` button (the first time, you will be asked which makefile style to use)
4646

4747
7. build the `opencv` core with the method you chose (make and make install if you chose Unix makfile at step 6)
48+
49+
### Update the repository documentation
50+
51+
In order to keep a clean overview containing all contributed modules the following files need to be created/adapted.
52+
53+
1. Update the README.md file under the modules folder. Here you add your model with a single line description.
54+
55+
2. Add a README.md inside your own module folder. This README explains which functionality (seperate functions) is available, links to the corresponding samples and explains in somewhat more detail what the module is expected to do. If any extra requirements are needed to build the module without problems, add them here also.

modules/README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
Please put your module here.
1+
An overview of the contrib modules and a small explanation
2+
----------------------------------------------------------
3+
4+
This list gives an overview of all modules available inside the contrib repository.
5+
These are also the correct names for disabling the building of a specific module by adding
6+
7+
```
8+
$ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_reponame=OFF <opencv_source_directory>
9+
```
10+
11+
1. **opencv_adas**: Advanced Driver Assistance Systems module with Forward Collision Warning.
12+
13+
2. **opencv_bgsegm**: Improved Adaptive Background Mixture Model for Real-time Tracking / Visual Tracking of Human Visitors under Variable-Lighting Conditions.
14+
15+
3. **opencv_bioinspired**: Biologically inspired vision models and derivated tools.
16+
17+
4. **opencv_ ccalib**: Custom Calibration Pattern for 3D reconstruction.
18+
19+
5. **opencv_cvv**: GUI for Interactive Visual Debugging of Computer Vision Programs.
20+
21+
6. **opencv_datasettools**: Tools for working with different datasets.
22+
23+
7. **opencv_face**: Recently added face recognition software which is not yet stabalized.
24+
25+
8. **opencv_line_descriptor**: Binary descriptors for lines extracted from an image.
26+
27+
9. **opencv_matlab**: OpenCV Matlab Code Generator.
28+
29+
10. **opencv_optflow**: Optical Flow Algorithms for tracking points.
30+
31+
11. **opencv_reg**: Image Registration module.
32+
33+
12. **opencv_rgbd**: RGB-Depth Processing module.
34+
35+
13. **opencv_saliency**: Saliency API, understanding where humans focus given a scene.
36+
37+
14. **opencv_surface_matching**: Surface Matching Algorithm Through 3D Features.
38+
39+
15. **opencv_text**: Scene Text Detection and Recognition in Natural Scene Images.
40+
41+
16. **opencv_tracking**: Long-term optical tracking API.
42+
43+
17. **opencv_xfeatures2d**: Extra 2D Features Framework containing experimental and non-free 2D feature algorithms.
44+
45+
18. **opencv_ximgproc**: Extended Image Processing: Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels.
46+
47+
19. **opencv_xobjdetect**: Integral Channel Features Detector Framework.
48+
49+
20. **opencv_xphoto**: Additional photo processing algorithms: Color balance / Denoising / Inpainting.

modules/adas/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ADAS: Advanced Driver Assistance Systems module with Forward Collision Warning
2+
==============================================================================

modules/adas/tools/fcw_detect/fcw_detect.cpp

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,29 @@ static Mat visualize(const Mat &image, const vector<Rect> &objects)
4848
}
4949
return img;
5050
}
51+
static bool read_window_size(const char *str, int *rows, int *cols)
52+
{
53+
int pos = 0;
54+
if( sscanf(str, "%dx%d%n", rows, cols, &pos) != 2 || str[pos] != '\0' ||
55+
*rows <= 0 || *cols <= 0)
56+
{
57+
return false;
58+
}
59+
return true;
60+
}
5161

5262
int main(int argc, char *argv[])
5363
{
5464
const string keys =
55-
"{help | | print this message}"
56-
"{model_filename | model.xml | filename for reading model}"
57-
"{image_path | test.png | path to image for detection}"
58-
"{out_image_path | out.png | path to image for output}"
59-
"{threshold | 0.0 | threshold for cascade}"
65+
"{help | | print this message}"
66+
"{model_filename | model.xml | filename for reading model}"
67+
"{image_path | test.png | path to image for detection}"
68+
"{out_image_path | out.png | path to image for output}"
69+
"{threshold | 0.0 | threshold for cascade}"
70+
"{step | 8 | sliding window step}"
71+
"{min_window_size | 40x40 | min window size in pixels}"
72+
"{max_window_size | 300x300 | max window size in pixels}"
73+
"{is_grayscale | false | read the image as grayscale}"
6074
;
6175

6276
CommandLineParser parser(argc, argv, keys);
@@ -71,7 +85,31 @@ int main(int argc, char *argv[])
7185
string model_filename = parser.get<string>("model_filename");
7286
string image_path = parser.get<string>("image_path");
7387
string out_image_path = parser.get<string>("out_image_path");
88+
bool is_grayscale = parser.get<bool>("is_grayscale");
7489
float threshold = parser.get<float>("threshold");
90+
int step = parser.get<int>("step");
91+
92+
int min_rows, min_cols, max_rows, max_cols;
93+
string min_window_size = parser.get<string>("min_window_size");
94+
if( !read_window_size(min_window_size.c_str(), &min_rows,
95+
&min_cols) )
96+
{
97+
cerr << "Error reading min window size from `" << min_window_size << "`" << endl;
98+
return 1;
99+
}
100+
string max_window_size = parser.get<string>("max_window_size");
101+
if( !read_window_size(max_window_size.c_str(), &max_rows,
102+
&max_cols) )
103+
{
104+
cerr << "Error reading max window size from `" << max_window_size << "`" << endl;
105+
return 1;
106+
}
107+
108+
int color;
109+
if(is_grayscale == false)
110+
color = cv::IMREAD_COLOR;
111+
else
112+
color = cv::IMREAD_GRAYSCALE;
75113

76114

77115
if( !parser.check() )
@@ -85,8 +123,10 @@ int main(int argc, char *argv[])
85123
detector.read(fs["icfdetector"]);
86124
fs.release();
87125
vector<Rect> objects;
88-
Mat img = imread(image_path);
89-
detector.detect(img, objects, 1.1f, Size(40, 40),
90-
Size(300, 300), threshold);
126+
Mat img = imread(image_path, color);
127+
std::vector<float> values;
128+
detector.detect(img, objects, 1.1f, Size(min_cols, min_rows), Size(max_cols, max_rows), threshold, step, values);
91129
imwrite(out_image_path, visualize(img, objects));
130+
131+
92132
}

modules/adas/tools/fcw_train/fcw_train.cpp

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ using cv::imread;
2626
#include <opencv2/core/utility.hpp>
2727
using cv::CommandLineParser;
2828
using cv::FileStorage;
29+
#include <opencv2/core/utility.hpp>
30+
31+
#include <ctime> // std::time
32+
#include <cstdlib> // std::rand, std::srand
2933

3034
#include <opencv2/xobjdetect.hpp>
3135

36+
3237
using cv::xobjdetect::ICFDetectorParams;
3338
using cv::xobjdetect::ICFDetector;
3439
using cv::xobjdetect::WaldBoost;
@@ -46,8 +51,11 @@ static bool read_model_size(const char *str, int *rows, int *cols)
4651
return true;
4752
}
4853

54+
static int randomPred (int i) { return std::rand()%i;}
55+
4956
int main(int argc, char *argv[])
5057
{
58+
5159
const string keys =
5260
"{help | | print this message}"
5361
"{pos_path | pos | path to training object samples}"
@@ -57,8 +65,15 @@ int main(int argc, char *argv[])
5765
"{weak_count | 100 | number of weak classifiers in cascade}"
5866
"{model_size | 40x40 | model size in pixels}"
5967
"{model_filename | model.xml | filename for saving model}"
68+
"{features_type | icf | features type, \"icf\" or \"acf\"}"
69+
"{alpha | 0.02 | alpha value}"
70+
"{is_grayscale | false | read the image as grayscale}"
71+
"{use_fast_log | false | use fast log function}"
72+
"{limit_ps | -1 | limit to positive samples (-1 means all)}"
73+
"{limit_bg | -1 | limit to negative samples (-1 means all)}"
6074
;
6175

76+
6277
CommandLineParser parser(argc, argv, keys);
6378
parser.about("FCW trainer");
6479

@@ -76,15 +91,22 @@ int main(int argc, char *argv[])
7691
params.feature_count = parser.get<int>("feature_count");
7792
params.weak_count = parser.get<int>("weak_count");
7893
params.bg_per_image = parser.get<int>("bg_per_image");
79-
94+
params.features_type = parser.get<string>("features_type");
95+
params.alpha = parser.get<float>("alpha");
96+
params.is_grayscale = parser.get<bool>("is_grayscale");
97+
params.use_fast_log = parser.get<bool>("use_fast_log");
98+
99+
int limit_ps = parser.get<int>("limit_ps");
100+
int limit_bg = parser.get<int>("limit_bg");
101+
80102
string model_size = parser.get<string>("model_size");
81103
if( !read_model_size(model_size.c_str(), &params.model_n_rows,
82104
&params.model_n_cols) )
83105
{
84106
cerr << "Error reading model size from `" << model_size << "`" << endl;
85107
return 1;
86108
}
87-
109+
88110
if( params.feature_count <= 0 )
89111
{
90112
cerr << "feature_count must be positive number" << endl;
@@ -97,20 +119,67 @@ int main(int argc, char *argv[])
97119
return 1;
98120
}
99121

100-
if( params.bg_per_image <= 0 )
122+
if( params.features_type != "icf" && params.features_type != "acf" )
101123
{
102-
cerr << "bg_per_image must be positive number" << endl;
124+
cerr << "features_type must be \"icf\" or \"acf\"" << endl;
125+
return 1;
126+
}
127+
if( params.alpha <= 0 )
128+
{
129+
cerr << "alpha must be positive float number" << endl;
103130
return 1;
104131
}
105-
106132
if( !parser.check() )
107133
{
108134
parser.printErrors();
109135
return 1;
110136
}
137+
138+
std::vector<cv::String> pos_filenames;
139+
glob(pos_path, pos_filenames);
140+
141+
std::vector<cv::String> bg_filenames;
142+
glob(bg_path, bg_filenames);
143+
144+
if(limit_ps != -1 && (int)pos_filenames.size() > limit_ps)
145+
pos_filenames.erase(pos_filenames.begin()+limit_ps, pos_filenames.end());
146+
if(limit_bg != -1 && (int)bg_filenames.size() > limit_bg)
147+
bg_filenames.erase(bg_filenames.begin()+limit_bg, bg_filenames.end());
148+
149+
//random pick input images
150+
bool random_shuffle = false;
151+
if(random_shuffle)
152+
{
153+
std::srand ( unsigned ( std::time(0) ) );
154+
std::random_shuffle ( pos_filenames.begin(), pos_filenames.end(), randomPred );
155+
std::random_shuffle ( bg_filenames.begin(), bg_filenames.end(), randomPred );
156+
}
157+
158+
int samples_size = (int)((params.bg_per_image * bg_filenames.size()) + pos_filenames.size());
159+
int features_size = params.feature_count;
160+
int max_features_allowed = (int)(INT_MAX/(sizeof(int)* samples_size));
161+
int max_samples_allowed = (int)(INT_MAX/(sizeof(int)* features_size));
162+
int total_samples = (int)((params.bg_per_image * bg_filenames.size()) + pos_filenames.size());
163+
164+
165+
if(total_samples >max_samples_allowed)
166+
{
167+
CV_Error_(1, ("exceeded maximum number of samples. Maximum number of samples with %d features is %d, you have %d (%d positive samples + (%d bg * %d bg_per_image))\n",features_size,max_samples_allowed,total_samples,pos_filenames.size(),bg_filenames.size(),params.bg_per_image ));
168+
}
169+
170+
if(params.feature_count >max_features_allowed)
171+
{
172+
CV_Error_(1, ("exceeded maximum number of features. Maximum number of features with %d samples is %d, you have %d\n",samples_size,max_features_allowed, features_size ));
173+
}
174+
175+
std::cout<<pos_filenames.size()<<std::endl;
176+
std::cout<<bg_filenames.size()<<std::endl;
177+
178+
ICFDetector detector;
179+
180+
181+
detector.train(pos_filenames, bg_filenames, params);
111182

112-
ICFDetector detector;
113-
detector.train(pos_path, bg_path, params);
114183
FileStorage fs(model_filename, FileStorage::WRITE);
115184
fs << "icfdetector";
116185
detector.write(fs);

modules/bgsegm/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Improved Background-Foreground Segmentation Methods
2+
===================================================
3+
4+
1. Adaptive Background Mixture Model for Real-time Tracking
5+
2. Visual Tracking of Human Visitors under Variable-Lighting Conditions.

modules/bioinspired/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Biologically inspired vision models and derivated tools
2+
=======================================================

modules/bioinspired/include/opencv2/bioinspired/retina.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ enum {
8585
};
8686

8787
/**
88-
* @class Retina a wrapper class which allows the Gipsa/Listic Labs model to be used with OpenCV.
88+
* a wrapper class which allows the Gipsa/Listic Labs model to be used with OpenCV.
8989
* This retina model allows spatio-temporal image processing (applied on still images, video sequences).
9090
* As a summary, these are the retina model properties:
9191
* => It applies a spectral whithening (mid-frequency details enhancement)
@@ -176,7 +176,6 @@ class CV_EXPORTS_W Retina : public Algorithm {
176176
* => if the xml file does not exist, then default setup is applied
177177
* => warning, Exceptions are thrown if read XML file is not valid
178178
* @param newParameters : a parameters structures updated with the new target configuration
179-
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
180179
*/
181180
CV_WRAP virtual void setup(RetinaParameters newParameters)=0;
182181

@@ -193,7 +192,7 @@ class CV_EXPORTS_W Retina : public Algorithm {
193192

194193
/**
195194
* write xml/yml formated parameters information
196-
* @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information
195+
* @param fs : the filename of the xml file that will be open and writen with formatted parameters information
197196
*/
198197
CV_WRAP virtual void write( String fs ) const=0;
199198

modules/bioinspired/include/opencv2/bioinspired/retinafasttonemapping.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace cv{
8080
namespace bioinspired{
8181

8282
/**
83-
* @class RetinaFastToneMappingImpl a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV.
83+
* a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV.
8484
* This algorithm is already implemented in thre Retina class (retina::applyFastToneMapping) but used it does not require all the retina model to be allocated. This allows a light memory use for low memory devices (smartphones, etc.
8585
* As a summary, these are the model properties:
8686
* => 2 stages of local luminance adaptation with a different local neighborhood for each.

modules/bioinspired/include/opencv2/bioinspired/transientareassegmentationmodule.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
116116
* try to open an XML segmentation parameters file to adjust current segmentation instance setup
117117
* => if the xml file does not exist, then default setup is applied
118118
* => warning, Exceptions are thrown if read XML file is not valid
119-
* @param retinaParameterFile : the parameters filename
119+
* @param segmentationParameterFile : the parameters filename
120120
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
121121
*/
122122
CV_WRAP virtual void setup(String segmentationParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
@@ -135,7 +135,6 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
135135
* => if the xml file does not exist, then default setup is applied
136136
* => warning, Exceptions are thrown if read XML file is not valid
137137
* @param newParameters : a parameters structures updated with the new target configuration
138-
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
139138
*/
140139
CV_WRAP virtual void setup(SegmentationParameters newParameters)=0;
141140

@@ -152,7 +151,7 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
152151

153152
/**
154153
* write xml/yml formated parameters information
155-
* @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information
154+
* @param fs : the filename of the xml file that will be open and writen with formatted parameters information
156155
*/
157156
CV_WRAP virtual void write( String fs ) const=0;
158157

@@ -181,9 +180,8 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
181180
CV_WRAP virtual void clearAllBuffers()=0;
182181
};
183182

184-
/**
185-
* allocator
186-
* @param Size : size of the images input to segment (output will be the same size)
183+
/** allocator
184+
* @param inputSize : size of the images input to segment (output will be the same size)
187185
*/
188186
CV_EXPORTS_W Ptr<TransientAreasSegmentationModule> createTransientAreasSegmentationModule(Size inputSize);
189187

0 commit comments

Comments
 (0)