sumo migration: update opencv to version 3.4.2

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
Arturo Buzarra 2018-12-19 11:00:31 +01:00
parent 004d341db2
commit 7047e86bd9
10 changed files with 279 additions and 106 deletions

View File

@ -0,0 +1,66 @@
From f1604999632344f5bcbf6f611693917f6a9c2aa3 Mon Sep 17 00:00:00 2001
From: Alexander Alekhin <alexander.alekhin@intel.com>
Date: Mon, 9 Jul 2018 17:19:35 +0300
Subject: [PATCH] dnn: allow to use external protobuf
"custom layers" feature will not work properly in these builds.
Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
Upstream-Status: Backport [https://github.com/opencv/opencv/commit/e2b5d112909b9dfd764f14833b82e38e4bc2f81f]
---
modules/dnn/CMakeLists.txt | 4 ++++
modules/dnn/src/caffe/caffe_io.cpp | 4 ++++
modules/dnn/test/test_layers.cpp | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
index e306dde..a2f741c 100644
--- a/modules/dnn/CMakeLists.txt
+++ b/modules/dnn/CMakeLists.txt
@@ -48,6 +48,10 @@ if(ANDROID)
add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
endif()
+if(NOT BUILD_PROTOBUF)
+ add_definitions(-DOPENCV_DNN_EXTERNAL_PROTOBUF=1)
+endif()
+
add_definitions(-DHAVE_PROTOBUF=1)
#suppress warnings in autogenerated caffe.pb.* files
diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
index 730c752..9f4e31c 100644
--- a/modules/dnn/src/caffe/caffe_io.cpp
+++ b/modules/dnn/src/caffe/caffe_io.cpp
@@ -1120,7 +1120,11 @@ bool ReadProtoFromTextFile(const char* filename, Message* proto) {
std::ifstream fs(filename, std::ifstream::in);
CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
IstreamInputStream input(&fs);
+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
return google::protobuf::TextFormat::Parser(true).Parse(&input, proto);
+#else
+ return google::protobuf::TextFormat::Parser().Parse(&input, proto);
+#endif
}
bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp
index 963206b..05ea61a 100644
--- a/modules/dnn/test/test_layers.cpp
+++ b/modules/dnn/test/test_layers.cpp
@@ -1150,7 +1150,11 @@ private:
TEST(Layer_Test_Interp_custom, Accuracy)
{
+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
CV_DNN_REGISTER_LAYER_CLASS(Interp, InterpLayer);
+#else
+ CV_DNN_REGISTER_LAYER_CLASS(DISABLED_Interp, InterpLayer); // requires patched protobuf (available in OpenCV source tree only)
+#endif
testLayerUsingCaffeModels("layer_interp", DNN_TARGET_CPU, false, false);
LayerFactory::unregisterLayer("Interp");
}
--
2.7.4

View File

@ -0,0 +1,66 @@
From f49f6d52b45a09a133621c3e96b77b321746452f Mon Sep 17 00:00:00 2001
From: berak <px1704@web.de>
Date: Tue, 7 Aug 2018 15:14:22 +0200
Subject: [PATCH] photo: avoid resizing a const Mat in decolor()
---
modules/photo/src/contrast_preserve.hpp | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/modules/photo/src/contrast_preserve.hpp b/modules/photo/src/contrast_preserve.hpp
index ec8274e..65ca9c1 100644
--- a/modules/photo/src/contrast_preserve.hpp
+++ b/modules/photo/src/contrast_preserve.hpp
@@ -204,14 +204,19 @@ void Decolor::add_to_vector_poly(vector < vector <double> > &polyGrad, const vec
idx1++;
}
-void Decolor::weak_order(const Mat &img, vector <double> &alf) const
+void Decolor::weak_order(const Mat &im, vector <double> &alf) const
{
- const int h = img.size().height;
- const int w = img.size().width;
+ Mat img;
+ const int h = im.size().height;
+ const int w = im.size().width;
if((h + w) > 800)
{
const double sizefactor = double(800)/(h+w);
- resize(img, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ resize(im, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ }
+ else
+ {
+ img = im;
}
Mat curIm = Mat(img.size(),CV_32FC1);
@@ -246,16 +251,20 @@ void Decolor::weak_order(const Mat &img, vector <double> &alf) const
alf[i] -= tmp1[i] * tmp2[i] * tmp3[i];
}
-void Decolor::grad_system(const Mat &img, vector < vector < double > > &polyGrad,
+void Decolor::grad_system(const Mat &im, vector < vector < double > > &polyGrad,
vector < double > &Cg, vector <Vec3i>& comb) const
{
- int h = img.size().height;
- int w = img.size().width;
-
+ Mat img;
+ int h = im.size().height;
+ int w = im.size().width;
if((h + w) > 800)
{
const double sizefactor = double(800)/(h+w);
- resize(img, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ resize(im, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ }
+ else
+ {
+ img = im;
}
h = img.size().height;
--
2.7.4

View File

@ -0,0 +1,51 @@
From fb2b26c4197cb7569e9df8afbadedbe419b4e04e Mon Sep 17 00:00:00 2001
From: yom <yom@home.com>
Date: Tue, 7 Aug 2018 17:52:05 +0200
Subject: [PATCH] photo: Decolor corrections * Keep image aspect ratio in
resize called in grad_system and weak_order * Bug correction in loop
inside Decolor::gradvector
---
modules/photo/src/contrast_preserve.hpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/photo/src/contrast_preserve.hpp b/modules/photo/src/contrast_preserve.hpp
index 65ca9c1..1afd4bc 100644
--- a/modules/photo/src/contrast_preserve.hpp
+++ b/modules/photo/src/contrast_preserve.hpp
@@ -159,12 +159,12 @@ void Decolor::gradvector(const Mat &img, vector <double> &grad) const
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
- grad[i*height + j] = d_trans.at<float>(i, j);
+ grad[i*width + j] = d_trans.at<float>(i, j);
const int offset = width * height;
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
- grad[offset + i * height + j] = d1_trans.at<float>(i, j);
+ grad[offset + i * width + j] = d1_trans.at<float>(i, j);
}
void Decolor::colorGrad(const Mat &img, vector <double> &Cg) const
@@ -212,7 +212,7 @@ void Decolor::weak_order(const Mat &im, vector <double> &alf) const
if((h + w) > 800)
{
const double sizefactor = double(800)/(h+w);
- resize(im, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ resize(im, img, Size(cvRound(w*sizefactor), cvRound(h*sizefactor)));
}
else
{
@@ -260,7 +260,7 @@ void Decolor::grad_system(const Mat &im, vector < vector < double > > &polyGrad,
if((h + w) > 800)
{
const double sizefactor = double(800)/(h+w);
- resize(im, img, Size(cvRound(h*sizefactor), cvRound(w*sizefactor)));
+ resize(im, img, Size(cvRound(w*sizefactor), cvRound(h*sizefactor)));
}
else
{
--
2.7.4

View File

@ -0,0 +1,83 @@
From ace48a628dca34d742615598afeef42ed323a029 Mon Sep 17 00:00:00 2001
From: Huang Qiyu <huangqy.fnst@cn.fujitsu.com>
Date: Fri, 19 May 2017 04:27:50 +0900
Subject: [PATCH 3/3] To fix errors as following:
"test_main.cpp:45: undefined reference to `parseCustomOptions(int, char**)'"
"perf_abs.cpp:13: undefined reference to `cvtest::param_seed'"
"test_superres.cpp:270: undefined reference to `checkIppStatus()'"
Signed-off-by: Huang Qiyu <huangqy.fnst@cn.fujitsu.com>
Also add the visibility changes for certain OpenCL-related functions in
ts module.
Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
---
modules/ts/include/opencv2/ts.hpp | 6 +++---
modules/ts/include/opencv2/ts/ocl_test.hpp | 2 +-
modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
Index: git/modules/ts/include/opencv2/ts.hpp
===================================================================
--- git.orig/modules/ts/include/opencv2/ts.hpp
+++ git/modules/ts/include/opencv2/ts.hpp
@@ -611,7 +611,7 @@ protected:
}
};
-extern uint64 param_seed;
+CV_EXPORTS extern uint64 param_seed;
struct DefaultRngAuto
{
@@ -667,14 +667,14 @@ std::string findDataFile(const std::stri
#ifdef HAVE_OPENCL
namespace ocl {
-void dumpOpenCLDevice();
+CV_EXPORTS void dumpOpenCLDevice();
}
#define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
#else
#define TEST_DUMP_OCL_INFO
#endif
-void parseCustomOptions(int argc, char **argv);
+CV_EXPORTS void parseCustomOptions(int argc, char **argv);
#define CV_TEST_INIT0_NOOP (void)0
Index: git/modules/ts/include/opencv2/ts/ocl_test.hpp
===================================================================
--- git.orig/modules/ts/include/opencv2/ts/ocl_test.hpp
+++ git/modules/ts/include/opencv2/ts/ocl_test.hpp
@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src)
return dst;
}
-extern int test_loop_times;
+CV_EXPORTS extern int test_loop_times;
#define MAX_VALUE 357
Index: git/modules/ts/include/opencv2/ts/ts_ext.hpp
===================================================================
--- git.orig/modules/ts/include/opencv2/ts/ts_ext.hpp
+++ git/modules/ts/include/opencv2/ts/ts_ext.hpp
@@ -9,10 +9,10 @@
#define OPENCV_TS_EXT_HPP
namespace cvtest {
-void checkIppStatus();
-extern bool skipUnstableTests;
-extern bool runBigDataTests;
-extern int testThreads;
+CV_EXPORTS void checkIppStatus();
+CV_EXPORTS extern bool skipUnstableTests;
+CV_EXPORTS extern bool runBigDataTests;
+CV_EXPORTS extern int testThreads;
}
// check for required "opencv_test" namespace

View File

@ -1,13 +0,0 @@
Index: git/modules/core/src/command_line_parser.cpp
===================================================================
--- git.orig/modules/core/src/command_line_parser.cpp 2017-01-24 09:21:45.900724275 -0600
+++ git/modules/core/src/command_line_parser.cpp 2017-01-24 10:34:17.000000000 -0600
@@ -10,7 +10,7 @@
static String cat_string(const String& str)
{
int left = 0, right = (int)str.length();
- while( left <= right && str[left] == ' ' )
+ while( left < right && str[left] == ' ' )
left++;
while( right > left && str[right-1] == ' ' )
right--;

View File

@ -1,25 +0,0 @@
diff --git a/modules/core/src/ovx.cpp b/modules/core/src/ovx.cpp
index a53f553..6fb9bce 100644
--- a/modules/core/src/ovx.cpp
+++ b/modules/core/src/ovx.cpp
@@ -17,6 +17,12 @@ namespace cv
bool haveOpenVX()
{
#ifdef HAVE_OPENVX
+ char *p;
+ p = getenv("NO_OPENVX");
+ if((p != NULL) && (p[0] == '1'))
+ {
+ return false;
+ }
static int g_haveOpenVX = -1;
if(g_haveOpenVX < 0)
{
@@ -45,6 +51,7 @@ bool useOpenVX()
{
#ifdef HAVE_OPENVX
CoreTLSData* data = getCoreTlsData().get();
+ if(!haveOpenVX()) return false;
if( data->useOpenVX < 0 )
{
// enabled (if available) by default

View File

@ -1,34 +0,0 @@
Upstream-status: Inappropriate [OE specific]
Signed-off-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
diff --git a/modules/dnn_modern/CMakeLists.txt b/modules/dnn_modern/CMakeLists.txt
index 79b64b12160b..ba06a0a163e4 100644
--- a/modules/dnn_modern/CMakeLists.txt
+++ b/modules/dnn_modern/CMakeLists.txt
@@ -15,24 +15,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# MODULE REQUIREMENTS
# ----------------------------------------------------------------------------
-set(TINY_DNN_CPP_PATH "${OpenCV_BINARY_DIR}/3rdparty/tinydnn")
-set(TINY_DNN_CPP_ROOT "${TINY_DNN_CPP_PATH}/tiny-dnn-1.0.0a3")
-ocv_download(FILENAME "v1.0.0a3.tar.gz"
- HASH "adb1c512e09ca2c7a6faef36f9c53e59"
- URL
- "${OPENCV_TINY_DNN_URL}"
- "$ENV{OPENCV_TINY_DNN_URL}"
- "https://github.com/tiny-dnn/tiny-dnn/archive/"
- DESTINATION_DIR "${TINY_DNN_CPP_PATH}"
- STATUS TINY_DNN_DOWNLOAD_SUCCESS
- ID "tiny-dnn"
- UNPACK RELATIVE_URL)
-
-if(NOT TINY_DNN_DOWNLOAD_SUCCESS)
- message(STATUS "Failed to download tiny-dnn sources")
-endif()
-
-find_package(TinyDNN QUIET)
+set(TINYDNN_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/tinydnn/tiny-dnn-1.0.0a3")
+set(TinyDNN_FOUND TRUE)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)

View File

@ -1,13 +0,0 @@
diff --git a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
index eb2a729cc2eb..8717736484de 100644
--- a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
+++ b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
@@ -24,7 +24,7 @@ if(NOT BUILD_PROTOBUF AND NOT (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF
find_package(Protobuf QUIET)
endif()
-if(PROTOBUF_FOUND)
+if(PROTOBUF_FOUND OR (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES))
# nothing
else()
include(${CMAKE_CURRENT_LIST_DIR}/download_protobuf.cmake)

View File

@ -10,8 +10,8 @@ ARM_INSTRUCTION_SET_armv5 = "arm"
DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
SRCREV_opencv = "6ffc48769ac60d53c4bd1913eac15117c9b1c9f7"
SRCREV_contrib = "ced5aa760688dd2ec867ebf7bd4f0c2341d2fde5"
SRCREV_opencv = "9e1b1e5389237c2b9f6c7b9d7715d9836c0a5de1"
SRCREV_contrib = "d4e02869454998c9af5af1a5c3392cdc0c31dd22"
SRCREV_ipp = "a62e20676a60ee0ad6581e217fe7e4bada3b95db"
SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
@ -38,8 +38,8 @@ IPP_FILENAME = "${@ipp_filename(d)}"
IPP_MD5 = "${@ipp_md5sum(d)}"
SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
SRC_URI = "git://github.com/opencv/opencv.git;branch=3.4;name=opencv \
git://github.com/opencv/opencv_contrib.git;branch=3.4;destsuffix=contrib;name=contrib \
git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20170418;destsuffix=ipp;name=ipp \
git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \
git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \
@ -47,12 +47,13 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
file://fixpkgconfig.patch \
file://uselocalxfeatures.patch;patchdir=../contrib/ \
file://tinydnn.patch;patchdir=../contrib/ \
file://0003-To-fix-errors-as-following.patch \
file://0001-Dont-use-isystem.patch \
file://javagen.patch \
file://0001-dnn-allow-to-use-external-protobuf.patch \
"
PV = "3.4.1+git${SRCPV}"
PV = "3.4.2+git${SRCPV}"
S = "${WORKDIR}/git"

View File

@ -3,13 +3,16 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
# Specify the opencv_extra source. The version should match the overall opencv version.
# Recording the opencv_extra version here allows us to raise a fatal error if the
# package version is updated but this section is not.
SRC_URI += "git://github.com/opencv/opencv_extra.git;destsuffix=opencv_extra;name=opencv_extra"
SRCREV_opencv_extra = "c533012eb214ec3db851586f74f9dc43ea20c065"
OPENCV_EXTRA_VERSION = "3.4.1"
SRC_URI += "git://github.com/opencv/opencv_extra.git;branch=3.4;destsuffix=opencv_extra;name=opencv_extra"
SRCREV_opencv_extra = "cc18e9a17c5afe034341c8c70a5aaa9ac86e5601"
OPENCV_EXTRA_VERSION = "3.4.2"
SRC_URI_remove = "file://javagen.patch"
SRC_URI += "file://fix_openvx_samples.patch"
SRC_URI += "file://fix_python_bindings.patch"
SRC_URI += "file://0001-photo-avoid-resizing-a-const-Mat-in-decolor.patch \
file://0002-photo-Decolor-corrections.patch \
"
PACKAGECONFIG_remove_imx = "eigen"
PACKAGECONFIG_remove_mx8 = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland x11', 'gtk', '', d)}"
@ -44,16 +47,6 @@ do_check_opencv_extra_version() {
}
addtask check_opencv_extra_version before do_fetch
do_compile_prepend() {
# A build break occurs if dnn and python3 are configured. Work around
# the problem by building opencv_dnn first. See
# https://github.com/opencv/opencv/issues/10474.
if ${@bb.utils.contains("PACKAGECONFIG", "dnn python3", "true", "false", d)}; then
bbnote VERBOSE=1 cmake --build '${B}' --target opencv_dnn -- ${PARALLEL_MAKE}
VERBOSE=1 cmake --build '${B}' --target opencv_dnn -- ${PARALLEL_MAKE}
fi
}
do_install_append() {
if ${@bb.utils.contains("PACKAGECONFIG", "samples", "true", "false", d)}; then
install -d ${D}${datadir}/OpenCV/samples/data
@ -66,5 +59,3 @@ do_install_append() {
RDEPENDS_opencv-apps += \
"${@bb.utils.contains('PACKAGECONFIG', 'test', 'bash', '', d)}"
PACKAGE_ARCH = "${MACHINE_SOCARCH}"