1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-18 17:24:28 +08:00

Change of interface and multiple fixes

This commit is contained in:
Vlad Shakhuro
2015-08-03 17:14:28 +03:00
parent 3f1cce24ba
commit d06d7e2918
27 changed files with 917 additions and 2460 deletions

View File

@@ -0,0 +1 @@
add_subdirectory(waldboost_detector)

View File

@@ -0,0 +1,35 @@
set(name waldboost_detector)
set(the_target opencv_${name})
set(OPENCV_${the_target}_DEPS opencv_core opencv_imgcodecs opencv_videoio
opencv_highgui opencv_xobjdetect)
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
if(NOT OCV_DEPENDENCIES_FOUND)
return()
endif()
project(${the_target})
ocv_include_directories("${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules_recurse(${OPENCV_${the_target}_DEPS})
file(GLOB ${the_target}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_executable(${the_target} ${${the_target}_SOURCES})
target_link_libraries(${the_target} ${OPENCV_${the_target}_DEPS})
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
OUTPUT_NAME ${the_target})
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()
install(TARGETS ${the_target} OPTIONAL RUNTIME DESTINATION bin COMPONENT main)

View File

@@ -0,0 +1,33 @@
#include <opencv2/xobjdetect.hpp>
#include <opencv2/imgcodecs/imgcodecs_c.h>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace std;
using namespace cv;
using namespace cv::xobjdetect;
int main(int argc, char **argv)
{
if (argc < 5) {
cerr << "Usage: " << argv[0] << " train <model_filename> <pos_path> <neg_path>" << endl;
cerr << " " << argv[0] << " detect <model_filename> <img_filename> <out_filename>" << endl;
return 0;
}
string mode = argv[1];
WBDetector detector(argv[2]);
if (mode == "train") {
detector.train(argv[3], argv[4]);
} else if (mode == "detect") {
cerr << "detect" << endl;
vector<Rect> bboxes;
vector<double> confidences;
Mat img = imread(argv[3], CV_LOAD_IMAGE_GRAYSCALE);
detector.detect(img, bboxes, confidences);
for (size_t i = 0; i < bboxes.size(); ++i) {
rectangle(img, bboxes[i], Scalar(255, 0, 0));
}
imwrite(argv[4], img);
}
}