#include #include #include //#define OPENCV #include "yolo_v2_class.hpp" // imported functions from DLL #ifdef OPENCV #include // C++ #pragma comment(lib, "opencv_core249.lib") #pragma comment(lib, "opencv_imgproc249.lib") #pragma comment(lib, "opencv_highgui249.lib") void draw_boxes(cv::Mat mat_img, std::vector result_vec) { for (auto &i : result_vec) { cv::rectangle(mat_img, cv::Rect(i.x, i.y, i.w, i.h), cv::Scalar(50, 200, 50), 1); } cv::imshow("window name", mat_img); cv::waitKey(0); } #endif // OPENCV void show_result(std::vector result_vec) { for (auto &i : result_vec) { std::cout << "obj_id = " << i.obj_id << " - x = " << i.x << ", y = " << i.y << ", w = " << i.w << ", h = " << i.h << ", prob = " << i.prob << std::endl; } } int main(int argc, char *argv[]) { std::string names_file = "../data/coco.names"; std::string cfg_file = "../cfg/yolov3.cfg"; std::string weights_file = "../yolov3.weights"; std::string filename; Detector detector(cfg_file, weights_file); while (true) { std::string filename = "../data/dog.jpg"; // std::cin >> filename; if (filename.size() == 0) break; std::cout << filename; cv::Mat mat_img = cv::imread(filename); std::vector result_vec = detector.detect(mat_img); std::cout << "---eee---"; show_result(result_vec); // draw_boxes(mat_img, result_vec); } return 0; }