#include #include #include /* srand, rand */ #include #include #include "utils.h" #include #include #include #include #include "Yolo3Detection.h" bool gRun; bool SAVE_RESULT = false; void sig_handler(int signo) { std::cout<<"request gateway stop\n"; gRun = false; } int main(int argc, char *argv[]) { std::cout<<"detection\n"; signal(SIGINT, sig_handler); char *net = "yolo3_berkeley.rt"; if(argc > 1) net = argv[1]; char *input = "../demo/yolo_test.mp4"; if(argc > 2) input = argv[2]; tk::dnn::Yolo3Detection yolo; yolo.init(net); gRun = true; cv::VideoCapture cap(input); if(!cap.isOpened()) gRun = false; else std::cout<<"camera started\n"; cv::VideoWriter resultVideo; if(SAVE_RESULT) { int w = cap.get(cv::CAP_PROP_FRAME_WIDTH); int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT); resultVideo.open("result.mp4", cv::VideoWriter::fourcc('M','P','4','V'), 30, cv::Size(w, h)); } cv::Mat frame; cv::Mat dnn_input; cv::namedWindow("detection", cv::WINDOW_NORMAL); while(gRun) { cap >> frame; if(!frame.data) { break; } // this will be resized to the net format dnn_input = frame.clone(); // TODO: async infer yolo.update(dnn_input); // draw dets for(int i=0; iclassesNames[b.cl]; float prob = b.prob; std::cout<