| | |
| | | #include "opencv2/videoio/videoio_c.h" |
| | | #endif |
| | | image get_image_from_stream(CvCapture *cap); |
| | | image get_image_from_stream_cpp(CvCapture *cap); |
| | | #include "http_stream.h" |
| | | #endif |
| | | |
| | | float *get_regression_values(char **labels, int n) |
| | |
| | | |
| | | args.min = net.min_crop; |
| | | args.max = net.max_crop; |
| | | args.flip = net.flip; |
| | | args.angle = net.angle; |
| | | args.aspect = net.aspect; |
| | | args.exposure = net.exposure; |
| | |
| | | |
| | | args.min = net.min_crop; |
| | | args.max = net.max_crop; |
| | | args.flip = net.flip; |
| | | args.angle = net.angle; |
| | | args.aspect = net.aspect; |
| | | args.exposure = net.exposure; |
| | |
| | | int *indexes = calloc(topk, sizeof(int)); |
| | | |
| | | for(i = 0; i < m; ++i){ |
| | | int class = -1; |
| | | int class_id = -1; |
| | | char *path = paths[i]; |
| | | for(j = 0; j < classes; ++j){ |
| | | if(strstr(path, labels[j])){ |
| | | class = j; |
| | | class_id = j; |
| | | break; |
| | | } |
| | | } |
| | |
| | | free_image(im); |
| | | top_k(pred, classes, topk, indexes); |
| | | free(pred); |
| | | if(indexes[0] == class) avg_acc += 1; |
| | | if(indexes[0] == class_id) avg_acc += 1; |
| | | for(j = 0; j < topk; ++j){ |
| | | if(indexes[j] == class) avg_topk += 1; |
| | | if(indexes[j] == class_id) avg_topk += 1; |
| | | } |
| | | |
| | | printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1)); |
| | |
| | | |
| | | int size = net.w; |
| | | for(i = 0; i < m; ++i){ |
| | | int class = -1; |
| | | int class_id = -1; |
| | | char *path = paths[i]; |
| | | for(j = 0; j < classes; ++j){ |
| | | if(strstr(path, labels[j])){ |
| | | class = j; |
| | | class_id = j; |
| | | break; |
| | | } |
| | | } |
| | |
| | | free_image(resized); |
| | | top_k(pred, classes, topk, indexes); |
| | | |
| | | if(indexes[0] == class) avg_acc += 1; |
| | | if(indexes[0] == class_id) avg_acc += 1; |
| | | for(j = 0; j < topk; ++j){ |
| | | if(indexes[j] == class) avg_topk += 1; |
| | | if(indexes[j] == class_id) avg_topk += 1; |
| | | } |
| | | |
| | | printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1)); |
| | |
| | | int *indexes = calloc(topk, sizeof(int)); |
| | | |
| | | for(i = 0; i < m; ++i){ |
| | | int class = -1; |
| | | int class_id = -1; |
| | | char *path = paths[i]; |
| | | for(j = 0; j < classes; ++j){ |
| | | if(strstr(path, labels[j])){ |
| | | class = j; |
| | | class_id = j; |
| | | break; |
| | | } |
| | | } |
| | |
| | | free_image(crop); |
| | | top_k(pred, classes, topk, indexes); |
| | | |
| | | if(indexes[0] == class) avg_acc += 1; |
| | | if(indexes[0] == class_id) avg_acc += 1; |
| | | for(j = 0; j < topk; ++j){ |
| | | if(indexes[j] == class) avg_topk += 1; |
| | | if(indexes[j] == class_id) avg_topk += 1; |
| | | } |
| | | |
| | | printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1)); |
| | |
| | | int *indexes = calloc(topk, sizeof(int)); |
| | | |
| | | for(i = 0; i < m; ++i){ |
| | | int class = -1; |
| | | int class_id = -1; |
| | | char *path = paths[i]; |
| | | for(j = 0; j < classes; ++j){ |
| | | if(strstr(path, labels[j])){ |
| | | class = j; |
| | | class_id = j; |
| | | break; |
| | | } |
| | | } |
| | |
| | | free_image(im); |
| | | top_k(pred, classes, topk, indexes); |
| | | free(pred); |
| | | if(indexes[0] == class) avg_acc += 1; |
| | | if(indexes[0] == class_id) avg_acc += 1; |
| | | for(j = 0; j < topk; ++j){ |
| | | if(indexes[j] == class) avg_topk += 1; |
| | | if(indexes[j] == class_id) avg_topk += 1; |
| | | } |
| | | |
| | | printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1)); |
| | |
| | | |
| | | void try_classifier(char *datacfg, char *cfgfile, char *weightfile, char *filename, int layer_num) |
| | | { |
| | | network net = parse_network_cfg(cfgfile); |
| | | network net = parse_network_cfg_custom(cfgfile, 1); |
| | | if(weightfile){ |
| | | load_weights(&net, weightfile); |
| | | } |
| | |
| | | |
| | | void predict_classifier(char *datacfg, char *cfgfile, char *weightfile, char *filename, int top) |
| | | { |
| | | network net = parse_network_cfg(cfgfile); |
| | | network net = parse_network_cfg_custom(cfgfile, 1); |
| | | if(weightfile){ |
| | | load_weights(&net, weightfile); |
| | | } |
| | |
| | | srand(2222222); |
| | | CvCapture * cap; |
| | | |
| | | if(filename){ |
| | | cap = cvCaptureFromFile(filename); |
| | | }else{ |
| | | cap = cvCaptureFromCAM(cam_index); |
| | | } |
| | | if (filename) { |
| | | //cap = cvCaptureFromFile(filename); |
| | | cap = get_capture_video_stream(filename); |
| | | } |
| | | else { |
| | | //cap = cvCaptureFromCAM(cam_index); |
| | | cap = get_capture_webcam(cam_index); |
| | | } |
| | | |
| | | int top = option_find_int(options, "top", 1); |
| | | |
| | |
| | | struct timeval tval_before, tval_after, tval_result; |
| | | gettimeofday(&tval_before, NULL); |
| | | |
| | | image in = get_image_from_stream(cap); |
| | | //image in = get_image_from_stream(cap); |
| | | image in = get_image_from_stream_cpp(cap); |
| | | if(!in.data) break; |
| | | image in_s = resize_image(in, net.w, net.h); |
| | | |
| | |
| | | srand(2222222); |
| | | CvCapture * cap; |
| | | |
| | | if(filename){ |
| | | cap = cvCaptureFromFile(filename); |
| | | }else{ |
| | | cap = cvCaptureFromCAM(cam_index); |
| | | } |
| | | if (filename) { |
| | | //cap = cvCaptureFromFile(filename); |
| | | cap = get_capture_video_stream(filename); |
| | | } |
| | | else { |
| | | //cap = cvCaptureFromCAM(cam_index); |
| | | cap = get_capture_webcam(cam_index); |
| | | } |
| | | |
| | | int top = option_find_int(options, "top", 1); |
| | | |
| | |
| | | struct timeval tval_before, tval_after, tval_result; |
| | | gettimeofday(&tval_before, NULL); |
| | | |
| | | image in = get_image_from_stream(cap); |
| | | //image in = get_image_from_stream(cap); |
| | | image in = get_image_from_stream_cpp(cap); |
| | | image in_s = resize_image(in, net.w, net.h); |
| | | show_image(in, "Threat Detection"); |
| | | |
| | |
| | | { |
| | | #ifdef OPENCV |
| | | printf("Classifier Demo\n"); |
| | | network net = parse_network_cfg(cfgfile); |
| | | network net = parse_network_cfg_custom(cfgfile, 1); |
| | | if(weightfile){ |
| | | load_weights(&net, weightfile); |
| | | } |
| | |
| | | CvCapture * cap; |
| | | |
| | | if(filename){ |
| | | cap = cvCaptureFromFile(filename); |
| | | //cap = cvCaptureFromFile(filename); |
| | | cap = get_capture_video_stream(filename); |
| | | }else{ |
| | | cap = cvCaptureFromCAM(cam_index); |
| | | //cap = cvCaptureFromCAM(cam_index); |
| | | cap = get_capture_webcam(cam_index); |
| | | } |
| | | |
| | | int top = option_find_int(options, "top", 1); |
| | |
| | | struct timeval tval_before, tval_after, tval_result; |
| | | gettimeofday(&tval_before, NULL); |
| | | |
| | | image in = get_image_from_stream(cap); |
| | | //image in = get_image_from_stream(cap); |
| | | image in = get_image_from_stream_cpp(cap); |
| | | image in_s = resize_image(in, net.w, net.h); |
| | | show_image(in, "Classifier"); |
| | | |