export detections to file #239
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
bool SAVE_RESULT = false;
|
bool SAVE_RESULT = false;
|
||||||
|
bool save_detections = true;
|
||||||
|
std::ofstream outfile;
|
||||||
|
|
||||||
void sig_handler(int signo) {
|
void sig_handler(int signo) {
|
||||||
std::cout<<"request gateway stop\n";
|
std::cout<<"request gateway stop\n";
|
||||||
@@ -101,6 +103,11 @@ int main(int argc, char *argv[]) {
|
|||||||
std::vector<cv::Mat> batch_frame;
|
std::vector<cv::Mat> batch_frame;
|
||||||
std::vector<cv::Mat> batch_dnn_input;
|
std::vector<cv::Mat> batch_dnn_input;
|
||||||
|
|
||||||
|
if(save_detections)
|
||||||
|
outfile.open("detections.csv", std::ofstream::out);
|
||||||
|
|
||||||
|
int frame_num = -1;
|
||||||
|
|
||||||
while(gRun) {
|
while(gRun) {
|
||||||
batch_dnn_input.clear();
|
batch_dnn_input.clear();
|
||||||
batch_frame.clear();
|
batch_frame.clear();
|
||||||
@@ -122,6 +129,18 @@ int main(int argc, char *argv[]) {
|
|||||||
detNN->update(batch_dnn_input, n_batch);
|
detNN->update(batch_dnn_input, n_batch);
|
||||||
detNN->draw(batch_frame);
|
detNN->draw(batch_frame);
|
||||||
|
|
||||||
|
if(save_detections){
|
||||||
|
frame_num++;
|
||||||
|
tk::dnn::box b;
|
||||||
|
for(int bi=0; bi<batch_frame.size(); ++bi){
|
||||||
|
for(int i=0; i < detNN->batchDetected[bi].size(); i++) {
|
||||||
|
b = detNN->batchDetected[bi][i];
|
||||||
|
std::string det_class = detNN->classesNames[b.cl];
|
||||||
|
outfile<<frame_num<<";"<<det_class<<";"<<b.x<<";"<<b.y<<";"<<b.x+b.w<<";"<<b.y+b.h<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(show){
|
if(show){
|
||||||
for(int bi=0; bi< n_batch; ++bi){
|
for(int bi=0; bi< n_batch; ++bi){
|
||||||
cv::imshow("detection", batch_frame[bi]);
|
cv::imshow("detection", batch_frame[bi]);
|
||||||
@@ -132,6 +151,9 @@ int main(int argc, char *argv[]) {
|
|||||||
resultVideo << frame;
|
resultVideo << frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(save_detections)
|
||||||
|
outfile.close();
|
||||||
|
|
||||||
std::cout<<"detection end\n";
|
std::cout<<"detection end\n";
|
||||||
double mean = 0;
|
double mean = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user