How to extract min, max of X, Y in VisualizeBBox?
I want to extract min, max of x, y, so I modified bbox_util.cpp (VisualizeBBox)
like this ---
void VisualizeBBox(const vectorcv::Mat& images, const Blob
const Dtype* detections_data = detections->cpu_data();
const int width = images[0].cols;
const int height = images[0].rows;
vector
int fontface = cv::FONT_HERSHEY_SIMPLEX; double scale = 0.5; int thickness = 1; int baseline = 0; char buffer[50];
/* // file for recoding x,y of object FILE *fp; if( (fp = fopen("XnY_Point.txt", "w")) == NULL) { printf("error\n"); return 0; } */
ofstream outFile("object_infor.txt");
// ************
for (int i = 0; i < num_img; ++i) {
// ----- ajb
outFile << "image num : " << i << "-----" << std::endl;
cv::Mat image = images[i];
// Show FPS.
snprintf(buffer, sizeof(buffer), "FPS: %.2f", fps);
cv::Size text = cv::getTextSize(buffer, fontface, scale, thickness,
&baseline);
cv::rectangle(image, cv::Point(0, 0),
cv::Point(text.width, text.height + baseline),
CV_RGB(255, 255, 255), CV_FILLED);
cv::putText(image, buffer, cv::Point(0, text.height + baseline / 2.),
fontface, scale, CV_RGB(0, 0, 0), thickness, 4);
// Draw bboxes.
for (map<int, vector
// write infor to txt file
// outFile << "detected object num : " << label << " // "; // label = label index
outFile << "detected object class : " << label_name << " // ";
outFile << "X max : " << bboxes[j].xmax() << ", ";
outFile << "X min : " << bboxes[j].xmin() << ", ";
outFile << "Y max : " << bboxes[j].ymax() << ", ";
outFile << "Y min : " << bboxes[j].ymin();
outFile << std::endl;
cv::Point top_left_pt(bboxes[j].xmin(), bboxes[j].ymin());
cv::Point bottom_right_pt(bboxes[j].xmax(), bboxes[j].ymax());
cv::rectangle(image, top_left_pt, bottom_right_pt, color, 4);
cv::Point bottom_left_pt(bboxes[j].xmin(), bboxes[j].ymax());
snprintf(buffer, sizeof(buffer), "%s : %0.2f", label_name.c_str(),
bboxes[j].score());
cv::Size text = cv::getTextSize(buffer, fontface, scale, thickness,
&baseline);
cv::rectangle(
image, bottom_left_pt + cv::Point(0, 0),
bottom_left_pt + cv::Point(text.width, -text.height-baseline),
color, CV_FILLED);
cv::putText(image, buffer, bottom_left_pt - cv::Point(0, baseline),
fontface, scale, CV_RGB(0, 0, 0), thickness, 4);
}
}
// -----ajb
outFile << "-----" << std::endl;
// Save result if required.
if (!save_file.empty()) {
if (!cap_out.isOpened()) {
cv::Size size(image.size().width, image.size().height);
cv::VideoWriter outputVideo(save_file, CV_FOURCC('D', 'I', 'V', 'X'),
30, size, true);
cap_out = outputVideo;
}
cap_out.write(image);
}
/* ------------ */
/* Added for saving video */
if(!cap_out.isOpened()) {
cv::Size S(image.size().width,image.size().height);
cv::VideoWriter outputVideo("output.avi", CV_FOURCC('D','I','V','X'), 24, S, true);
cap_out = outputVideo;
}
else {
cap_out.write(image);
}
/* ----------- */
cv::imshow("detections", image);
if (cv::waitKey(1) == 27) {
raise(SIGINT);
}
}
outFile.close(); start_clock = clock(); }
But, i even extracted num = 0 (i = 0) image information. And another images infors were not extracted. So, Could you let me know how to extract all infor of images? And What file and function use VisualizeBBox func? I did my best to find that things but... I couldn't.. Please tell me about that... Thank You!
The DetectionOutputLayer.c* produces detection output and called that function.
Thank you so much! :D