| | |
| | | |
| | | #ifdef OPENCV |
| | | #include "opencv2/highgui/highgui_c.h" |
| | | #include "opencv2/core/version.hpp" |
| | | #ifndef CV_VERSION_EPOCH |
| | | #include "opencv2/videoio/videoio_c.h" |
| | | #endif |
| | | image get_image_from_stream(CvCapture *cap); |
| | | #endif |
| | | |
| | | void extract_voxel(char *lfile, char *rfile, char *prefix) |
| | | { |
| | | #ifdef OPENCV |
| | | int w = 1920; |
| | | int h = 1080; |
| | | #ifdef OPENCV |
| | | int shift = 0; |
| | | int count = 0; |
| | | CvCapture *lcap = cvCaptureFromFile(lfile); |
| | | CvCapture *rcap = cvCaptureFromFile(rfile); |
| | | while(1){ |
| | | image l = get_image_from_stream(lcap); |
| | | image r = get_image_from_stream(rcap); |
| | | if(!l.w || !r.w) break; |
| | | if(count%100 == 0) { |
| | | shift = best_3d_shift_r(l, r, -l.h/100, l.h/100); |
| | | printf("%d\n", shift); |
| | | } |
| | | image ls = crop_image(l, (l.w - w)/2, (l.h - h)/2, w, h); |
| | | image rs = crop_image(r, 105 + (r.w - w)/2, (r.h - h)/2 + shift, w, h); |
| | | char buff[256]; |
| | | sprintf(buff, "%s_%05d_l", prefix, count); |
| | | save_image(ls, buff); |
| | | sprintf(buff, "%s_%05d_r", prefix, count); |
| | | save_image(rs, buff); |
| | | free_image(l); |
| | | free_image(r); |
| | | free_image(ls); |
| | | free_image(rs); |
| | | ++count; |
| | | int shift = 0; |
| | | int count = 0; |
| | | CvCapture *lcap = cvCaptureFromFile(lfile); |
| | | CvCapture *rcap = cvCaptureFromFile(rfile); |
| | | while(1){ |
| | | image l = get_image_from_stream(lcap); |
| | | image r = get_image_from_stream(rcap); |
| | | if(!l.w || !r.w) break; |
| | | if(count%100 == 0) { |
| | | shift = best_3d_shift_r(l, r, -l.h/100, l.h/100); |
| | | printf("%d\n", shift); |
| | | } |
| | | image ls = crop_image(l, (l.w - w)/2, (l.h - h)/2, w, h); |
| | | image rs = crop_image(r, 105 + (r.w - w)/2, (r.h - h)/2 + shift, w, h); |
| | | char buff[256]; |
| | | sprintf(buff, "%s_%05d_l", prefix, count); |
| | | save_image(ls, buff); |
| | | sprintf(buff, "%s_%05d_r", prefix, count); |
| | | save_image(rs, buff); |
| | | free_image(l); |
| | | free_image(r); |
| | | free_image(ls); |
| | | free_image(rs); |
| | | ++count; |
| | | } |
| | | |
| | | #else |
| | | printf("need OpenCV for extraction\n"); |
| | | printf("need OpenCV for extraction\n"); |
| | | #endif |
| | | } |
| | | |
| | |
| | | char *train_images = "/data/imagenet/imagenet1k.train.list"; |
| | | char *backup_directory = "/home/pjreddie/backup/"; |
| | | srand(time(0)); |
| | | data_seed = time(0); |
| | | char *base = basecfg(cfgfile); |
| | | printf("%s\n", base); |
| | | float avg_loss = -1; |
| | |
| | | else if(0==strcmp(argv[2], "test")) test_voxel(cfg, weights, filename); |
| | | else if(0==strcmp(argv[2], "extract")) extract_voxel(argv[3], argv[4], argv[5]); |
| | | /* |
| | | else if(0==strcmp(argv[2], "valid")) validate_voxel(cfg, weights); |
| | | */ |
| | | else if(0==strcmp(argv[2], "valid")) validate_voxel(cfg, weights); |
| | | */ |
| | | } |