Package: src:sitplus
Followup-For: Bug #841405

Hi,

the attached patch fixes the FTBFS and an other open bug.

Cheers Jochen
>From f7fc115718e6bc602f8793a9200fc70efa8ebea1 Mon Sep 17 00:00:00 2001
From: Jochen Sprickerhof <jspri...@debian.org>
Date: Sat, 5 Nov 2016 11:47:20 +0100
Subject: [PATCH] Port to OpenCV3

Closes: #788209
Closes: #841405
---
 debian/control                                     |   1 -
 ...icalFlowFarneback-instead-of-cvCalcOptica.patch |  89 +++++++++++
 debian/patches/0011-Remove-old-FindOpenCV.patch    | 172 +++++++++++++++++++++
 debian/patches/series                              |   3 +-
 debian/patches/sitplus-opencv2.4.patch             |  15 --
 5 files changed, 263 insertions(+), 17 deletions(-)
 create mode 100644 debian/patches/0010-Use-calcOpticalFlowFarneback-instead-of-cvCalcOptica.patch
 create mode 100644 debian/patches/0011-Remove-old-FindOpenCV.patch
 delete mode 100644 debian/patches/sitplus-opencv2.4.patch

diff --git a/debian/control b/debian/control
index 4fa29e8..9358973 100644
--- a/debian/control
+++ b/debian/control
@@ -15,7 +15,6 @@ Build-Depends: debhelper (>= 9),
                libconfig-dev,
                libsdl1.2-dev,
                libopencv-dev,
-               libhighgui-dev,
                libv4l-dev,
                libportmidi-dev,
                libboost-filesystem-dev,
