export detections to file #239

Closed
morrolinux wants to merge 5 commits from cnet into cnet
+22
View File
@@ -10,6 +10,8 @@
bool gRun;
bool SAVE_RESULT = false;
bool save_detections = true;
std::ofstream outfile;
void sig_handler(int signo) {
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_dnn_input;
if(save_detections)
outfile.open("detections.csv", std::ofstream::out);
int frame_num = -1;
while(gRun) {
batch_dnn_input.clear();
batch_frame.clear();
@@ -122,6 +129,18 @@ int main(int argc, char *argv[]) {
detNN->update(batch_dnn_input, n_batch);
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){
for(int bi=0; bi< n_batch; ++bi){
cv::imshow("detection", batch_frame[bi]);
@@ -132,6 +151,9 @@ int main(int argc, char *argv[]) {
resultVideo << frame;
}
if(save_detections)
outfile.close();
std::cout<<"detection end\n";
double mean = 0;