diff --git a/demo/demo/demo.cpp b/demo/demo/demo.cpp index 7a0d547..b8156c6 100644 --- a/demo/demo/demo.cpp +++ b/demo/demo/demo.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { std::cout<<"detection\n"; signal(SIGINT, sig_handler); - Yolo3Detection yolo; + tk::dnn::Yolo3Detection yolo; yolo.init("./"); gRun = true; @@ -39,6 +39,7 @@ int main(int argc, char *argv[]) { std::cout<<"camera started\n"; cv::Mat frame; + cv::Mat dnn_input; cv::namedWindow("detection", cv::WINDOW_NORMAL); cv::resizeWindow("detection", 544*1.2, 320*1.2); @@ -48,7 +49,8 @@ int main(int argc, char *argv[]) { continue; } - yolo.update(frame); + dnn_input = frame.clone(); + yolo.update(dnn_input); // draw dets for(int i=0; i +namespace tk { namespace dnn { + /** * * @author Francesco Gatti @@ -51,3 +53,5 @@ class Yolo3Detection { void update(cv::Mat &frame); }; + +}} diff --git a/src/Yolo3Detection.cpp b/src/Yolo3Detection.cpp index fd492b6..c2f46f6 100644 --- a/src/Yolo3Detection.cpp +++ b/src/Yolo3Detection.cpp @@ -1,5 +1,7 @@ #include "Yolo3Detection.h" +namespace tk { namespace dnn { + bool Yolo3Detection::init(std::string tensor_folder) { //const char *tensor_path = "../data/yolo3/yolo3_berkeley.rt"; @@ -43,7 +45,9 @@ void Yolo3Detection::update(cv::Mat &imageORIG) { if(!imageORIG.data) { std::cout<<"YOLO: NO IMAGE DATA\n"; return; - } + } + float xRatio = float(imageORIG.cols) / float(netRT->input_dim.w); + float yRatio = float(imageORIG.rows) / float(netRT->input_dim.h); resize(imageORIG, imageORIG, cv::Size(netRT->input_dim.w, netRT->input_dim.h)); imageORIG.convertTo(imageF, CV_32FC3, 1/255.0); @@ -83,10 +87,6 @@ void Yolo3Detection::update(cv::Mat &imageORIG) { tk::dnn::Yolo::mergeDetections(dets, ndets, classes); TIMER_STOP - - float xRatio = float(imageORIG.cols) / float(netRT->input_dim.w); - float yRatio = float(imageORIG.rows) / float(netRT->input_dim.h); - // fill detected detected.clear(); for(int j=0; j