From 84d6533cb8112f23a34d3de76435a10f4620f4b8 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 23 Oct 2017 13:43:03 +0000
Subject: [PATCH] Fixed OpenCV usage in the yolo_console_dll.cpp

---
 src/voxel.c |   62 ++++++++++++++++--------------
 1 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/src/voxel.c b/src/voxel.c
index b41cf77..476663f 100644
--- a/src/voxel.c
+++ b/src/voxel.c
@@ -5,41 +5,46 @@
 
 #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
 }
 
@@ -48,7 +53,6 @@
     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;
@@ -164,6 +168,6 @@
     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);
+     */
 }

--
Gitblit v1.10.0