vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
set(name waldboost_detector)
|
||||
set(the_target opencv_${name})
|
||||
|
||||
set(OPENCV_${the_target}_DEPS opencv_core opencv_imgproc 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})
|
||||
|
||||
ocv_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}
|
||||
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)
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "opencv2/xobjdetect.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
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> <labelling_filename>" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
string mode = argv[1];
|
||||
Ptr<WBDetector> detector = WBDetector::create();
|
||||
if (mode == "train") {
|
||||
assert(argc == 5);
|
||||
detector->train(argv[3], argv[4]);
|
||||
FileStorage fs(argv[2], FileStorage::WRITE);
|
||||
fs << "waldboost";
|
||||
detector->write(fs);
|
||||
} else if (mode == "detect") {
|
||||
assert(argc == 6);
|
||||
vector<Rect> bboxes;
|
||||
vector<double> confidences;
|
||||
Mat img = imread(argv[3], IMREAD_GRAYSCALE);
|
||||
FileStorage fs(argv[2], FileStorage::READ);
|
||||
detector->read(fs.getFirstTopLevelNode());
|
||||
detector->detect(img, bboxes, confidences);
|
||||
|
||||
FILE *fhandle = fopen(argv[5], "a");
|
||||
for (size_t i = 0; i < bboxes.size(); ++i) {
|
||||
Rect o = bboxes[i];
|
||||
fprintf(fhandle, "%s;%u;%u;%u;%u;%lf\n",
|
||||
argv[3], o.x, o.y, o.width, o.height, confidences[i]);
|
||||
}
|
||||
for (size_t i = 0; i < bboxes.size(); ++i) {
|
||||
rectangle(img, bboxes[i], Scalar(255, 0, 0));
|
||||
}
|
||||
imwrite(argv[4], img);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user