This commit is contained in:
Francesco Gatti
2019-02-18 15:51:57 +00:00
parent 0d682136de
commit 13063b904d
3 changed files with 15 additions and 8 deletions
+4 -3
View File
@@ -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<yolo.detected.size(); i++) {
@@ -64,7 +66,6 @@ int main(int argc, char *argv[]) {
cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[obj_class], 2);
}
cv::imshow("detection", frame);
cv::waitKey(1);
}
+4
View File
@@ -11,6 +11,8 @@
#include <tkDNN/tkdnn.h>
namespace tk { namespace dnn {
/**
*
* @author Francesco Gatti
@@ -51,3 +53,5 @@ class Yolo3Detection {
void update(cv::Mat &frame);
};
}}
+7 -5
View File
@@ -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<ndets; j++) {
@@ -126,3 +126,5 @@ void Yolo3Detection::update(cv::Mat &imageORIG) {
}
}
}}