| | |
| | | int class = max_index(probs[i], classes); |
| | | float prob = probs[i][class]; |
| | | if(prob > thresh){ |
| | | //int width = pow(prob, 1./2.)*30+1; |
| | | |
| | | int width = im.h * .012; |
| | | |
| | | if(0){ |
| | | width = pow(prob, 1./2.)*10+1; |
| | | alphabet = 0; |
| | | } |
| | | |
| | | printf("%s: %.0f%%\n", names[class], prob*100); |
| | | int offset = class*1 % classes; |
| | | int offset = class*123457 % classes; |
| | | float red = get_color(2,offset,classes); |
| | | float green = get_color(1,offset,classes); |
| | | float blue = get_color(0,offset,classes); |
| | |
| | | cvReleaseImage(&buffer); |
| | | } |
| | | cvShowImage(buff, disp); |
| | | |
| | | { |
| | | CvSize size; |
| | | { |
| | | size.width = disp->width, size.height = disp->height; |
| | | } |
| | | |
| | | static CvVideoWriter* output_video = NULL; // cv::VideoWriter output_video; |
| | | if (output_video == NULL) |
| | | { |
| | | printf("\n SRC output_video = %p \n", output_video); |
| | | const char* output_name = "test_dnn_out.avi"; |
| | | //output_video = cvCreateVideoWriter(output_name, CV_FOURCC('H', '2', '6', '4'), 25, size, 1); |
| | | output_video = cvCreateVideoWriter(output_name, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1); |
| | | //output_video = cvCreateVideoWriter(output_name, CV_FOURCC('M', 'J', 'P', 'G'), 25, size, 1); |
| | | printf("\n cvCreateVideoWriter, DST output_video = %p \n", output_video); |
| | | } |
| | | |
| | | cvWriteFrame(output_video, disp); |
| | | printf("\n cvWriteFrame \n"); |
| | | } |
| | | |
| | | cvReleaseImage(&disp); |
| | | } |
| | | #endif |
| | |
| | | } |
| | | #endif |
| | | |
| | | void save_image(image im, const char *name) |
| | | void save_image_png(image im, const char *name) |
| | | { |
| | | #ifdef OPENCV |
| | | save_image_jpg(im, name); |
| | | #else |
| | | char buff[256]; |
| | | //sprintf(buff, "%s (%d)", name, windows); |
| | | sprintf(buff, "%s.png", name); |
| | |
| | | int success = stbi_write_png(buff, im.w, im.h, im.c, data, im.w*im.c); |
| | | free(data); |
| | | if(!success) fprintf(stderr, "Failed to write image %s\n", buff); |
| | | } |
| | | |
| | | void save_image(image im, const char *name) |
| | | { |
| | | #ifdef OPENCV |
| | | save_image_jpg(im, name); |
| | | #else |
| | | save_image_png(im, name); |
| | | #endif |
| | | } |
| | | |
| | |
| | | #endif |
| | | } |
| | | |
| | | image resize_max(image im, int max) |
| | | { |
| | | int w = im.w; |
| | | int h = im.h; |
| | | if(w > h){ |
| | | h = (h * max) / w; |
| | | w = max; |
| | | } else { |
| | | w = (w * max) / h; |
| | | h = max; |
| | | } |
| | | if(w == im.w && h == im.h) return im; |
| | | image resized = resize_image(im, w, h); |
| | | return resized; |
| | | } |
| | | |
| | | image resize_min(image im, int min) |
| | | { |
| | | int w = im.w; |