mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 12:55:15 +08:00
Remove icf app, add xobjdetect module
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
add_definitions(-D__OPENCV_BUILD=1)
|
|
||||||
link_libraries(${OPENCV_LINKER_LIBS})
|
|
||||||
|
|
||||||
add_subdirectory(icf)
|
|
4
modules/adas/CMakeLists.txt
Normal file
4
modules/adas/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
set(the_description "Automatic driver assistance algorithms")
|
||||||
|
ocv_define_module(adas opencv_xobjdetect)
|
||||||
|
|
||||||
|
add_subdirectory(tools)
|
@@ -1,7 +1,8 @@
|
|||||||
set(name icf)
|
set(name fcw-train)
|
||||||
set(the_target opencv_${name})
|
set(the_target opencv_${name})
|
||||||
|
|
||||||
set(OPENCV_${the_target}_DEPS opencv_core opencv_imgproc opencv_highgui)
|
set(OPENCV_${the_target}_DEPS opencv_xobjdetect)
|
||||||
|
|
||||||
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
|
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
|
||||||
|
|
||||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||||
@@ -24,7 +25,7 @@ set_target_properties(${the_target} PROPERTIES
|
|||||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||||
INSTALL_NAME_DIR lib
|
INSTALL_NAME_DIR lib
|
||||||
OUTPUT_NAME "opencv_trainicfcascade")
|
OUTPUT_NAME ${the_target})
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
|
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
|
@@ -17,11 +17,14 @@ using std::stringstream;
|
|||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
using cv::Rect;
|
using cv::Rect;
|
||||||
|
|
||||||
#include "icfdetector.hpp"
|
#include <opencv2/xobjdetect/icfdetector.hpp>
|
||||||
#include "waldboost.hpp"
|
#include <opencv2/xobjdetect/waldboost.hpp>
|
||||||
|
|
||||||
using cv::adas::ICFDetectorParams;
|
using cv::adas::ICFDetectorParams;
|
||||||
using cv::adas::ICFDetector;
|
using cv::adas::ICFDetector;
|
||||||
|
using cv::adas::WaldBoost;
|
||||||
|
using cv::adas::WaldBoostParams;
|
||||||
|
using cv::Mat;
|
||||||
|
|
||||||
static bool read_pos_int(const char *str, int *n)
|
static bool read_pos_int(const char *str, int *n)
|
||||||
{
|
{
|
||||||
@@ -171,6 +174,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
WaldBoostParams p;
|
||||||
|
WaldBoost b(p);
|
||||||
|
b.train(Mat(), Mat());
|
||||||
ICFDetector detector;
|
ICFDetector detector;
|
||||||
vector<string> filenames;
|
vector<string> filenames;
|
||||||
vector< vector<Rect> > labelling;
|
vector< vector<Rect> > labelling;
|
2
modules/xobjdetect/CMakeLists.txt
Normal file
2
modules/xobjdetect/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
set(the_description "Object detection algorithms")
|
||||||
|
ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_highgui)
|
9
modules/xobjdetect/include/opencv2/xobjdetect.hpp
Normal file
9
modules/xobjdetect/include/opencv2/xobjdetect.hpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __OPENCV_XOBJDETECT_XOBJDETECT_HPP__
|
||||||
|
#define __OPENCV_XOBJDETECT_XOBJDETECT_HPP__
|
||||||
|
|
||||||
|
#include "xobjdetect/stump.hpp"
|
||||||
|
#include "xobjdetect/waldboost.hpp"
|
||||||
|
#include "xobjdetect/acffeature.hpp"
|
||||||
|
#include "xobjdetect/icfdetector.hpp"
|
||||||
|
|
||||||
|
#endif /* __OPENCV_XOBJDETECT_XOBJDETECT_HPP__ */
|
@@ -59,7 +59,7 @@ namespace adas
|
|||||||
*/
|
*/
|
||||||
void computeChannels(InputArray image, OutputArrayOfArrays channels);
|
void computeChannels(InputArray image, OutputArrayOfArrays channels);
|
||||||
|
|
||||||
class ACFFeatureEvaluator
|
class CV_EXPORTS ACFFeatureEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Construct evaluator, set features to evaluate */
|
/* Construct evaluator, set features to evaluate */
|
@@ -52,7 +52,7 @@ namespace cv
|
|||||||
namespace adas
|
namespace adas
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ICFDetectorParams
|
struct CV_EXPORTS ICFDetectorParams
|
||||||
{
|
{
|
||||||
int feature_count;
|
int feature_count;
|
||||||
int weak_count;
|
int weak_count;
|
||||||
@@ -61,7 +61,7 @@ struct ICFDetectorParams
|
|||||||
double overlap;
|
double overlap;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ICFDetector
|
class CV_EXPORTS ICFDetector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Train detector
|
/* Train detector
|
@@ -8,7 +8,7 @@ namespace cv
|
|||||||
namespace adas
|
namespace adas
|
||||||
{
|
{
|
||||||
|
|
||||||
class Stump
|
class CV_EXPORTS Stump
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@@ -44,21 +44,21 @@ the use of this software, even if advised of the possibility of such damage.
|
|||||||
|
|
||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
|
|
||||||
#include "acffeature.hpp"
|
#include <opencv2/xobjdetect/acffeature.hpp>
|
||||||
#include "stump.hpp"
|
#include <opencv2/xobjdetect/stump.hpp>
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
namespace adas
|
namespace adas
|
||||||
{
|
{
|
||||||
|
|
||||||
struct WaldBoostParams
|
struct CV_EXPORTS WaldBoostParams
|
||||||
{
|
{
|
||||||
int weak_count;
|
int weak_count;
|
||||||
float alpha;
|
float alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WaldBoost
|
class CV_EXPORTS WaldBoost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Initialize WaldBoost cascade with default of specified parameters */
|
/* Initialize WaldBoost cascade with default of specified parameters */
|
@@ -1,4 +1,4 @@
|
|||||||
#include "acffeature.hpp"
|
#include <opencv2/xobjdetect/acffeature.hpp>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
@@ -1,5 +1,5 @@
|
|||||||
#include "icfdetector.hpp"
|
#include <opencv2/xobjdetect/icfdetector.hpp>
|
||||||
#include "waldboost.hpp"
|
#include <opencv2/xobjdetect/waldboost.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@ void ICFDetector::train(const vector<string>& image_filenames,
|
|||||||
|
|
||||||
vector<Mat> samples; /* positive samples + negative samples */
|
vector<Mat> samples; /* positive samples + negative samples */
|
||||||
Mat sample, resized_sample;
|
Mat sample, resized_sample;
|
||||||
int pos_count = 0;
|
size_t pos_count = 0;
|
||||||
for( size_t i = 0; i < image_filenames.size(); ++i, ++pos_count )
|
for( size_t i = 0; i < image_filenames.size(); ++i, ++pos_count )
|
||||||
{
|
{
|
||||||
Mat img = imread(image_filenames[i]);
|
Mat img = imread(String(image_filenames[i].c_str()));
|
||||||
for( size_t j = 0; j < labelling[i].size(); ++j )
|
for( size_t j = 0; j < labelling[i].size(); ++j )
|
||||||
{
|
{
|
||||||
Rect r = labelling[i][j];
|
Rect r = labelling[i][j];
|
||||||
@@ -59,10 +59,10 @@ void ICFDetector::train(const vector<string>& image_filenames,
|
|||||||
|
|
||||||
int neg_count = 0;
|
int neg_count = 0;
|
||||||
RNG rng;
|
RNG rng;
|
||||||
for( size_t i = 0; i < image_filenames.size(); ++i, ++neg_count )
|
for( size_t i = 0; i < image_filenames.size(); ++i )
|
||||||
{
|
{
|
||||||
Mat img = imread(image_filenames[i]);
|
Mat img = imread(String(image_filenames[i].c_str()));
|
||||||
for( size_t j = 0; j < pos_count / image_filenames.size() + 1; ++j )
|
for( size_t j = 0; j < pos_count / image_filenames.size() + 1; )
|
||||||
{
|
{
|
||||||
Rect r;
|
Rect r;
|
||||||
r.x = rng.uniform(0, img.cols);
|
r.x = rng.uniform(0, img.cols);
|
||||||
@@ -73,9 +73,10 @@ void ICFDetector::train(const vector<string>& image_filenames,
|
|||||||
if( !overlap(r, labelling[i]) )
|
if( !overlap(r, labelling[i]) )
|
||||||
{
|
{
|
||||||
sample = img.colRange(r.x, r.width).rowRange(r.y, r.height);
|
sample = img.colRange(r.x, r.width).rowRange(r.y, r.height);
|
||||||
resize(sample, resized_sample);
|
//resize(sample, resized_sample);
|
||||||
samples.push_back(resized_sample);
|
samples.push_back(resized_sample);
|
||||||
++neg_count;
|
++neg_count;
|
||||||
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
#include "stump.hpp"
|
#include <opencv2/xobjdetect/stump.hpp>
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
@@ -3,7 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
#include "waldboost.hpp"
|
#include <opencv2/xobjdetect/waldboost.hpp>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
Reference in New Issue
Block a user