diff --git a/debian/patches/0010-Use-calcOpticalFlowFarneback-instead-of-cvCalcOptica.patch b/debian/patches/0010-Use-calcOpticalFlowFarneback-instead-of-cvCalcOptica.patch
new file mode 100644
index 0000000..3329d0d
--- /dev/null
+++ b/debian/patches/0010-Use-calcOpticalFlowFarneback-instead-of-cvCalcOptica.patch
@@ -0,0 +1,89 @@
+From: Jochen Sprickerhof <jspri...@debian.org>
+Date: Sat, 5 Nov 2016 11:46:11 +0100
+Subject: Use calcOpticalFlowFarneback instead of cvCalcOpticalFlowHS
+
+---
+ src/mod_vision/oftracker.cpp | 30 ++++++------------------------
+ src/mod_vision/oftracker.h   |  2 --
+ 2 files changed, 6 insertions(+), 26 deletions(-)
+
+diff --git a/src/mod_vision/oftracker.cpp b/src/mod_vision/oftracker.cpp
+index cdc2fa2..3b4d7de 100755
+--- a/src/mod_vision/oftracker.cpp
++++ b/src/mod_vision/oftracker.cpp
+@@ -18,6 +18,7 @@
+ //#include "crvimage.h"
+ #include "creavision/crvcolor.h"
+ //#include "crvdraw.h"
++#include <opencv2/video/tracking.hpp>
+ 
+ using namespace mod_camera;
+ using namespace spcore;
+@@ -62,16 +63,6 @@ bool COfTracker::AllocateImages(const IplImage& image)
+ 		changed= true;
+ 	}
+ 
+-	if (!m_velX.Initialized() || m_velX.Width()!= image.width || m_velX.Height()!= image.height)
+-	{
+-		m_velX.Free();
+-		m_velX.Create (image.width, image.height, IPL_DEPTH_32F, "GRAY", IPL_ORIGIN_TL, IPL_ALIGN_DWORD);
+-	
+-		m_velY.Free();
+-		m_velY.Create (image.width, image.height, IPL_DEPTH_32F, "GRAY", IPL_ORIGIN_TL, IPL_ALIGN_DWORD);
+-	
+-		changed= true;
+-	}
+ 
+ 	return changed;
+ }
+@@ -149,26 +140,17 @@ int COfTracker::ProcessImage(const IplImage& image, float &x, float &y)
+ 		m_currentImg.PushROI();
+ 		m_currentImg.SetROI (roiX, roiY, roiWidth, roiHeight);
+ 
+-		m_velX.SetROI (roiX, roiY, roiWidth, roiHeight);
+-		m_velY.SetROI (roiX, roiY, roiWidth, roiHeight);
+ 
+-		CvTermCriteria term;
+-		term.type= CV_TERMCRIT_ITER;
+-		term.max_iter= 6;
+-		cvCalcOpticalFlowHS (m_previousImg.ptr(), m_currentImg.ptr(), 0,
+-							 m_velX.ptr(), m_velY.ptr(), 0.001, term);
++		cv::UMat uflow;
++		calcOpticalFlowFarneback (cv::cvarrToMat (m_previousImg.ptr()), cv::cvarrToMat (m_currentImg.ptr()), uflow, 0.5, 3, 15, 3, 5, 1.2, 0);
+ 
+ 		m_currentImg.PopROI();
+ 		m_previousImg.PopROI();
+-						
+-		// Compute mean
+-		cvSmooth( m_velX.ptr(), m_velX.ptr(), CV_GAUSSIAN, 3, 3);               
+ 
+ 		CvScalar cs;
+-		cs= cvSum( m_velX.ptr() );
++		cs= cv::sum (uflow);
+ 		x= (float) cs.val[0] / (float) (roiWidth * roiHeight);
+-		cs= cvSum( m_velY.ptr() );
+-		y= (float) cs.val[0] / (float) (roiWidth * roiHeight);
++		y= (float) cs.val[1] / (float) (roiWidth * roiHeight);
+ 
+ 		// Apply rotation
+ 		float rotation= atan2 (y,x);
+@@ -183,4 +165,4 @@ int COfTracker::ProcessImage(const IplImage& image, float &x, float &y)
+ 	return 1;
+ }
+ 
+-};
+\ No newline at end of file
++};
+diff --git a/src/mod_vision/oftracker.h b/src/mod_vision/oftracker.h
+index 0fe7838..9a8c639 100755
+--- a/src/mod_vision/oftracker.h
++++ b/src/mod_vision/oftracker.h
+@@ -44,8 +44,6 @@ public:
+ private:	
+ 	bool AllocateImages(const IplImage& image);
+ 
+-    CIplImage m_velX;
+-    CIplImage m_velY;
+     CIplImage m_previousImg;
+ 	CIplImage m_currentImg;
+ 	CIplImage m_diffImg; 
diff --git a/debian/patches/0011-Remove-old-FindOpenCV.patch b/debian/patches/0011-Remove-old-FindOpenCV.patch
new file mode 100644
index 0000000..bc8db43
--- /dev/null
+++ b/debian/patches/0011-Remove-old-FindOpenCV.patch
@@ -0,0 +1,172 @@
+From: Jochen Sprickerhof <jspri...@debian.org>
+Date: Sat, 5 Nov 2016 11:51:47 +0100
+Subject: Remove old FindOpenCV
+
+---
+ cmake_modules/FindOpenCV.cmake | 157 -----------------------------------------
+ 1 file changed, 157 deletions(-)
+ delete mode 100644 cmake_modules/FindOpenCV.cmake
+
+diff --git a/cmake_modules/FindOpenCV.cmake b/cmake_modules/FindOpenCV.cmake
+deleted file mode 100644
+index d3be336..0000000
+--- a/cmake_modules/FindOpenCV.cmake
++++ /dev/null
+@@ -1,157 +0,0 @@
+-###########################################################
+-#                  Find OpenCV Library
+-# See http://sourceforge.net/projects/opencvlibrary/
+-#----------------------------------------------------------
+-#
+-## 1: Setup:
+-# The following variables are optionally searched for defaults
+-#  OpenCV_DIR:            Base directory of OpenCv tree to use.
+-#
+-## 2: Variable
+-# The following are set after configuration is done: 
+-#  
+-#  OpenCV_FOUND
+-#  OpenCV_LIBS
+-#  OpenCV_INCLUDE_DIR
+-#  OpenCV_VERSION (OpenCV_VERSION_MAJOR, OpenCV_VERSION_MINOR, OpenCV_VERSION_PATCH)
+-#
+-#
+-# Deprecated variable are used to maintain backward compatibility with
+-# the script of Jan Woetzel (2006/09): www.mip.informatik.uni-kiel.de/~jw
+-#  OpenCV_INCLUDE_DIRS
+-#  OpenCV_LIBRARIES
+-#  OpenCV_LINK_DIRECTORIES
+-# 
+-## 3: Version
+-#
+-# 2010/04/07 Benoit Rat, Correct a bug when OpenCVConfig.cmake is not found.
+-# 2010/03/24 Benoit Rat, Add compatibility for when OpenCVConfig.cmake is not found.
+-# 2010/03/22 Benoit Rat, Creation of the script.
+-#
+-#
+-# tested with:
+-# - OpenCV 2.1:  MinGW, MSVC2008
+-# - OpenCV 2.0:  MinGW, MSVC2008, GCC4
+-#
+-#
+-## 4: Licence:
+-#
+-# LGPL 2.1 : GNU Lesser General Public License Usage
+-# Alternatively, this file may be used under the terms of the GNU Lesser
+-
+-# General Public License version 2.1 as published by the Free Software
+-# Foundation and appearing in the file LICENSE.LGPL included in the
+-# packaging of this file.  Please review the following information to
+-# ensure the GNU Lesser General Public License version 2.1 requirements
+-# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+-# 
+-#----------------------------------------------------------
+-
+-
+-find_path(OpenCV_DIR "OpenCVConfig.cmake" DOC "Root directory of OpenCV")
+-
+-##====================================================
+-## Find OpenCV libraries
+-##----------------------------------------------------
+-if(EXISTS "${OpenCV_DIR}")
+-
+-        #When its possible to use the Config script use it.
+-        if(EXISTS "${OpenCV_DIR}/OpenCVConfig.cmake")
+-
+-                ## Include the standard CMake script
+-                include("${OpenCV_DIR}/OpenCVConfig.cmake")
+-
+-                ## Search for a specific version
+-                set(CVLIB_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}")
+-
+-        #Otherwise it try to guess it.
+-        else(EXISTS "${OpenCV_DIR}/OpenCVConfig.cmake")
+-
+-                set(OPENCV_LIB_COMPONENTS cxcore cv ml highgui cvaux)
+-                find_path(OpenCV_INCLUDE_DIR "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "")
+-                if(EXISTS  ${OpenCV_INCLUDE_DIR})
+-                    include_directories(${OpenCV_INCLUDE_DIR})
+-                endif(EXISTS  ${OpenCV_INCLUDE_DIR})
+-
+-                #Find OpenCV version by looking at cvver.h
+-                file(STRINGS ${OpenCV_INCLUDE_DIR}/cvver.h OpenCV_VERSIONS_TMP REGEX "^#define CV_[A-Z]+_VERSION[ \t]+[0-9]+$")
+-                string(REGEX REPLACE ".*#define CV_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_MAJOR ${OpenCV_VERSIONS_TMP})
+-                string(REGEX REPLACE ".*#define CV_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_MINOR ${OpenCV_VERSIONS_TMP})
+-                string(REGEX REPLACE ".*#define CV_SUBMINOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_PATCH ${OpenCV_VERSIONS_TMP})
+-                set(OpenCV_VERSION ${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH} CACHE STRING "" FORCE)
+-                set(CVLIB_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}")
+-                
+-        endif(EXISTS "${OpenCV_DIR}/OpenCVConfig.cmake")
+-
+-        ## Initiate the variable before the loop
+-        set(OpenCV_LIBS "")
+-        set(OpenCV_FOUND_TMP true)
+-
+-        ## Loop over each components
+-        foreach(__CVLIB ${OPENCV_LIB_COMPONENTS})
+-
+-                find_library(OpenCV_${__CVLIB}_LIBRARY_DEBUG NAMES "${__CVLIB}${CVLIB_SUFFIX}d" "lib${__CVLIB}${CVLIB_SUFFIX}d" "${__CVLIB}d" "lib${__CVLIB}d" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH)
+-                find_library(OpenCV_${__CVLIB}_LIBRARY_RELEASE NAMES "${__CVLIB}${CVLIB_SUFFIX}" "lib${__CVLIB}${CVLIB_SUFFIX}" "${__CVLIB}" "lib${__CVLIB}" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH)
+-                
+-                #Remove the cache value
+-                set(OpenCV_${__CVLIB}_LIBRARY "" CACHE STRING "" FORCE)
+-        
+-                #both debug/release
+-                if(OpenCV_${__CVLIB}_LIBRARY_DEBUG AND OpenCV_${__CVLIB}_LIBRARY_RELEASE)
+-                        set(OpenCV_${__CVLIB}_LIBRARY debug ${OpenCV_${__CVLIB}_LIBRARY_DEBUG} optimized ${OpenCV_${__CVLIB}_LIBRARY_RELEASE}  CACHE STRING "" FORCE)
+-                #only debug
+-                elseif(OpenCV_${__CVLIB}_LIBRARY_DEBUG)
+-                        set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_DEBUG}  CACHE STRING "" FORCE)
+-                #only release
+-                elseif(OpenCV_${__CVLIB}_LIBRARY_RELEASE)
+-                        set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_RELEASE}  CACHE STRING "" FORCE)
+-                #no library found
+-                else()
+-                        set(OpenCV_FOUND_TMP false)
+-                endif()
+-                
+-                #Add to the general list
+-                if(OpenCV_${__CVLIB}_LIBRARY)
+-                        set(OpenCV_LIBS ${OpenCV_LIBS} ${OpenCV_${__CVLIB}_LIBRARY})
+-                endif(OpenCV_${__CVLIB}_LIBRARY)
+-                
+-        endforeach(__CVLIB)
+-
+-
+-        set(OpenCV_FOUND ${OpenCV_FOUND_TMP} CACHE BOOL "" FORCE)
+-
+-
+-else(EXISTS "${OpenCV_DIR}")
+-        set(ERR_MSG "Please specify OpenCV directory using OpenCV_DIR env. variable")
+-endif(EXISTS "${OpenCV_DIR}")
+-##====================================================
+-
+-
+-##====================================================
+-## Print message
+-##----------------------------------------------------
+-if(NOT OpenCV_FOUND)
+-  # make FIND_PACKAGE friendly
+-  if(NOT OpenCV_FIND_QUIETLY)
+-        if(OpenCV_FIND_REQUIRED)
+-          message(FATAL_ERROR "OpenCV required but some headers or libs not found. ${ERR_MSG}")
+-        else(OpenCV_FIND_REQUIRED)
+-          message(STATUS "WARNING: OpenCV was not found. ${ERR_MSG}")
+-        endif(OpenCV_FIND_REQUIRED)
+-  endif(NOT OpenCV_FIND_QUIETLY)
+-endif(NOT OpenCV_FOUND)
+-##====================================================
+-
+-
+-##====================================================
+-## Backward compatibility
+-##----------------------------------------------------
+-if(OpenCV_FOUND)
+-option(OpenCV_BACKWARD_COMPA "Add some variable to make this script compatible with the other version of FindOpenCV.cmake" false)
+-if(OpenCV_BACKWARD_COMPA)
+-        find_path(OpenCV_INCLUDE_DIRS "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "Include directory") 
+-        find_path(OpenCV_INCLUDE_DIR "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "Include directory")
+-        set(OpenCV_LIBRARIES "${OpenCV_LIBS}" CACHE STRING "" FORCE)
+-endif(OpenCV_BACKWARD_COMPA)
+-endif(OpenCV_FOUND)
+-##====================================================
diff --git a/debian/patches/series b/debian/patches/series
index cb6f33f..100daf3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,9 +1,10 @@
 spelling.diff
 as-needed.patch
 0001-remove-workaround-for-older-libconfig-versions.patch
-sitplus-opencv2.4.patch
 libs_underlinkage.patch
 remove-deprecated-controls.patch
 fix-printf-formats-for-size_t.patch
 wxwidgets3.0.patch
 sitplus-1.0.3-gcc-6.patch
+0010-Use-calcOpticalFlowFarneback-instead-of-cvCalcOptica.patch
+0011-Remove-old-FindOpenCV.patch
diff --git a/debian/patches/sitplus-opencv2.4.patch b/debian/patches/sitplus-opencv2.4.patch
deleted file mode 100644
index 69bd433..0000000
--- a/debian/patches/sitplus-opencv2.4.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-Description: Enable building with recent with opencv 2.4
-Author: : Nobuhiro Iwamatsu <iwama...@nigauri.org>
-Date: Wed, 20 Jun 2012 02:42:02 UTC
-Bug-Debian: http://bugs.debian.org/678226
-
---- sitplus.orig/src/creavision/crvimage.h
-+++ sitplus/src/creavision/crvimage.h
-@@ -24,6 +24,7 @@
- 
- #include <assert.h>
- #include <cv.h>
-+#include <opencv2/legacy/legacy.hpp>
- 
- class CIplImage
- {
-- 
2.10.2

Reply via email to