From f39160f6e8f4465e9325e235e18f0d9413d1f672 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Sun, 04 Mar 2018 00:09:40 +0000
Subject: [PATCH] Added: calc_anchors
---
src/image.c | 63 ++++++-------------------------
1 files changed, 13 insertions(+), 50 deletions(-)
diff --git a/src/image.c b/src/image.c
index efa7185..64e4158 100644
--- a/src/image.c
+++ b/src/image.c
@@ -188,8 +188,8 @@
int i;
for(i = 0; i < num; ++i){
- int class = max_index(probs[i], classes);
- float prob = probs[i][class];
+ int class_id = max_index(probs[i], classes);
+ float prob = probs[i][class_id];
if(prob > thresh){
//// for comparison with OpenCV version of DNN Darknet Yolo v2
@@ -207,8 +207,8 @@
alphabet = 0;
}
- printf("%s: %.0f%%\n", names[class], prob*100);
- int offset = class*123457 % classes;
+ printf("%s: %.0f%%\n", names[class_id], prob*100);
+ int offset = class_id*123457 % classes;
float red = get_color(2,offset,classes);
float green = get_color(1,offset,classes);
float blue = get_color(0,offset,classes);
@@ -233,7 +233,7 @@
draw_box_width(im, left, top, right, bot, width, red, green, blue);
if (alphabet) {
- image label = get_label(alphabet, names[class], (im.h*.03)/10);
+ image label = get_label(alphabet, names[class_id], (im.h*.03)/10);
draw_label(im, top + width, left, label, rgb);
}
}
@@ -246,8 +246,8 @@
int i;
for (i = 0; i < num; ++i) {
- int class = max_index(probs[i], classes);
- float prob = probs[i][class];
+ int class_id = max_index(probs[i], classes);
+ float prob = probs[i][class_id];
if (prob > thresh) {
int width = show_img->height * .012;
@@ -257,8 +257,8 @@
alphabet = 0;
}
- printf("%s: %.0f%%\n", names[class], prob * 100);
- int offset = class * 123457 % classes;
+ printf("%s: %.0f%%\n", names[class_id], prob * 100);
+ int offset = class_id * 123457 % classes;
float red = get_color(2, offset, classes);
float green = get_color(1, offset, classes);
float blue = get_color(0, offset, classes);
@@ -299,14 +299,14 @@
color.val[2] = blue * 256;
cvRectangle(show_img, pt1, pt2, color, width, 8, 0);
- //printf("left=%d, right=%d, top=%d, bottom=%d, obj_id=%d, obj=%s \n", left, right, top, bot, class, names[class]);
+ //printf("left=%d, right=%d, top=%d, bottom=%d, obj_id=%d, obj=%s \n", left, right, top, bot, class_id, names[class_id]);
cvRectangle(show_img, pt_text_bg1, pt_text_bg2, color, width, 8, 0);
cvRectangle(show_img, pt_text_bg1, pt_text_bg2, color, CV_FILLED, 8, 0); // filled
CvScalar black_color;
black_color.val[0] = 0;
CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, font_size, font_size, 0, font_size * 3, 8);
- cvPutText(show_img, names[class], pt_text, &font, black_color);
+ cvPutText(show_img, names[class_id], pt_text, &font, black_color);
}
}
}
@@ -528,7 +528,7 @@
}
-void show_image_cv_ipl(IplImage *disp, const char *name, const char *out_filename, int http_stream_port)
+void show_image_cv_ipl(IplImage *disp, const char *name)
{
if (disp == NULL) return;
char buff[256];
@@ -538,44 +538,7 @@
//cvMoveWindow(buff, 100*(windows%10) + 200*(windows/10), 100*(windows%10));
++windows;
cvShowImage(buff, disp);
-
-
- // http mjpeg stream: http://localhost:8090
- // use URL with the port number stated in your command line instead of 8090
- if (http_stream_port > 0) {
- //int port = 8090;
- int port = http_stream_port;
- int timeout = 200;
- int jpeg_quality = 30; // 1 - 100
- send_mjpeg(disp, port, timeout, jpeg_quality);
- }
-
-
- if(out_filename)
- {
- CvSize size;
- {
- size.width = disp->width, size.height = disp->height;
- }
-
- static CvVideoWriter* output_video = NULL; // cv::VideoWriter output_video;
- if (output_video == NULL)
- {
- //const char* output_name = "test_dnn_out.avi";
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('H', '2', '6', '4'), 25, size, 1);
- output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1);
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('M', 'J', 'P', 'G'), 25, size, 1);
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('M', 'P', '4', 'V'), 25, size, 1);
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('M', 'P', '4', '2'), 25, size, 1);
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('X', 'V', 'I', 'D'), 25, size, 1);
- //output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('W', 'M', 'V', '2'), 25, size, 1);
- }
-
- cvWriteFrame(output_video, disp); // comment this line to improve FPS !!!
- printf("\n cvWriteFrame \n");
- }
-
- cvReleaseImage(&disp);
+ //cvReleaseImage(&disp);
}
#endif
--
Gitblit v1.10.0