killed some warnings, cam control

This commit is contained in:
Joseph Redmon 2015-11-17 11:00:04 -08:00
parent 0f7f2899b6
commit b394337824
4 changed files with 16 additions and 12 deletions

View File

@ -201,7 +201,7 @@ void rgbgr_image(image im)
} }
#ifdef OPENCV #ifdef OPENCV
void show_image_cv(image p, char *name) void show_image_cv(image p, const char *name)
{ {
int x,y,k; int x,y,k;
image copy = copy_image(p); image copy = copy_image(p);
@ -244,7 +244,7 @@ void show_image_cv(image p, char *name)
} }
#endif #endif
void show_image(image p, char *name) void show_image(image p, const char *name)
{ {
#ifdef OPENCV #ifdef OPENCV
show_image_cv(p, name); show_image_cv(p, name);
@ -254,7 +254,7 @@ void show_image(image p, char *name)
#endif #endif
} }
void save_image(image im, char *name) void save_image(image im, const char *name)
{ {
char buff[256]; char buff[256];
//sprintf(buff, "%s (%d)", name, windows); //sprintf(buff, "%s (%d)", name, windows);

View File

@ -43,8 +43,8 @@ image collapse_image_layers(image source, int border);
image collapse_images_horz(image *ims, int n); image collapse_images_horz(image *ims, int n);
image collapse_images_vert(image *ims, int n); image collapse_images_vert(image *ims, int n);
void show_image(image p, char *name); void show_image(image p, const char *name);
void save_image(image p, char *name); void save_image(image p, const char *name);
void show_images(image *ims, int n, char *window); void show_images(image *ims, int n, char *window);
void show_image_layers(image p, char *name); void show_image_layers(image p, char *name);
void show_image_collapsed(image p, char *name); void show_image_collapsed(image p, char *name);

View File

@ -21,7 +21,7 @@ void draw_yolo(image im, int num, float thresh, box *boxes, float **probs)
float prob = probs[i][class]; float prob = probs[i][class];
if(prob > thresh){ if(prob > thresh){
int width = pow(prob, 1./2.)*10+1; int width = pow(prob, 1./2.)*10+1;
//width = 8; width = 8;
printf("%s: %.2f\n", voc_names[class], prob); printf("%s: %.2f\n", voc_names[class], prob);
class = class * 7 % 20; class = class * 7 % 20;
float red = get_color(0,class,classes); float red = get_color(0,class,classes);
@ -427,14 +427,18 @@ void demo_swag(char *cfgfile, char *weightfile, float thresh){}
#endif #endif
*/ */
void demo_yolo(char *cfgfile, char *weightfile, float thresh); void demo_yolo(char *cfgfile, char *weightfile, float thresh, int cam_index);
#ifndef GPU #ifndef GPU
void demo_yolo(char *cfgfile, char *weightfile, float thresh){} void demo_yolo(char *cfgfile, char *weightfile, float thresh, int cam_index)
{
fprintf(stderr, "Darknet must be compiled with CUDA for YOLO demo.\n");
}
#endif #endif
void run_yolo(int argc, char **argv) void run_yolo(int argc, char **argv)
{ {
float thresh = find_float_arg(argc, argv, "-thresh", .2); float thresh = find_float_arg(argc, argv, "-thresh", .2);
int cam_index = find_int_arg(argc, argv, "-c", 0);
if(argc < 4){ if(argc < 4){
fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]); fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]);
return; return;
@ -447,5 +451,5 @@ void run_yolo(int argc, char **argv)
else if(0==strcmp(argv[2], "train")) train_yolo(cfg, weights); else if(0==strcmp(argv[2], "train")) train_yolo(cfg, weights);
else if(0==strcmp(argv[2], "valid")) validate_yolo(cfg, weights); else if(0==strcmp(argv[2], "valid")) validate_yolo(cfg, weights);
else if(0==strcmp(argv[2], "recall")) validate_yolo_recall(cfg, weights); else if(0==strcmp(argv[2], "recall")) validate_yolo_recall(cfg, weights);
else if(0==strcmp(argv[2], "demo")) demo_yolo(cfg, weights, thresh); else if(0==strcmp(argv[2], "demo")) demo_yolo(cfg, weights, thresh, cam_index);
} }

View File

@ -61,7 +61,7 @@ void *detect_in_thread(void *ptr)
return 0; return 0;
} }
extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh) extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh, int cam_index)
{ {
printf("YOLO demo\n"); printf("YOLO demo\n");
net = parse_network_cfg(cfgfile); net = parse_network_cfg(cfgfile);
@ -72,7 +72,7 @@ extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh)
srand(2222222); srand(2222222);
cv::VideoCapture cam(0); cv::VideoCapture cam(cam_index);
cap = cam; cap = cam;
if(!cap.isOpened()) error("Couldn't connect to webcam.\n"); if(!cap.isOpened()) error("Couldn't connect to webcam.\n");
@ -118,7 +118,7 @@ extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh)
} }
} }
#else #else
extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh){ extern "C" void demo_yolo(char *cfgfile, char *weightfile, float thresh, int cam_index){
fprintf(stderr, "YOLO demo needs OpenCV for webcam images.\n"); fprintf(stderr, "YOLO demo needs OpenCV for webcam images.\n");
} }
#endif #endif