summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Bermond2018-11-25 23:14:55 +0000
committerDaniel Bermond2018-11-25 23:14:55 +0000
commitd722e3f2f8a173104ff58d89840331fe6309c909 (patch)
tree96598befbd4618910c47a5b4656ef34ddeee9307
parent97c7a17cfcb83fec51474260cbb8578b8ce25a29 (diff)
downloadaur-d722e3f2f8a173104ff58d89840331fe6309c909.tar.gz
Fix build with opencv 4.0
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD9
-rw-r--r--caffe2-1.0rc1-opencv4-fix.patch106
3 files changed, 116 insertions, 3 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 2aca25b1fa7..91740e0f7fd 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = caffe2
pkgdesc = A new lightweight, modular, and scalable deep learning framework
pkgver = 0.8.2.pytorch.1.0rc1
- pkgrel = 7
+ pkgrel = 8
url = https://caffe2.ai/
arch = i686
arch = x86_64
@@ -81,6 +81,7 @@ pkgbase = caffe2
source = git+https://github.com/shibatch/sleef.git#commit=6ff7a135a1e31979d1e1844a2e7171dfbd34f54f
source = git+https://github.com/intel/ideep.git#commit=dedff8fb8193fe3a1ea893d4bc852f8ea395b6b3
source = caffe2-1.0rc1-add-full-relro.patch
+ source = caffe2-1.0rc1-opencv4-fix.patch
sha256sums = 473cd4af032ddec4279cf3a90dd9508b6fa0be5cd89c842945f88b5a576a4231
sha256sums = SKIP
sha256sums = SKIP
@@ -109,6 +110,7 @@ pkgbase = caffe2
sha256sums = SKIP
sha256sums = SKIP
sha256sums = c41dd34bdf0bfbe62bba8527e950a14b356bef136edc53ea40c6469644502583
+ sha256sums = 058d05d3fdf9e4d688dc29475265c69f99892ccc5f9926d45b26da9616eb936c
pkgname = caffe2
diff --git a/PKGBUILD b/PKGBUILD
index cf273219851..3222e8314e5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -31,7 +31,7 @@ _pytorchver=1.0rc1 # pytorch stable release version
pkgname=caffe2
pkgver="0.8.2.pytorch.${_pytorchver}"
-pkgrel=7
+pkgrel=8
pkgdesc='A new lightweight, modular, and scalable deep learning framework'
arch=('i686' 'x86_64')
url='https://caffe2.ai/'
@@ -92,6 +92,7 @@ source=(
"git+https://github.com/intel/ideep.git#commit=${_ideep_commit}"
# patches:
'caffe2-1.0rc1-add-full-relro.patch'
+ 'caffe2-1.0rc1-opencv4-fix.patch'
)
sha256sums=('473cd4af032ddec4279cf3a90dd9508b6fa0be5cd89c842945f88b5a576a4231'
'SKIP'
@@ -120,7 +121,8 @@ sha256sums=('473cd4af032ddec4279cf3a90dd9508b6fa0be5cd89c842945f88b5a576a4231'
'SKIP'
'SKIP'
'SKIP'
- 'c41dd34bdf0bfbe62bba8527e950a14b356bef136edc53ea40c6469644502583')
+ 'c41dd34bdf0bfbe62bba8527e950a14b356bef136edc53ea40c6469644502583'
+ '058d05d3fdf9e4d688dc29475265c69f99892ccc5f9926d45b26da9616eb936c')
prepare() {
cd "pytorch-${_pytorchver}/third_party"
@@ -149,6 +151,9 @@ prepare() {
# add full relro
cd "${srcdir}/pytorch-${_pytorchver}"
patch -Np1 -i "${srcdir}/caffe2-1.0rc1-add-full-relro.patch"
+
+ # opencv 4.0 fix
+ patch -Np1 -i "${srcdir}/caffe2-1.0rc1-opencv4-fix.patch"
}
build() {
diff --git a/caffe2-1.0rc1-opencv4-fix.patch b/caffe2-1.0rc1-opencv4-fix.patch
new file mode 100644
index 00000000000..94cb614c547
--- /dev/null
+++ b/caffe2-1.0rc1-opencv4-fix.patch
@@ -0,0 +1,106 @@
+diff -Naurp a/binaries/convert_encoded_to_raw_leveldb.cc b/binaries/convert_encoded_to_raw_leveldb.cc
+--- a/binaries/convert_encoded_to_raw_leveldb.cc 2018-10-02 04:54:52.000000000 +0000
++++ b/binaries/convert_encoded_to_raw_leveldb.cc 2018-11-25 18:02:35.117906145 +0000
+@@ -109,7 +109,7 @@ void ConvertToRawDataset(
+ cv::Mat img = cv::imdecode(
+ cv::Mat(1, &encoded_size, CV_8UC1,
+ const_cast<char*>(encoded_image.data())),
+- caffe2::FLAGS_color ? CV_LOAD_IMAGE_COLOR : CV_LOAD_IMAGE_GRAYSCALE);
++ caffe2::FLAGS_color ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE);
+ cv::Mat resized_img;
+ int scaled_width, scaled_height;
+ if (caffe2::FLAGS_warp) {
+diff -Naurp a/binaries/make_image_db.cc b/binaries/make_image_db.cc
+--- a/binaries/make_image_db.cc 2018-10-02 04:54:52.000000000 +0000
++++ b/binaries/make_image_db.cc 2018-11-25 18:06:55.018892401 +0000
+@@ -140,8 +140,8 @@ class Converter {
+ // Load image
+ cv::Mat img = cv::imread(
+ input_folder + pair.first,
+- caffe2::FLAGS_color ? CV_LOAD_IMAGE_COLOR
+- : CV_LOAD_IMAGE_GRAYSCALE);
++ caffe2::FLAGS_color ? cv::IMREAD_COLOR
++ : cv::IMREAD_GRAYSCALE);
+
+ // Resize image
+ cv::Mat resized_img;
+diff -Naurp a/caffe2/contrib/cuda-convnet2/make-data/pyext/src/pyext.cpp b/caffe2/contrib/cuda-convnet2/make-data/pyext/src/pyext.cpp
+--- a/caffe2/contrib/cuda-convnet2/make-data/pyext/src/pyext.cpp 2018-11-25 13:49:49.972477452 +0000
++++ b/caffe2/contrib/cuda-convnet2/make-data/pyext/src/pyext.cpp 2018-11-25 13:42:33.000000000 +0000
+@@ -93,7 +93,7 @@ void DecoderThread::makeJPEG(int idx) {
+ size_t src_len = PyString_GET_SIZE(pySrc);
+ vector<uchar> src_vec(src, src + src_len);
+
+- cv::Mat decoded_mat = cv::imdecode(cv::Mat(src_vec), CV_LOAD_IMAGE_COLOR);
++ cv::Mat decoded_mat = cv::imdecode(cv::Mat(src_vec), cv::IMREAD_COLOR);
+ assert(decoded_mat.channels() == 3);
+
+ /*
+diff -Naurp a/caffe2/image/image_input_op.h b/caffe2/image/image_input_op.h
+--- a/caffe2/image/image_input_op.h 2018-10-02 04:54:52.000000000 +0000
++++ b/caffe2/image/image_input_op.h 2018-11-25 13:51:25.414641803 +0000
+@@ -465,7 +465,7 @@ bool ImageInputOp<Context>::GetImageAndL
+ datum.data().size(),
+ CV_8UC1,
+ const_cast<char*>(datum.data().data())),
+- color_ ? CV_LOAD_IMAGE_COLOR : CV_LOAD_IMAGE_GRAYSCALE);
++ color_ ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE);
+ if (src.rows == 0 or src.cols == 0) {
+ num_decode_errors_in_batch_++;
+ src = cv::Mat::zeros(cv::Size(224, 224), CV_8UC3);
+@@ -540,7 +540,7 @@ bool ImageInputOp<Context>::GetImageAndL
+ &encoded_size,
+ CV_8UC1,
+ const_cast<char*>(encoded_image_str.data())),
+- color_ ? CV_LOAD_IMAGE_COLOR : CV_LOAD_IMAGE_GRAYSCALE);
++ color_ ? cv::IMREAD_COLOR : cv::IMREAD_GRAYSCALE);
+ if (src.rows == 0 or src.cols == 0) {
+ num_decode_errors_in_batch_++;
+ src = cv::Mat::zeros(cv::Size(224, 224), CV_8UC3);
+@@ -681,7 +681,7 @@ bool ImageInputOp<Context>::GetImageAndL
+ if (out_c == src.channels()) {
+ *img = src;
+ } else {
+- cv::cvtColor(src, *img, (out_c == 1) ? CV_BGR2GRAY : CV_GRAY2BGR);
++ cv::cvtColor(src, *img, (out_c == 1) ? cv::COLOR_BGR2GRAY : cv::COLOR_GRAY2BGR);
+ }
+
+ // Note(Yangqing): I believe that the mat should be created continuous.
+diff -Naurp a/caffe2/video/optical_flow.cc b/caffe2/video/optical_flow.cc
+--- a/caffe2/video/optical_flow.cc 2018-10-02 04:54:52.000000000 +0000
++++ b/caffe2/video/optical_flow.cc 2018-11-25 20:35:42.327123803 +0000
+@@ -7,7 +7,11 @@ void OpticalFlowExtractor(
+ const cv::Mat& curr_gray,
+ const int flow_alg_type,
+ cv::Mat& flow) {
++#if CV_MAJOR_VERSION >= 4
++ cv::Ptr<cv::DISOpticalFlow> tvl1 = cv::DISOpticalFlow::create();
++#else
+ cv::Ptr<cv::DualTVL1OpticalFlow> tvl1 = cv::DualTVL1OpticalFlow::create();
++#endif
+ switch (flow_alg_type) {
+ case FLowAlgType::FarnebackOpticalFlow:
+ cv::calcOpticalFlowFarneback(
+diff -Naurp a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
+--- a/cmake/Dependencies.cmake 2018-10-02 04:54:52.000000000 +0000
++++ b/cmake/Dependencies.cmake 2018-11-25 18:14:31.186866421 +0000
+@@ -278,11 +278,15 @@ endif()
+
+ # ---[ OpenCV
+ if(USE_OPENCV)
+- # OpenCV 3
+- find_package(OpenCV 3 QUIET COMPONENTS core highgui imgproc imgcodecs videoio video)
++ # OpenCV 4
++ find_package(OpenCV 4 QUIET COMPONENTS core highgui imgproc imgcodecs optflow videoio video)
+ if(NOT OpenCV_FOUND)
+- # OpenCV 2
+- find_package(OpenCV QUIET COMPONENTS core highgui imgproc)
++ # OpenCV 3
++ find_package(OpenCV 3 QUIET COMPONENTS core highgui imgproc imgcodecs videoio video)
++ if(NOT OpenCV_FOUND)
++ # OpenCV 2
++ find_package(OpenCV QUIET COMPONENTS core highgui imgproc)
++ endif()
+ endif()
+ if(OpenCV_FOUND)
+ include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})