Fix optical flow code compilation with current OpenCV libs
authorAndreas Eversberg <jolly@eversberg.eu>
Mon, 2 Oct 2017 16:09:01 +0000 (18:09 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Mon, 2 Oct 2017 16:11:56 +0000 (18:11 +0200)
src/Makefile.am
src/opticalflow.cpp [moved from src/opticalflow.c with 96% similarity]

index 832c99f..04777a4 100644 (file)
@@ -29,7 +29,7 @@ libcommon_a_SOURCES = \
 
 if ENABLE_OPENCV
 libcommon_a_SOURCES += \
-       opticalflow.c
+       opticalflow.cpp
 endif
 
 colorize_SOURCES = \
similarity index 96%
rename from src/opticalflow.c
rename to src/opticalflow.cpp
index ff4a5c5..378bc49 100644 (file)
@@ -1,11 +1,13 @@
 #include <stdio.h>
+extern "C" {
 #include "img.h"
 #include "opticalflow.h"
 #include "yuv.h"
-#include <opencv2/core/core_c.h>
-#include <opencv2/imgproc/imgproc_c.h>
-#include <opencv2/video/tracking.hpp>
 #include "dir_seperator.h"
+}
+#include <opencv2/core/core.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+#include <opencv2/video/tracking.hpp>
 
 int flow_enable = 0, flow_window, flow_view_vector, flow_view_uv;
 
@@ -69,7 +71,7 @@ static void copy_matrix_to_map(CvMat *flow, int width, int height, double *flow_
  */
 void *create_flow_maps(const double *img_prev_buffer, const double *img_next_buffer, const double *img_buffer, int width, int height, int win_size, int steps, double *flow_map_x_prev, double *flow_map_y_prev, double *flow_map_x_next, double *flow_map_y_next, void *_image_preview)
 {
-       IplImage *image_prev = NULL, *image = NULL, *image_next = NULL, *image_preview = _image_preview;
+       IplImage *image_prev = NULL, *image = NULL, *image_next = NULL, *image_preview = (IplImage *)_image_preview;
        CvMat *flow;
        CvSize size;
        int i, j;
@@ -242,7 +244,7 @@ void create_flow_view(const char *filename_prev, const char *filename_next, unsi
        flow_map_y_next = (double *)malloc(sizeof(double)*width*height);
 
        if (image_preview) {
-               image_preview = create_flow_maps(img_prev_buffer, img_next_buffer, img_buffer, width, height, win_size, steps, flow_map_x_prev, flow_map_y_prev, flow_map_x_next, flow_map_y_next, image_preview);
+               image_preview = (IplImage *)create_flow_maps(img_prev_buffer, img_next_buffer, img_buffer, width, height, win_size, steps, flow_map_x_prev, flow_map_y_prev, flow_map_x_next, flow_map_y_next, image_preview);
 
                /* paint vectors from image_preview to img_buffer */
                for (i = 0; i < height; i++) {