summaryrefslogtreecommitdiffstats
path: root/recipes-support
diff options
context:
space:
mode:
authorLuciano Dittgen <luciano.dittgen@ossystems.com.br>2026-06-29 13:36:24 -0300
committerLuciano Dittgen <luciano.dittgen@ossystems.com.br>2026-06-30 16:39:56 -0300
commitcedf6ffb9a5edc8bcba05079380909be6e49aaea (patch)
treea7291c550e7e7539fcbb17415f9aa4f471dd0396 /recipes-support
parent4fcd787f54d8abcee5994d60e119adf22b255f39 (diff)
downloadmeta-freescale-cedf6ffb9a5edc8bcba05079380909be6e49aaea.tar.gz
opencv: Move recipe to openembedded-layer dynamic layer
The OpenCV recipe and the packagegroups that depend on meta-oe recipes should only be parsed when openembedded-layer is present. Move them under the existing openembedded-layer dynamic layer so a core-only meta-freescale setup does not expose those dependencies. Tested with yocto-check-layer against the current worktree. Signed-off-by: Luciano Dittgen <luciano.dittgen@ossystems.com.br>
Diffstat (limited to 'recipes-support')
-rw-r--r--recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch37
-rw-r--r--recipes-support/opencv/opencv/0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch26
-rw-r--r--recipes-support/opencv/opencv/0001-Add-smaller-version-of-download_models.py.patch180
-rw-r--r--recipes-support/opencv/opencv/0001-Dont-use-isystem.patch28
-rw-r--r--recipes-support/opencv/opencv/0001-Make-ts-module-external.patch42
-rw-r--r--recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch32
-rw-r--r--recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch31
-rw-r--r--recipes-support/opencv/opencv/0001-Use-the-one-argument-version-of-SetTotalBytesLimit.patch41
-rw-r--r--recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch44
-rw-r--r--recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch71
-rw-r--r--recipes-support/opencv/opencv/OpenCV_DNN_examples.patch141
-rw-r--r--recipes-support/opencv/opencv/download.patch41
-rw-r--r--recipes-support/opencv/opencv/fix-build-with-protobuf-v22.patch408
-rw-r--r--recipes-support/opencv/opencv_4.6.0.imx.bb318
14 files changed, 0 insertions, 1440 deletions
diff --git a/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch b/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch
deleted file mode 100644
index b1b00623d..000000000
--- a/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From 9b4959b97d2e95d4b49cf6ca2a3fce3cdb484f2d Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Thu, 31 Mar 2016 00:20:15 +0200
4Subject: [PATCH] 3rdparty/ippicv: Use pre-downloaded ipp
5
6Upstream-Status: Pending
7Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
8Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
9
10---
11 3rdparty/ippicv/ippicv.cmake | 15 +--------------
12 1 file changed, 1 insertion(+), 14 deletions(-)
13
14diff --git a/3rdparty/ippicv/ippicv.cmake b/3rdparty/ippicv/ippicv.cmake
15index 257af6fcc6..f88460450f 100644
16--- a/3rdparty/ippicv/ippicv.cmake
17+++ b/3rdparty/ippicv/ippicv.cmake
18@@ -34,18 +34,5 @@ function(download_ippicv root_var)
19 endif()
20
21 set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/ippicv")
22- ocv_download(FILENAME ${OPENCV_ICV_NAME}
23- HASH ${OPENCV_ICV_HASH}
24- URL
25- "${OPENCV_IPPICV_URL}"
26- "$ENV{OPENCV_IPPICV_URL}"
27- "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
28- DESTINATION_DIR "${THE_ROOT}"
29- ID IPPICV
30- STATUS res
31- UNPACK RELATIVE_URL)
32-
33- if(res)
34- set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE)
35- endif()
36+ set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE)
37 endfunction()
diff --git a/recipes-support/opencv/opencv/0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch b/recipes-support/opencv/opencv/0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch
deleted file mode 100644
index 59da6ab32..000000000
--- a/recipes-support/opencv/opencv/0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From d6bdd0a91eb0ed57688c0af5ba5088cf0afdc0a0 Mon Sep 17 00:00:00 2001
2From: Jochen Sprickerhof <jspricke@debian.org>
3Date: Mon, 8 Aug 2022 21:10:13 +0200
4Subject: [PATCH] Add missing header for LIBAVCODEC_VERSION_INT
5
6Upstream-Status: Backport [https://github.com/opencv/opencv/pull/22357]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 modules/videoio/src/ffmpeg_codecs.hpp | 1 +
10 1 file changed, 1 insertion(+)
11
12diff --git a/modules/videoio/src/ffmpeg_codecs.hpp b/modules/videoio/src/ffmpeg_codecs.hpp
13index 61788e0345..faad2596ed 100644
14--- a/modules/videoio/src/ffmpeg_codecs.hpp
15+++ b/modules/videoio/src/ffmpeg_codecs.hpp
16@@ -60,6 +60,7 @@ extern "C" {
17 #include <errno.h>
18 #endif
19
20+#include <libavcodec/version.h>
21 #include <libavformat/avformat.h>
22
23 #ifdef __cplusplus
24--
252.38.1
26
diff --git a/recipes-support/opencv/opencv/0001-Add-smaller-version-of-download_models.py.patch b/recipes-support/opencv/opencv/0001-Add-smaller-version-of-download_models.py.patch
deleted file mode 100644
index 46232ec5c..000000000
--- a/recipes-support/opencv/opencv/0001-Add-smaller-version-of-download_models.py.patch
+++ /dev/null
@@ -1,180 +0,0 @@
1From fca4d9eec289f22c081daa2c61a1110e3f268f92 Mon Sep 17 00:00:00 2001
2From: Tom Hochstein <tom.hochstein@nxp.com>
3Date: Tue, 1 Sep 2020 14:57:07 -0500
4Subject: [PATCH] Add smaller version of download_models.py
5
6Upstream-Status: Pending
7Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
8---
9 testdata/dnn/download_models_basic.py | 159 ++++++++++++++++++++++++++
10 1 file changed, 159 insertions(+)
11 create mode 100644 testdata/dnn/download_models_basic.py
12
13diff --git a/testdata/dnn/download_models_basic.py b/testdata/dnn/download_models_basic.py
14new file mode 100644
15index 0000000..5c8a616
16--- /dev/null
17+++ b/testdata/dnn/download_models_basic.py
18@@ -0,0 +1,159 @@
19+#!/usr/bin/env python
20+
21+from __future__ import print_function
22+import hashlib
23+import sys
24+import tarfile
25+if sys.version_info[0] < 3:
26+ from urllib2 import urlopen
27+else:
28+ from urllib.request import urlopen
29+
30+
31+class Model:
32+ MB = 1024*1024
33+ BUFSIZE = 10*MB
34+
35+ def __init__(self, **kwargs):
36+ self.name = kwargs.pop('name')
37+ self.url = kwargs.pop('url', None)
38+ self.filename = kwargs.pop('filename')
39+ self.sha = kwargs.pop('sha', None)
40+ self.archive = kwargs.pop('archive', None)
41+ self.member = kwargs.pop('member', None)
42+
43+ def __str__(self):
44+ return 'Model <{}>'.format(self.name)
45+
46+ def printRequest(self, r):
47+ def getMB(r):
48+ d = dict(r.info())
49+ for c in ['content-length', 'Content-Length']:
50+ if c in d:
51+ return int(d[c]) / self.MB
52+ return '<unknown>'
53+ print(' {} {} [{} Mb]'.format(r.getcode(), r.msg, getMB(r)))
54+
55+ def verify(self):
56+ if not self.sha:
57+ return False
58+ print(' expect {}'.format(self.sha))
59+ sha = hashlib.sha1()
60+ try:
61+ with open(self.filename, 'rb') as f:
62+ while True:
63+ buf = f.read(self.BUFSIZE)
64+ if not buf:
65+ break
66+ sha.update(buf)
67+ print(' actual {}'.format(sha.hexdigest()))
68+ return self.sha == sha.hexdigest()
69+ except Exception as e:
70+ print(' catch {}'.format(e))
71+
72+ def get(self):
73+ if self.verify():
74+ print(' hash match - skipping')
75+ return True
76+
77+ if self.archive or self.member:
78+ assert(self.archive and self.member)
79+ print(' hash check failed - extracting')
80+ print(' get {}'.format(self.member))
81+ self.extract()
82+ else:
83+ assert(self.url)
84+ print(' hash check failed - downloading')
85+ print(' get {}'.format(self.url))
86+ self.download()
87+
88+ print(' done')
89+ print(' file {}'.format(self.filename))
90+ return self.verify()
91+
92+ def download(self):
93+ try:
94+ r = urlopen(self.url, timeout=60)
95+ self.printRequest(r)
96+ self.save(r)
97+ except Exception as e:
98+ print(' catch {}'.format(e))
99+
100+ def extract(self):
101+ try:
102+ with tarfile.open(self.archive) as f:
103+ assert self.member in f.getnames()
104+ self.save(f.extractfile(self.member))
105+ except Exception as e:
106+ print(' catch {}'.format(e))
107+
108+ def save(self, r):
109+ with open(self.filename, 'wb') as f:
110+ print(' progress ', end='')
111+ sys.stdout.flush()
112+ while True:
113+ buf = r.read(self.BUFSIZE)
114+ if not buf:
115+ break
116+ f.write(buf)
117+ print('>', end='')
118+ sys.stdout.flush()
119+
120+models = [
121+ Model(
122+ name='Fcn',
123+ url='http://dl.caffe.berkeleyvision.org/fcn8s-heavy-pascal.caffemodel',
124+ sha='c449ea74dd7d83751d1357d6a8c323fcf4038962',
125+ filename='fcn8s-heavy-pascal.caffemodel'),
126+ Model(
127+ name='SqueezeNet_v1.1',
128+ url='https://raw.githubusercontent.com/DeepScale/SqueezeNet/b5c3f1a23713c8b3fd7b801d229f6b04c64374a5/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel',
129+ sha='3397f026368a45ae236403ccc81cfcbe8ebe1bd0',
130+ filename='squeezenet_v1.1.caffemodel'),
131+ Model(
132+ name='Colorization',
133+ url='https://raw.githubusercontent.com/richzhang/colorization/master/models/colorization_deploy_v2.prototxt',
134+ sha='f528334e386a69cbaaf237a7611d833bef8e5219',
135+ filename='colorization_deploy_v2.prototxt'),
136+ Model(
137+ name='Colorization',
138+ url='http://eecs.berkeley.edu/~rich.zhang/projects/2016_colorization/files/demo_v2/colorization_release_v2.caffemodel',
139+ sha='21e61293a3fa6747308171c11b6dd18a68a26e7f',
140+ filename='colorization_release_v2.caffemodel'),
141+ Model(
142+ name='OpenPose/pose/coco', # https://github.com/CMU-Perceptual-Computing-Lab/openpose
143+ url='http://posefs1.perception.cs.cmu.edu/OpenPose/models/pose/coco/pose_iter_440000.caffemodel',
144+ sha='ac7e97da66f3ab8169af2e601384c144e23a95c1',
145+ filename='openpose_pose_coco.caffemodel'),
146+ Model(
147+ name='YOLOv3', # https://pjreddie.com/darknet/yolo/
148+ url='https://pjreddie.com/media/files/yolov3.weights',
149+ sha='520878f12e97cf820529daea502acca380f1cb8e',
150+ filename='yolov3.weights'),
151+ Model(
152+ name='EAST', # https://github.com/argman/EAST (a TensorFlow model), https://arxiv.org/abs/1704.03155v2 (a paper)
153+ url='https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1',
154+ sha='3ca8233d6edd748f7ed23246c8ca24cbf696bb94',
155+ filename='frozen_east_text_detection.tar.gz'),
156+ Model(
157+ name='EAST',
158+ archive='frozen_east_text_detection.tar.gz',
159+ member='frozen_east_text_detection.pb',
160+ sha='fffabf5ac36f37bddf68e34e84b45f5c4247ed06',
161+ filename='frozen_east_text_detection.pb'),
162+]
163+
164+# Note: models will be downloaded to current working directory
165+# expected working directory is opencv_extra/testdata/dnn
166+if __name__ == '__main__':
167+ failedModels = []
168+ for m in models:
169+ print(m)
170+ if not m.get():
171+ failedModels.append(m.filename)
172+
173+ if failedModels:
174+ print("Following models have not been downloaded:")
175+ for f in failedModels:
176+ print("* {}".format(f))
177+ exit(15)
178--
1792.17.1
180
diff --git a/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch b/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
deleted file mode 100644
index 948a80faf..000000000
--- a/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
+++ /dev/null
@@ -1,28 +0,0 @@
1From 66e50ee69fa9ee2469d349100e70d8b296c4b4dc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 11 Sep 2018 00:21:18 -0700
4Subject: [PATCH] Dont use isystem
5
6clang really does not like it
7
8Upstream-Status: Pending
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11
12---
13 cmake/OpenCVPCHSupport.cmake | 2 ++
14 1 file changed, 2 insertions(+)
15
16diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
17index 08cd06def4..46c9c02da3 100644
18--- a/cmake/OpenCVPCHSupport.cmake
19+++ b/cmake/OpenCVPCHSupport.cmake
20@@ -18,6 +18,8 @@ IF(CV_GCC)
21 SET(PCHSupport_FOUND TRUE)
22 ENDIF()
23
24+ SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I")
25+ SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I")
26 SET(_PCH_include_prefix "-I")
27 SET(_PCH_isystem_prefix "-isystem")
28 SET(_PCH_define_prefix "-D")
diff --git a/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch b/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch
deleted file mode 100644
index d56b8ae67..000000000
--- a/recipes-support/opencv/opencv/0001-Make-ts-module-external.patch
+++ /dev/null
@@ -1,42 +0,0 @@
1From 11bbf909e08594628bd757d989ae34cf1bfe200b Mon Sep 17 00:00:00 2001
2From: Mingli Yu <mingli.yu@windriver.com>
3Date: Thu, 18 Jun 2020 05:51:38 +0000
4Subject: [PATCH] Make ts module external
5
6Make ts module external
7
8Reference: https://github.com/qbonnard/opencv/commit/6b229c5834cb9a0930425e762a6c7b03244d7abb
9
10Upstream-Status: Submitted [https://github.com/opencv/opencv/issues/8408]
11
12Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
13---
14 modules/ts/CMakeLists.txt | 5 +----
15 1 file changed, 1 insertion(+), 4 deletions(-)
16
17diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt
18index f95bed0793..66f315bcca 100644
19--- a/modules/ts/CMakeLists.txt
20+++ b/modules/ts/CMakeLists.txt
21@@ -4,9 +4,6 @@ if(NOT BUILD_opencv_ts AND NOT BUILD_TESTS AND NOT BUILD_PERF_TESTS)
22 ocv_module_disable(ts)
23 endif()
24
25-set(OPENCV_MODULE_TYPE STATIC)
26-set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
27-
28 if(WINRT)
29 # WINRT doesn't have access to environment variables
30 # so adding corresponding macros during CMake run
31@@ -16,7 +13,7 @@ endif()
32
33 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
34
35-ocv_add_module(ts INTERNAL opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
36+ocv_add_module(ts opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
37
38 ocv_glob_module_sources()
39 ocv_module_include_directories()
40--
412.24.1
42
diff --git a/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch b/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch
deleted file mode 100644
index aa7d335ea..000000000
--- a/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch
+++ /dev/null
@@ -1,32 +0,0 @@
1From e4ec6cea72da9e9ae5ba57140fa2f5c63f1f8295 Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Wed, 9 May 2018 13:33:59 -0700
4Subject: [PATCH] Temporarliy work around deprecated ffmpeg RAW function
5 compile failure until next uprev
6
7Upstream-Status: Inappropriate [platform specific]
8Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
9
10---
11 modules/videoio/src/cap_ffmpeg_impl.hpp | 8 ++++++++
12 1 file changed, 8 insertions(+)
13
14diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
15index 6dca724a89..ae55dd4555 100644
16--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
17+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
18@@ -774,6 +774,14 @@ struct ImplMutex::Impl
19
20 #endif
21
22+/* NOTE This is deprecated in ffmpeg and the code should be removed */
23+#ifndef AVFMT_RAWPICTURE
24+#define AVFMT_RAWPICTURE 0x0020
25+#endif /* AVFMT_RAWPICTURE */
26+#ifndef CODEC_FLAG_GLOBAL_HEADER
27+#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
28+#endif
29+
30 void ImplMutex::init()
31 {
32 impl = new Impl();
diff --git a/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch b/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch
deleted file mode 100644
index c5a64387f..000000000
--- a/recipes-support/opencv/opencv/0001-Use-Os-to-compile-tinyxml2.cpp.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From 59fafe6e39759e193b5764b36b4c5a93da352123 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 18 Aug 2020 00:36:49 -0700
4Subject: [PATCH] Use -Os to compile tinyxml2.cpp
5
6This workarounds issue [1] seen on riscv with gcc
7
8[1] https://github.com/riscv/riscv-gnu-toolchain/issues/624
9
10Upstream-Status: Inappropriate [ OE-Specific ]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 modules/datasets/CMakeLists.txt | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/modules/datasets/CMakeLists.txt b/modules/datasets/CMakeLists.txt
17index 56ca9e310..99b7a33f6 100644
18--- a/modules/datasets/CMakeLists.txt
19+++ b/modules/datasets/CMakeLists.txt
20@@ -2,7 +2,7 @@ set(the_description "datasets framework")
21
22 set(filter_srcs "${CMAKE_CURRENT_LIST_DIR}/src/tinyxml2/tinyxml2.cpp")
23 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
24- ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-suggest-override") # GCC
25+ ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-suggest-override -Os") # GCC
26 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
27 ocv_append_source_files_cxx_compiler_options(filter_srcs "-Wno-inconsistent-missing-override") # Clang
28 endif()
29--
302.28.0
31
diff --git a/recipes-support/opencv/opencv/0001-Use-the-one-argument-version-of-SetTotalBytesLimit.patch b/recipes-support/opencv/opencv/0001-Use-the-one-argument-version-of-SetTotalBytesLimit.patch
deleted file mode 100644
index 5d88d1a6a..000000000
--- a/recipes-support/opencv/opencv/0001-Use-the-one-argument-version-of-SetTotalBytesLimit.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From 9cfa84313c5833d7295fcf57be93d5d2aaadfd88 Mon Sep 17 00:00:00 2001
2From: Vincent Rabaud <vrabaud@google.com>
3Date: Sat, 10 Jul 2021 00:21:52 +0200
4Subject: [PATCH] Use the one argument version of SetTotalBytesLimit.
5
6The two argument versions has been deprecated, cf
7https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream
8
9Upstream-Status: Backport [9cfa84313c5833d7295fcf57be93d5d2aaadfd88 - from master after 4.5.3 tag]
10Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
11---
12 modules/dnn/src/caffe/caffe_io.cpp | 5 +++++
13 1 file changed, 5 insertions(+)
14
15diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
16index 2fc4d84f46..ebecf95eea 100644
17--- a/modules/dnn/src/caffe/caffe_io.cpp
18+++ b/modules/dnn/src/caffe/caffe_io.cpp
19@@ -92,6 +92,7 @@
20 #ifdef HAVE_PROTOBUF
21 #include <google/protobuf/io/coded_stream.h>
22 #include <google/protobuf/io/zero_copy_stream_impl.h>
23+#include <google/protobuf/stubs/common.h>
24 #include <google/protobuf/text_format.h>
25
26 #include <opencv2/core.hpp>
27@@ -1111,7 +1112,11 @@ static const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 by
28
29 bool ReadProtoFromBinary(ZeroCopyInputStream* input, Message *proto) {
30 CodedInputStream coded_input(input);
31+#if GOOGLE_PROTOBUF_VERSION >= 3006000
32+ coded_input.SetTotalBytesLimit(kProtoReadBytesLimit);
33+#else
34 coded_input.SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
35+#endif
36
37 return proto->ParseFromCodedStream(&coded_input);
38 }
39--
402.32.0
41
diff --git a/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch b/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch
deleted file mode 100644
index 7b2c4100a..000000000
--- a/recipes-support/opencv/opencv/0001-sfm-link-with-Glog_LIBS.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1From ffe20fc4ec46c6b491eff29a38f90686d4d035f6 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Mon, 12 Apr 2021 20:37:40 +0000
4Subject: [PATCH] sfm: link with Glog_LIBS
5
6* in 4.5.0 there was explicit linkage with GLOG_LIBRARY, but since 4.5.1 with:
7 https://github.com/opencv/opencv_contrib/commit/23ee62a19b7a3e50d6dbf295359d8b1aff2e03fd
8
9 it's gone, probably because Glog_FOUND is already set from Ceres,
10 but then GLOG_LIBRARIES is empty in LIBMV_LIGHT_LIBS and build with gold fails:
11
12FAILED: bin/example_tutorial_perspective_correction
13: && TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -DNDEBUG -DNDEBUG -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,--gc-sections -Wl,--as-needed samples/cpp/CMakeFiles/example_tutorial_perspective_correction.dir/tutorial_code/features2D/Homography/perspective_correction.cpp.o -o bin/example_tutorial_perspective_correction -ldl -lm -lpthread -lrt lib/libopencv_gapi.so.4.5.2 lib/libopencv_stitching.so.4.5.2 lib/libopencv_ts.so.4.5.2 lib/libopencv_alphamat.so.4.5.2 lib/libopencv_aruco.so.4.5.2 lib/libopencv_bgsegm.so.4.5.2 lib/libopencv_bioinspired.so.4.5.2 lib/libopencv_ccalib.so.4.5.2 lib/libopencv_dnn_objdetect.so.4.5.2 lib/libopencv_dnn_superres.so.4.5.2 lib/libopencv_dpm.so.4.5.2 lib/libopencv_face.so.4.5.2 lib/libopencv_fuzzy.so.4.5.2 lib/libopencv_hfs.so.4.5.2 lib/libopencv_img_hash.so.4.5.2 lib/libopencv_intensity_transform.so.4.5.2 lib/libopencv_line_descriptor.so.4.5.2 lib/libopencv_mcc.so.4.5.2 lib/libopencv_quality.so.4.5.2 lib/libopencv_rapid.so.4.5.2 lib/libopencv_reg.so.4.5.2 lib/libopencv_rgbd.so.4.5.2 lib/libopencv_saliency.so.4.5.2 lib/libopencv_sfm.so.4.5.2 lib/libopencv_stereo.so.4.5.2 lib/libopencv_structured_light.so.4.5.2 lib/libopencv_superres.so.4.5.2 lib/libopencv_surface_matching.so.4.5.2 lib/libopencv_tracking.so.4.5.2 lib/libopencv_videostab.so.4.5.2 lib/libopencv_wechat_qrcode.so.4.5.2 lib/libopencv_xfeatures2d.so.4.5.2 lib/libopencv_xobjdetect.so.4.5.2 lib/libopencv_xphoto.so.4.5.2 lib/libopencv_shape.so.4.5.2 lib/libopencv_highgui.so.4.5.2 lib/libopencv_datasets.so.4.5.2 lib/libopencv_ml.so.4.5.2 lib/libopencv_plot.so.4.5.2 lib/libopencv_phase_unwrapping.so.4.5.2 lib/libopencv_optflow.so.4.5.2 lib/libopencv_ximgproc.so.4.5.2 lib/libopencv_videoio.so.4.5.2 lib/libopencv_video.so.4.5.2 lib/libopencv_dnn.so.4.5.2 lib/libopencv_imgcodecs.so.4.5.2 lib/libopencv_objdetect.so.4.5.2 lib/libopencv_calib3d.so.4.5.2 lib/libopencv_features2d.so.4.5.2 lib/libopencv_flann.so.4.5.2 lib/libopencv_photo.so.4.5.2 lib/libopencv_imgproc.so.4.5.2 lib/libopencv_core.so.4.5.2 -Wl,-rpath-link,TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/build/lib && :
14lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::LogMessage(char const*, int)'
15lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::stream()'
16lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::~LogMessage()'
17lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::kLogSiteUninitialized'
18lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'fLI::FLAGS_v'
19lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::InitVLOG3__(int**, int*, char const*, int)'
20lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::LogMessageFatal(char const*, int)'
21lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()'
22collect2: error: ld returned 1 exit status
23
24 Add Glog_LIBS which is set to the same value as GLOG_LIBRARIES used to be.
25
26Upstream-Status: Submitted [https://github.com/opencv/opencv_contrib/pull/2923]
27
28Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
29---
30 modules/sfm/CMakeLists.txt | 1 +
31 1 file changed, 1 insertion(+)
32
33diff --git a/modules/sfm/CMakeLists.txt b/modules/sfm/CMakeLists.txt
34index 045a1fe6e..ee7cecdac 100644
35--- a/modules/sfm/CMakeLists.txt
36+++ b/modules/sfm/CMakeLists.txt
37@@ -84,6 +84,7 @@ set(LIBMV_LIGHT_LIBS
38 multiview
39 numeric
40 ${GLOG_LIBRARIES}
41+ ${Glog_LIBS}
42 ${GFLAGS_LIBRARIES}
43 )
44
diff --git a/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch b/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
deleted file mode 100644
index d39c05822..000000000
--- a/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
+++ /dev/null
@@ -1,71 +0,0 @@
1From f42c9b8c7bafcadc7e95fb25a391707f970eb426 Mon Sep 17 00:00:00 2001
2From: Huang Qiyu <huangqy.fnst@cn.fujitsu.com>
3Date: Fri, 19 May 2017 04:27:50 +0900
4Subject: [PATCH] To fix errors as following:
5
6"test_main.cpp:45: undefined reference to `parseCustomOptions(int, char**)'"
7"perf_abs.cpp:13: undefined reference to `cvtest::param_seed'"
8"test_superres.cpp:270: undefined reference to `checkIppStatus()'"
9
10Upstream-Status: Pending
11Signed-off-by: Huang Qiyu <huangqy.fnst@cn.fujitsu.com>
12
13Also add the visibility changes for certain OpenCL-related functions in
14ts module.
15
16Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
17
18---
19 modules/ts/include/opencv2/ts.hpp | 4 ++--
20 modules/ts/include/opencv2/ts/ocl_test.hpp | 2 +-
21 modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +-
22 3 files changed, 4 insertions(+), 4 deletions(-)
23
24diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp
25index ed7491a89a..80919d13ee 100644
26--- a/modules/ts/include/opencv2/ts.hpp
27+++ b/modules/ts/include/opencv2/ts.hpp
28@@ -728,7 +728,7 @@ protected:
29 }
30 };
31
32-extern uint64 param_seed;
33+CV_EXPORTS extern uint64 param_seed;
34
35 struct DefaultRngAuto
36 {
37@@ -791,7 +791,7 @@ private:
38 #endif
39 #endif
40
41-void parseCustomOptions(int argc, char **argv);
42+CV_EXPORTS void parseCustomOptions(int argc, char **argv);
43
44 #define CV_TEST_INIT0_NOOP (void)0
45
46diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp
47index 11572e9f48..438112e2aa 100644
48--- a/modules/ts/include/opencv2/ts/ocl_test.hpp
49+++ b/modules/ts/include/opencv2/ts/ocl_test.hpp
50@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src)
51 return dst;
52 }
53
54-extern int test_loop_times;
55+CV_EXPORTS extern int test_loop_times;
56
57 #define MAX_VALUE 357
58
59diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp
60index b2a4cac241..b94c681c0c 100644
61--- a/modules/ts/include/opencv2/ts/ts_ext.hpp
62+++ b/modules/ts/include/opencv2/ts/ts_ext.hpp
63@@ -9,7 +9,7 @@
64 #define OPENCV_TS_EXT_HPP
65
66 namespace cvtest {
67-void checkIppStatus();
68+CV_EXPORTS void checkIppStatus();
69 extern bool skipUnstableTests;
70 extern bool runBigDataTests;
71 extern int testThreads;
diff --git a/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch b/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch
deleted file mode 100644
index ef7831a5f..000000000
--- a/recipes-support/opencv/opencv/OpenCV_DNN_examples.patch
+++ /dev/null
@@ -1,141 +0,0 @@
1From 3c4daafb54f961e376104a461ca7ec114ff0331a Mon Sep 17 00:00:00 2001
2From: Ludek Slosarcik <ludek.slosarcik@nxp.com>
3Date: Fri, 14 Feb 2020 15:46:50 +0100
4Subject: [PATCH] opencv_dnn: added video device for 2 examples, and change text labels
5
6Signed-off-by: Ludek Slosarcik <ludek.slosarcik@nxp.com>
7
8Upstream-Status: Pending
9---
10 samples/cpp/logistic_regression.cpp | 2 +-
11 samples/dnn/classification.cpp | 7 ++++---
12 samples/dnn/object_detection.cpp | 10 +++++-----
13 samples/dnn/segmentation.cpp | 2 +-
14 samples/dnn/text_detection.cpp | 5 +++--
15 5 files changed, 14 insertions(+), 12 deletions(-)
16
17Index: git/samples/cpp/logistic_regression.cpp
18===================================================================
19--- git.orig/samples/cpp/logistic_regression.cpp
20+++ git/samples/cpp/logistic_regression.cpp
21@@ -28,7 +28,7 @@ static float calculateAccuracyPercent(co
22
23 int main()
24 {
25- const String filename = samples::findFile("data01.xml");
26+ const String filename = samples::findFile("../data/data01.xml");
27 cout << "**********************************************************************" << endl;
28 cout << filename
29 << " contains digits 0 and 1 of 20 samples each, collected on an Android device" << endl;
30Index: git/samples/dnn/classification.cpp
31===================================================================
32--- git.orig/samples/dnn/classification.cpp
33+++ git/samples/dnn/classification.cpp
34@@ -12,6 +12,7 @@ std::string keys =
35 "{ help h | | Print help message. }"
36 "{ @alias | | An alias name of model to extract preprocessing parameters from models.yml file. }"
37 "{ zoo | models.yml | An optional path to file with preprocessing parameters }"
38+ "{ device | 0 | camera device number. }"
39 "{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}"
40 "{ initial_width | 0 | Preprocess input image by initial resizing to a specific width.}"
41 "{ initial_height | 0 | Preprocess input image by initial resizing to a specific height.}"
42@@ -113,7 +114,7 @@ int main(int argc, char** argv)
43 if (parser.has("input"))
44 cap.open(parser.get<String>("input"));
45 else
46- cap.open(0);
47+ cap.open(parser.get<int>("device"));
48 //! [Open a video file or an image file or a camera stream]
49
50 // Process frames.
51@@ -195,14 +196,14 @@ int main(int argc, char** argv)
52 }
53 std::string label = format("Inference time of 1 round: %.2f ms", t1);
54 std::string label2 = format("Average time of 200 rounds: %.2f ms", timeRecorder.getTimeMilli()/200);
55- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
56- putText(frame, label2, Point(0, 35), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
57+ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
58+ putText(frame, label2, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
59
60 // Print predicted class.
61 label = format("%s: %.4f", (classes.empty() ? format("Class #%d", classId).c_str() :
62 classes[classId].c_str()),
63 confidence);
64- putText(frame, label, Point(0, 55), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
65+ putText(frame, label, Point(0, 70), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
66
67 imshow(kWinName, frame);
68 }
69Index: git/samples/dnn/object_detection.cpp
70===================================================================
71--- git.orig/samples/dnn/object_detection.cpp
72+++ git/samples/dnn/object_detection.cpp
73@@ -260,13 +260,13 @@ int main(int argc, char** argv)
74 if (predictionsQueue.counter > 1)
75 {
76 std::string label = format("Camera: %.2f FPS", framesQueue.getFPS());
77- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
78+ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
79
80 label = format("Network: %.2f FPS", predictionsQueue.getFPS());
81- putText(frame, label, Point(0, 30), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
82+ putText(frame, label, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
83
84 label = format("Skipped frames: %d", framesQueue.counter - predictionsQueue.counter);
85- putText(frame, label, Point(0, 45), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
86+ putText(frame, label, Point(0, 70), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
87 }
88 imshow(kWinName, frame);
89 }
90@@ -302,7 +302,7 @@ int main(int argc, char** argv)
91 double freq = getTickFrequency() / 1000;
92 double t = net.getPerfProfile(layersTimes) / freq;
93 std::string label = format("Inference time: %.2f ms", t);
94- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
95+ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
96
97 imshow(kWinName, frame);
98 }
99@@ -471,7 +471,7 @@ void drawPred(int classId, float conf, i
100 top = max(top, labelSize.height);
101 rectangle(frame, Point(left, top - labelSize.height),
102 Point(left + labelSize.width, top + baseLine), Scalar::all(255), FILLED);
103- putText(frame, label, Point(left, top), FONT_HERSHEY_SIMPLEX, 0.5, Scalar());
104+ putText(frame, label, Point(left, top), FONT_HERSHEY_SIMPLEX, 0.8, Scalar());
105 }
106
107 void callback(int pos, void*)
108Index: git/samples/dnn/segmentation.cpp
109===================================================================
110--- git.orig/samples/dnn/segmentation.cpp
111+++ git/samples/dnn/segmentation.cpp
112@@ -162,7 +162,7 @@ int main(int argc, char** argv)
113 double freq = getTickFrequency() / 1000;
114 double t = net.getPerfProfile(layersTimes) / freq;
115 std::string label = format("Inference time: %.2f ms", t);
116- putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0));
117+ putText(frame, label, Point(0, 20), FONT_HERSHEY_SIMPLEX, 0.8, Scalar(0, 0, 255), 2, 8, false);
118
119 imshow(kWinName, frame);
120 if (!classes.empty())
121Index: git/samples/dnn/text_detection.cpp
122===================================================================
123--- git.orig/samples/dnn/text_detection.cpp
124+++ git/samples/dnn/text_detection.cpp
125@@ -30,6 +30,7 @@ using namespace cv::dnn;
126 const char* keys =
127 "{ help h | | Print help message. }"
128 "{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}"
129+ "{ device | 0 | camera device number. }"
130 "{ detModel dmp | | Path to a binary .pb file contains trained detector network.}"
131 "{ width | 320 | Preprocess input image by resizing to a specific width. It should be multiple by 32. }"
132 "{ height | 320 | Preprocess input image by resizing to a specific height. It should be multiple by 32. }"
133@@ -106,7 +107,7 @@ int main(int argc, char** argv)
134
135 // Open a video file or an image file or a camera stream.
136 VideoCapture cap;
137- bool openSuccess = parser.has("input") ? cap.open(parser.get<String>("input")) : cap.open(0);
138+ bool openSuccess = parser.has("input") ? cap.open(parser.get<String>("input")) : cap.open(parser.get<int>("device"));
139 CV_Assert(openSuccess);
140
141 static const std::string kWinName = "EAST: An Efficient and Accurate Scene Text Detector";
diff --git a/recipes-support/opencv/opencv/download.patch b/recipes-support/opencv/opencv/download.patch
deleted file mode 100644
index 33ac48312..000000000
--- a/recipes-support/opencv/opencv/download.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From b18a280fab06a680d9f831bf8b462647f3cb6214 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@intel.com>
3Date: Thu, 9 Jan 2020 16:24:24 +0000
4Subject: [PATCH] opencv: abort configure if we need to download
5
6This CMake module will download files during do_configure. This is bad as it
7means we can't do offline builds.
8
9Add an option to disallow downloads by emitting a fatal error.
10
11Upstream-Status: Pending
12Signed-off-by: Ross Burton <ross.burton@intel.com>
13
14---
15 cmake/OpenCVDownload.cmake | 6 ++++++
16 1 file changed, 6 insertions(+)
17
18diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake
19index 63cf6d3238..4acf477f70 100644
20--- a/cmake/OpenCVDownload.cmake
21+++ b/cmake/OpenCVDownload.cmake
22@@ -14,6 +14,7 @@
23 # RELATIVE_URL - if set, then URL is treated as a base, and FILENAME will be appended to it
24 # Note: uses OPENCV_DOWNLOAD_PATH folder as cache, default is <opencv>/.cache
25
26+set(OPENCV_ALLOW_DOWNLOADS ON CACHE BOOL "Allow downloads")
27 set(HELP_OPENCV_DOWNLOAD_PATH "Cache directory for downloaded files")
28 if(DEFINED ENV{OPENCV_DOWNLOAD_PATH})
29 set(OPENCV_DOWNLOAD_PATH "$ENV{OPENCV_DOWNLOAD_PATH}" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
30@@ -156,6 +157,11 @@ function(ocv_download)
31
32 # Download
33 if(NOT EXISTS "${CACHE_CANDIDATE}")
34+ if(NOT OPENCV_ALLOW_DOWNLOADS)
35+ message(FATAL_ERROR "Not going to download ${DL_FILENAME}")
36+ return()
37+ endif()
38+
39 ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"")
40 foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST})
41 ocv_download_log("#try ${try}")
diff --git a/recipes-support/opencv/opencv/fix-build-with-protobuf-v22.patch b/recipes-support/opencv/opencv/fix-build-with-protobuf-v22.patch
deleted file mode 100644
index 3538f24b3..000000000
--- a/recipes-support/opencv/opencv/fix-build-with-protobuf-v22.patch
+++ /dev/null
@@ -1,408 +0,0 @@
1From 5e4150826fea6f37276f348c65d94ce4847d1211 Mon Sep 17 00:00:00 2001
2From: Kumataro <Kumataro@users.noreply.github.com>
3Date: Sat, 7 Oct 2023 10:11:25 +0900
4Subject: [PATCH] 3rdparty: supporting protobuf v22 and later
5
6Upstream-Status: Submitted [https://github.com/opencv/opencv/pull/24372]
7---
8 cmake/OpenCVFindProtobuf.cmake | 37 ++++++++++++++++++++++++++++++++++
9 modules/dnn/CMakeLists.txt | 9 +++++++++
10 2 files changed, 46 insertions(+)
11
12diff --git a/cmake/OpenCVFindProtobuf.cmake b/cmake/OpenCVFindProtobuf.cmake
13index 8835347d1d..9bd5c28db8 100644
14--- a/cmake/OpenCVFindProtobuf.cmake
15+++ b/cmake/OpenCVFindProtobuf.cmake
16@@ -67,6 +67,38 @@ else()
17 endif()
18 endif()
19
20+# See https://github.com/opencv/opencv/issues/24369
21+# In Protocol Buffers v22.0 and later drops C++11 support and depends abseil-cpp.
22+# Details: https://protobuf.dev/news/2022-08-03/
23+# And if std::text_view is in abseil-cpp requests C++17 and later.
24+if(HAVE_PROTOBUF)
25+ if("${Protobuf_VERSION}" MATCHES [[[0-9]+.([0-9]+).[0-9]+]])
26+ string(COMPARE GREATER_EQUAL "${CMAKE_MATCH_1}" "22" REQUEST_ABSL)
27+
28+ if(REQUEST_ABSL)
29+ string(COMPARE GREATER_EQUAL "${CMAKE_CXX_STANDARD}" "17" USED_AFTER_CXX17)
30+ if(NOT USED_AFTER_CXX17)
31+ message("CMAKE_CXX_STANDARD : ${CMAKE_CXX_STANDARD}")
32+ message("protobuf : ${Protobuf_VERSION}")
33+ message(FATAL_ERROR "protobuf(v22 and later) and abseil-cpp request CMAKE_CXX_STANDARD=17 and later.")
34+ endif()
35+
36+ ocv_check_modules(ABSL_STRINGS absl_strings)
37+ if(NOT ABSL_STRINGS_FOUND)
38+ message(FATAL_ERROR "protobuf(v22 and later) requests abseil-cpp(strings), but missing.")
39+ endif()
40+
41+ ocv_check_modules(ABSL_LOG absl_log)
42+ if(NOT ABSL_LOG_FOUND)
43+ message(FATAL_ERROR "protobuf(v22 and later) requests abseil-cpp(log), but missing.")
44+ endif()
45+
46+ endif()
47+ else()
48+ message(FATAL_ERROR "Protobuf version(${Protobuf_VERSION}) is unexpected to split.")
49+ endif()
50+endif()
51+
52 if(HAVE_PROTOBUF AND PROTOBUF_UPDATE_FILES AND NOT COMMAND PROTOBUF_GENERATE_CPP)
53 message(FATAL_ERROR "Can't configure protobuf dependency (BUILD_PROTOBUF=${BUILD_PROTOBUF} PROTOBUF_UPDATE_FILES=${PROTOBUF_UPDATE_FILES})")
54 endif()
55@@ -89,3 +121,8 @@ if(HAVE_PROTOBUF)
56 BUILD_PROTOBUF THEN "build (${Protobuf_VERSION})"
57 ELSE "${__location} (${Protobuf_VERSION})")
58 endif()
59+
60+if(HAVE_ABSL_STRINGS AND HAVE_ABSL_LOG)
61+ list(APPEND CUSTOM_STATUS absl)
62+ list(APPEND CUSTOM_STATUS_absl " abseil-cpp:" "YES (${ABSL_STRINGS_VERSION})" )
63+endif()
64diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
65index 804b78ead2..d32007b37e 100644
66--- a/modules/dnn/CMakeLists.txt
67+++ b/modules/dnn/CMakeLists.txt
68@@ -149,6 +149,15 @@ if(NOT BUILD_PROTOBUF)
69 list(APPEND include_dirs ${Protobuf_INCLUDE_DIRS})
70 endif()
71
72+if(HAVE_ABSL_STRINGS)
73+ list(APPEND libs ${ABSL_STRINGS_LIBRARIES})
74+ list(APPEND include_dirs ${ABSL_STRTRINGS_INCLUDE_DIRS})
75+endif()
76+if(HAVE_ABSL_LOG)
77+ list(APPEND libs ${ABSL_LOG_LIBRARIES})
78+ list(APPEND include_dirs ${ABSL_LOG_INCLUDE_DIRS})
79+endif()
80+
81 set(sources_options "")
82
83 list(APPEND libs ${LAPACK_LIBRARIES})
84From 06a7669521d205f647d3e718322ccd153cdbbb77 Mon Sep 17 00:00:00 2001
85From: Kumataro <Kumataro@users.noreply.github.com>
86Date: Sun, 8 Oct 2023 09:39:35 +0900
87Subject: [PATCH] dnn: disable some tests for external protobuf
88
89---
90 modules/dnn/CMakeLists.txt | 5 +++++
91 modules/dnn/src/caffe/caffe_io.cpp | 24 ++++++++++++++++++++++--
92 modules/dnn/test/test_layers.cpp | 16 ++++++++++++++++
93 3 files changed, 43 insertions(+), 2 deletions(-)
94
95diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
96index d32007b37e..face38465f 100644
97--- a/modules/dnn/CMakeLists.txt
98+++ b/modules/dnn/CMakeLists.txt
99@@ -254,6 +254,12 @@ ocv_create_module(${libs} ${dnn_runtime_libs})
100 ocv_add_samples()
101 ocv_add_accuracy_tests(${dnn_runtime_libs})
102
103+if(NOT BUILD_PROTOBUF)
104+ if(TARGET opencv_test_dnn)
105+ ocv_target_compile_definitions(opencv_test_dnn PRIVATE "OPENCV_DNN_EXTERNAL_PROTOBUF=1")
106+ endif()
107+endif()
108+
109 set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf")
110 file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp")
111 file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h")
112
113diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
114index ebecf95eea..ebceca84cf 100644
115--- a/modules/dnn/src/caffe/caffe_io.cpp
116+++ b/modules/dnn/src/caffe/caffe_io.cpp
117@@ -1130,7 +1130,17 @@ bool ReadProtoFromTextFile(const char* filename, Message* proto) {
118 parser.AllowUnknownField(true);
119 parser.SetRecursionLimit(1000);
120 #endif
121- return parser.Parse(&input, proto);
122+ const bool ret = parser.Parse(&input, proto);
123+
124+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
125+ if(!ret)
126+ {
127+ LOG(ERROR) << "Some data requires patched protobuf (available in OpenCV source tree only).";
128+ CV_Error_(Error::StsError,("Some data requires patched protobuf (available in OpenCV source tree only)."));
129+ }
130+#endif
131+
132+ return ret;
133 }
134
135 bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
136@@ -1148,7 +1158,17 @@ bool ReadProtoFromTextBuffer(const char* data, size_t len, Message* proto) {
137 parser.AllowUnknownField(true);
138 parser.SetRecursionLimit(1000);
139 #endif
140- return parser.Parse(&input, proto);
141+ const bool ret = parser.Parse(&input, proto);
142+
143+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
144+ if(!ret)
145+ {
146+ LOG(ERROR) << "Some data requires patched protobuf (available in OpenCV source tree only).";
147+ CV_Error_(Error::StsError,("Some data requires patched protobuf (available in OpenCV source tree only)."));
148+ }
149+#endif
150+
151+ return ret;
152 }
153
154
155diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp
156index 763d94b99c..a07d442d76 100644
157--- a/modules/dnn/test/test_layers.cpp
158+++ b/modules/dnn/test/test_layers.cpp
159@@ -754,7 +754,11 @@ TEST_F(Layer_RNN_Test, get_set_test)
160 EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
161 }
162
163+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
164 TEST_P(Test_Caffe_layers, Accum)
165+#else
166+TEST_P(Test_Caffe_layers, DISABLED_Accum) // requires patched protobuf (available in OpenCV source tree only)
167+#endif
168 {
169 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
170 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL, CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
171@@ -778,7 +782,11 @@ TEST_P(Test_Caffe_layers, ChannelNorm)
172 testLayerUsingCaffeModels("channel_norm", false, false);
173 }
174
175+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
176 TEST_P(Test_Caffe_layers, DataAugmentation)
177+#else
178+TEST_P(Test_Caffe_layers, DISABLED_DataAugmentation) // requires patched protobuf (available in OpenCV source tree only)
179+#endif
180 {
181 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
182 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
183@@ -787,7 +795,11 @@ TEST_P(Test_Caffe_layers, DataAugmentation)
184 testLayerUsingCaffeModels("data_augmentation_8x6", true, false);
185 }
186
187+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
188 TEST_P(Test_Caffe_layers, Resample)
189+#else
190+TEST_P(Test_Caffe_layers, DISABLED_Resample) // requires patched protobuf (available in OpenCV source tree only)
191+#endif
192 {
193 if (backend != DNN_BACKEND_OPENCV)
194 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
195@@ -795,7 +807,11 @@ TEST_P(Test_Caffe_layers, Resample)
196 testLayerUsingCaffeModels("nearest", false, false);
197 }
198
199+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
200 TEST_P(Test_Caffe_layers, Correlation)
201+#else
202+TEST_P(Test_Caffe_layers, DISABLED_Correlation) // requires patched protobuf (available in OpenCV source tree only)
203+#endif
204 {
205 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
206 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER,
207From 2c33798f41942aefc203183d673ce4846f32dba4 Mon Sep 17 00:00:00 2001
208From: Kumataro <Kumataro@users.noreply.github.com>
209Date: Sun, 8 Oct 2023 13:28:40 +0900
210Subject: [PATCH] use GREATER instead of GREATER_EQUAL and remove new blank
211 line at EOF
212
213---
214 cmake/OpenCVFindProtobuf.cmake | 6 ++++--
215 1 file changed, 4 insertions(+), 2 deletions(-)
216
217diff --git a/cmake/OpenCVFindProtobuf.cmake b/cmake/OpenCVFindProtobuf.cmake
218index 9bd5c28db8..ba147526d6 100644
219--- a/cmake/OpenCVFindProtobuf.cmake
220+++ b/cmake/OpenCVFindProtobuf.cmake
221@@ -71,12 +71,14 @@ endif()
222 # In Protocol Buffers v22.0 and later drops C++11 support and depends abseil-cpp.
223 # Details: https://protobuf.dev/news/2022-08-03/
224 # And if std::text_view is in abseil-cpp requests C++17 and later.
225+
226 if(HAVE_PROTOBUF)
227 if("${Protobuf_VERSION}" MATCHES [[[0-9]+.([0-9]+).[0-9]+]])
228- string(COMPARE GREATER_EQUAL "${CMAKE_MATCH_1}" "22" REQUEST_ABSL)
229+ string(COMPARE GREATER "${CMAKE_MATCH_1}" "21" REQUEST_ABSL) # >=22
230
231 if(REQUEST_ABSL)
232- string(COMPARE GREATER_EQUAL "${CMAKE_CXX_STANDARD}" "17" USED_AFTER_CXX17)
233+ string(COMPARE GREATER "${CMAKE_CXX_STANDARD}" "16" USED_AFTER_CXX17) # >=17
234+
235 if(NOT USED_AFTER_CXX17)
236 message("CMAKE_CXX_STANDARD : ${CMAKE_CXX_STANDARD}")
237 message("protobuf : ${Protobuf_VERSION}")
238From cd709eefbeedd116bf3495b42280323b932791ff Mon Sep 17 00:00:00 2001
239From: Kumataro <Kumataro@users.noreply.github.com>
240Date: Mon, 9 Oct 2023 21:51:04 +0900
241Subject: [PATCH] fix for review
242
243---
244 cmake/OpenCVFindProtobuf.cmake | 5 ----
245 modules/dnn/src/caffe/caffe_io.cpp | 24 ++----------------
246 modules/dnn/test/test_layers.cpp | 40 +++++++++++++++---------------
247 3 files changed, 22 insertions(+), 47 deletions(-)
248
249diff --git a/cmake/OpenCVFindProtobuf.cmake b/cmake/OpenCVFindProtobuf.cmake
250index ba147526d6..2faf1010bf 100644
251--- a/cmake/OpenCVFindProtobuf.cmake
252+++ b/cmake/OpenCVFindProtobuf.cmake
253@@ -123,8 +123,3 @@ if(HAVE_PROTOBUF)
254 BUILD_PROTOBUF THEN "build (${Protobuf_VERSION})"
255 ELSE "${__location} (${Protobuf_VERSION})")
256 endif()
257-
258-if(HAVE_ABSL_STRINGS AND HAVE_ABSL_LOG)
259- list(APPEND CUSTOM_STATUS absl)
260- list(APPEND CUSTOM_STATUS_absl " abseil-cpp:" "YES (${ABSL_STRINGS_VERSION})" )
261-endif()
262diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
263index ebceca84cf..ebecf95eea 100644
264--- a/modules/dnn/src/caffe/caffe_io.cpp
265+++ b/modules/dnn/src/caffe/caffe_io.cpp
266@@ -1130,17 +1130,7 @@ bool ReadProtoFromTextFile(const char* filename, Message* proto) {
267 parser.AllowUnknownField(true);
268 parser.SetRecursionLimit(1000);
269 #endif
270- const bool ret = parser.Parse(&input, proto);
271-
272-#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
273- if(!ret)
274- {
275- LOG(ERROR) << "Some data requires patched protobuf (available in OpenCV source tree only).";
276- CV_Error_(Error::StsError,("Some data requires patched protobuf (available in OpenCV source tree only)."));
277- }
278-#endif
279-
280- return ret;
281+ return parser.Parse(&input, proto);
282 }
283
284 bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
285@@ -1158,17 +1148,7 @@ bool ReadProtoFromTextBuffer(const char* data, size_t len, Message* proto) {
286 parser.AllowUnknownField(true);
287 parser.SetRecursionLimit(1000);
288 #endif
289- const bool ret = parser.Parse(&input, proto);
290-
291-#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
292- if(!ret)
293- {
294- LOG(ERROR) << "Some data requires patched protobuf (available in OpenCV source tree only).";
295- CV_Error_(Error::StsError,("Some data requires patched protobuf (available in OpenCV source tree only)."));
296- }
297-#endif
298-
299- return ret;
300+ return parser.Parse(&input, proto);
301 }
302
303
304diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp
305index a07d442d76..5c6fc541d7 100644
306--- a/modules/dnn/test/test_layers.cpp
307+++ b/modules/dnn/test/test_layers.cpp
308@@ -754,17 +754,17 @@ TEST_F(Layer_RNN_Test, get_set_test)
309 EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
310 }
311
312-#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
313 TEST_P(Test_Caffe_layers, Accum)
314-#else
315-TEST_P(Test_Caffe_layers, DISABLED_Accum) // requires patched protobuf (available in OpenCV source tree only)
316-#endif
317 {
318+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
319+ throw SkipTestException("Requires patched protobuf");
320+#else
321 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
322 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL, CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
323
324 testLayerUsingCaffeModels("accum", false, false, 0.0, 0.0, 2);
325 testLayerUsingCaffeModels("accum_ref", false, false, 0.0, 0.0, 2);
326+#endif
327 }
328
329 TEST_P(Test_Caffe_layers, FlowWarp)
330@@ -782,42 +782,42 @@ TEST_P(Test_Caffe_layers, ChannelNorm)
331 testLayerUsingCaffeModels("channel_norm", false, false);
332 }
333
334-#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
335 TEST_P(Test_Caffe_layers, DataAugmentation)
336-#else
337-TEST_P(Test_Caffe_layers, DISABLED_DataAugmentation) // requires patched protobuf (available in OpenCV source tree only)
338-#endif
339 {
340+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
341+ throw SkipTestException("Requires patched protobuf");
342+#else
343 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
344 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
345 testLayerUsingCaffeModels("data_augmentation", true, false);
346 testLayerUsingCaffeModels("data_augmentation_2x1", true, false);
347 testLayerUsingCaffeModels("data_augmentation_8x6", true, false);
348+#endif
349 }
350
351-#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
352 TEST_P(Test_Caffe_layers, Resample)
353-#else
354-TEST_P(Test_Caffe_layers, DISABLED_Resample) // requires patched protobuf (available in OpenCV source tree only)
355-#endif
356 {
357+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
358+ throw SkipTestException("Requires patched protobuf");
359+#else
360 if (backend != DNN_BACKEND_OPENCV)
361 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
362 testLayerUsingCaffeModels("nearest_2inps", false, false, 0.0, 0.0, 2);
363 testLayerUsingCaffeModels("nearest", false, false);
364+#endif
365 }
366
367-#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
368 TEST_P(Test_Caffe_layers, Correlation)
369-#else
370-TEST_P(Test_Caffe_layers, DISABLED_Correlation) // requires patched protobuf (available in OpenCV source tree only)
371-#endif
372 {
373+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
374+ throw SkipTestException("Requires patched protobuf");
375+#else
376 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
377 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER,
378 CV_TEST_TAG_DNN_SKIP_OPENCL, CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
379 testLayerUsingCaffeModels("correlation", false, false, 0.0, 0.0, 2);
380 }
381+#endif
382
383 TEST_P(Test_Caffe_layers, Convolution2Inputs)
384 {
385@@ -1644,12 +1644,11 @@ private:
386 int outWidth, outHeight, zoomFactor;
387 };
388
389-#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
390 TEST_P(Test_Caffe_layers, Interp)
391-#else
392-TEST_P(Test_Caffe_layers, DISABLED_Interp) // requires patched protobuf (available in OpenCV source tree only)
393-#endif
394 {
395+#ifdef OPENCV_DNN_EXTERNAL_PROTOBUF
396+ throw SkipTestException("Requires patched protobuf");
397+#else
398 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
399 // Cannot get memory!
400 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
401@@ -1686,6 +1685,7 @@ TEST_P(Test_Caffe_layers, DISABLED_Interp) // requires patched protobuf (availa
402
403 // Test an implemented layer.
404 testLayerUsingCaffeModels("layer_interp", false, false);
405+#endif
406 }
407
408 INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_Caffe_layers, dnnBackendsAndTargets());
diff --git a/recipes-support/opencv/opencv_4.6.0.imx.bb b/recipes-support/opencv/opencv_4.6.0.imx.bb
deleted file mode 100644
index 0195bc61a..000000000
--- a/recipes-support/opencv/opencv_4.6.0.imx.bb
+++ /dev/null
@@ -1,318 +0,0 @@
1# This recipe is for the i.MX fork of opencv. For ease of
2# maintenance, the top section is a verbatim copy of an OE-core
3# recipe. The second section customizes the recipe for i.MX.
4
5########## meta-openembedded copy ###########
6# Upstream hash: 72dc42966be7da07f9553f75b825123b81704f0b
7# Commit https://github.com/openembedded/meta-openembedded/commit/225ce6a14a8110ab6b573b4dc9f5297a03d17e0f added
8
9SUMMARY = "Opencv : The Open Computer Vision Library"
10HOMEPAGE = "http://opencv.org/"
11SECTION = "libs"
12
13LICENSE = "Apache-2.0"
14LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
15
16ARM_INSTRUCTION_SET:armv4 = "arm"
17ARM_INSTRUCTION_SET:armv5 = "arm"
18
19DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
20
21SRCREV_opencv = "b0dc474160e389b9c9045da5db49d03ae17c6a6b"
22SRCREV_contrib = "7b77c355a8fdc97667b3fa1e7a0d37e4973fc868"
23SRCREV_ipp = "a56b6ac6f030c312b2dce17430eef13aed9af274"
24SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
25SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
26SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12"
27SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252"
28
29def ipp_filename(d):
30 import re
31 arch = d.getVar('TARGET_ARCH')
32 if re.match("i.86$", arch):
33 return "ippicv_2020_lnx_ia32_20191018_general.tgz"
34 else:
35 return "ippicv_2020_lnx_intel64_20191018_general.tgz"
36
37def ipp_md5sum(d):
38 import re
39 arch = d.getVar('TARGET_ARCH')
40 if re.match("i.86$", arch):
41 return "ad189a940fb60eb71f291321322fe3e8"
42 else:
43 return "7421de0095c7a39162ae13a6098782f9"
44
45IPP_FILENAME = "${@ipp_filename(d)}"
46IPP_MD5 = "${@ipp_md5sum(d)}"
47
48SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
49SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol=https \
50 git://github.com/opencv/opencv_contrib.git;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/contrib;name=contrib;branch=master;protocol=https \
51 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20191018;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/ipp;name=ipp;protocol=https \
52 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/boostdesc;name=boostdesc;protocol=https \
53 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/vgg;name=vgg;protocol=https \
54 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/face;name=face;protocol=https \
55 git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/wechat_qrcode;name=wechat-qrcode;protocol=https \
56 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
57 file://0003-To-fix-errors-as-following.patch \
58 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
59 file://0001-Dont-use-isystem.patch \
60 file://download.patch \
61 file://0001-Make-ts-module-external.patch \
62 file://0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch \
63 file://fix-build-with-protobuf-v22.patch \
64 "
65SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
66
67# OpenCV wants to download more files during configure. We download these in
68# do_fetch and construct a source cache in the format it expects
69OPENCV_DLDIR = "${UNPACKDIR}/downloads"
70
71do_unpack_extra() {
72 tar xzf ${S}/ipp/ippicv/${IPP_FILENAME} -C ${S}
73
74 md5() {
75 # Return the MD5 of $1
76 echo $(md5sum $1 | cut -d' ' -f1)
77 }
78 cache() {
79 TAG=$1
80 shift
81 mkdir --parents ${OPENCV_DLDIR}/$TAG
82 for F in $*; do
83 DEST=${OPENCV_DLDIR}/$TAG/$(md5 $F)-$(basename $F)
84 test -e $DEST || ln -s $F $DEST
85 done
86 }
87 cache xfeatures2d/boostdesc ${S}/boostdesc/*.i
88 cache xfeatures2d/vgg ${S}/vgg/*.i
89 cache data ${S}/face/*.dat
90 cache wechat_qrcode ${S}/wechat_qrcode/*.caffemodel
91 cache wechat_qrcode ${S}/wechat_qrcode/*.prototxt
92}
93addtask unpack_extra after do_unpack before do_patch
94
95CMAKE_VERBOSE = "VERBOSE=1"
96
97EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${S}/contrib/modules \
98 -DWITH_1394=OFF \
99 -DENABLE_PRECOMPILED_HEADERS=OFF \
100 -DCMAKE_SKIP_RPATH=ON \
101 -DOPENCV_ICV_HASH=${IPP_MD5} \
102 -DIPPROOT=${S}/ippicv_lnx \
103 -DOPENCV_GENERATE_PKGCONFIG=ON \
104 -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \
105 -DOPENCV_ALLOW_DOWNLOADS=OFF \
106 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
107 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
108 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.2", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1 -DENABLE_SSE42=1", "", d)} \
109"
110LDFLAGS:append:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
111LDFLAGS:append:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed"
112
113EXTRA_OECMAKE:append:x86 = " -DX86=ON"
114# disable sse4.1 and sse4.2 to fix 32bit build failure
115# https://github.com/opencv/opencv/issues/21597
116EXTRA_OECMAKE:remove:x86 = " -DENABLE_SSE41=1 -DENABLE_SSE42=1"
117
118PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
119 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
120 ${@bb.utils.contains_any("LICENSE_FLAGS_ACCEPTED", "commercial_ffmpeg commercial", "libav", "", d)}"
121
122# TBB does not build for powerpc so disable that package config
123PACKAGECONFIG:remove:powerpc = "tbb"
124# tbb now needs getcontect/setcontext which is not there for all arches on musl
125PACKAGECONFIG:remove:libc-musl:riscv64 = "tbb"
126PACKAGECONFIG:remove:libc-musl:riscv32 = "tbb"
127
128PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade"
129PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
130PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
131PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF -DCMAKE_CXX_STANDARD=17,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
132PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
133PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
134PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
135PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
136PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
137PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
138PACKAGECONFIG[java] = "-DJAVA_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native fastjar-native openjdk-8-native,"
139PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
140PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
141PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
142PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/libopencl1,"
143PACKAGECONFIG[oracle-java] = "-DJAVA_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${ORACLE_JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native oracle-jse-jdk oracle-jse-jdk-native,"
144PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
145PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
146PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/_core/include,,python3-numpy,"
147PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
148PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
149PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,,"
150PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
151PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
152PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
153
154inherit pkgconfig cmake
155
156inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'setuptools3-base', '', d)}
157inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
158
159export PYTHON_CSPEC = "-I${STAGING_INCDIR}/${PYTHON_DIR}"
160export PYTHON = "${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
161export ORACLE_JAVA_HOME = "${STAGING_DIR_NATIVE}/usr/bin/java"
162export JAVA_HOME = "${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
163export ANT_DIR = "${STAGING_DIR_NATIVE}/usr/share/ant/"
164
165TARGET_CC_ARCH += "-I${S}/include "
166
167PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
168 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
169 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
170 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
171 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
172 ${PN}-apps"
173
174python populate_packages:prepend () {
175 cv_libdir = d.expand('${libdir}')
176 do_split_packages(d, cv_libdir, r'^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
177 do_split_packages(d, cv_libdir, r'^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
178 do_split_packages(d, cv_libdir, r'^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
179 do_split_packages(d, cv_libdir, r'^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
180
181 pn = d.getVar('PN')
182 metapkg = pn + '-dev'
183 d.setVar('ALLOW_EMPTY:' + metapkg, "1")
184 blacklist = [ metapkg ]
185 metapkg_rdepends = [ ]
186 packages = d.getVar('PACKAGES').split()
187 for pkg in packages[1:]:
188 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
189 metapkg_rdepends.append(pkg)
190 d.setVar('RRECOMMENDS:' + metapkg, ' '.join(metapkg_rdepends))
191
192 metapkg = pn
193 d.setVar('ALLOW_EMPTY:' + metapkg, "1")
194 blacklist = [ metapkg, "libopencv-ts" ]
195 metapkg_rdepends = [ ]
196 for pkg in packages[1:]:
197 if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.endswith('-dev') and not pkg.endswith('-dbg') and not pkg.endswith('-doc') and not pkg.endswith('-locale') and not pkg.endswith('-staticdev'):
198 metapkg_rdepends.append(pkg)
199 d.setVar('RDEPENDS:' + metapkg, ' '.join(metapkg_rdepends))
200}
201
202PACKAGES_DYNAMIC += "^libopencv-.*"
203
204FILES:${PN} = ""
205FILES:${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
206FILES:${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
207FILES:${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
208FILES:${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
209FILES:${PN}-java = "${datadir}/OpenCV/java"
210FILES:${PN}-samples = "${datadir}/opencv4/samples/"
211
212INSANE_SKIP:${PN}-java = "libdir"
213INSANE_SKIP:${PN}-dbg = "libdir"
214
215ALLOW_EMPTY:${PN} = "1"
216
217SUMMARY:python-opencv = "Python bindings to opencv"
218FILES:python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
219RDEPENDS:python-opencv = "python-core python-numpy"
220
221SUMMARY:python3-opencv = "Python bindings to opencv"
222FILES:python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
223RDEPENDS:python3-opencv = "python3-core python3-numpy"
224
225RDEPENDS:${PN}-apps = "bash"
226
227do_compile:prepend() {
228 # remove the build host info to improve reproducibility
229 if [ -f ${WORKDIR}/build/modules/core/version_string.inc ]; then
230 sed -i "s#${WORKDIR}#/workdir#g" ${WORKDIR}/build/modules/core/version_string.inc
231 fi
232}
233
234do_install:append() {
235 # Move Python files into correct library folder (for multilib build)
236 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
237 mv ${D}/usr/lib/* ${D}/${libdir}/
238 rm -rf ${D}/usr/lib
239 fi
240 # remove build host path to improve reproducibility
241 if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then
242 sed -e 's@${STAGING_DIR_HOST}@@g' \
243 -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake
244 fi
245 # remove setup_vars_opencv4.sh as its content is confusing and useless
246 if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
247 rm -rf ${D}${bindir}/setup_vars_opencv4.sh
248 fi
249}
250
251########## End of meta-openembedded copy ##########
252
253########## i.MX overrides ##########
254
255SUMMARY = "Opencv : The Open Computer Vision Library, i.MX Fork"
256
257LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
258
259# Replace the opencv URL with the fork
260SRC_URI:remove = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol=https"
261SRC_URI =+ "${OPENCV_SRC};branch=${SRCBRANCH};name=opencv"
262OPENCV_SRC ?= "git://github.com/nxp-imx/opencv-imx.git;protocol=https;branch=master"
263SRCBRANCH = "4.6.0_imx"
264SRCREV_opencv = "d3440df40a6e90cd1d2a1b729bcbc16aa4d42f5d"
265
266# Add opencv_extra
267SRC_URI += " \
268 git://github.com/opencv/opencv_extra.git;destsuffix=extra;name=extra;branch=master;protocol=https \
269 file://0001-Add-smaller-version-of-download_models.py.patch;patchdir=${UNPACKDIR}/extra \
270"
271SRCREV_FORMAT:append = "_extra"
272SRCREV_extra = "936854e2b666853d6d0732a8eabc2d699f4fa3d8"
273
274# Patch DNN example
275SRC_URI += " \
276 file://OpenCV_DNN_examples.patch \
277"
278
279PACKAGECONFIG:remove = "eigen"
280
281PACKAGECONFIG:append:mx8-nxp-bsp = " dnn text"
282PACKAGECONFIG:append:mx9-nxp-bsp = " dnn text"
283
284PACKAGECONFIG:append = " ${PACKAGECONFIG_OPENCL}"
285PACKAGECONFIG_OPENCL = ""
286PACKAGECONFIG_OPENCL:mx8-nxp-bsp = "opencl"
287PACKAGECONFIG_OPENCL:mx8dxl-nxp-bsp = ""
288PACKAGECONFIG_OPENCL:mx8mm-nxp-bsp = ""
289PACKAGECONFIG_OPENCL:mx8mnul-nxp-bsp = ""
290
291PACKAGECONFIG[openvx] = "-DWITH_OPENVX=ON -DOPENVX_ROOT=${STAGING_LIBDIR} -DOPENVX_LIB_CANDIDATES='OpenVX;OpenVXU',-DWITH_OPENVX=OFF,virtual/libopenvx,"
292PACKAGECONFIG[qt5] = "-DWITH_QT=ON -DOE_QMAKE_PATH_EXTERNAL_HOST_BINS=${STAGING_BINDIR_NATIVE} -DCMAKE_PREFIX_PATH=${STAGING_BINDIR_NATIVE}/cmake,-DWITH_QT=OFF,qtbase qtbase-native,"
293PACKAGECONFIG[qt6] = "-DWITH_QT=ON -DQT_HOST_PATH=${RECIPE_SYSROOT_NATIVE}${prefix_native},-DWITH_QT=OFF,qtbase qtbase-native,"
294PACKAGECONFIG[tests-imx] = "-DINSTALL_TESTS=ON -DOPENCV_TEST_DATA_PATH=${UNPACKDIR}/extra/testdata, -DINSTALL_TESTS=OFF,"
295PACKAGECONFIG[tim-vx] = "-DWITH_TIMVX=ON -DTIMVX_INSTALL_DIR=${STAGING_DIR_HOST}${libdir},-DWITH_TIMVX=OFF,tim-vx"
296
297# Disable cvv module in opencv_contrib as it is not yet suppported for Qt6
298# (opencv debug framework)
299EXTRA_OECMAKE:append = " -DBUILD_opencv_cvv=OFF"
300
301do_install:append() {
302 ln -sf opencv4/opencv2 ${D}${includedir}/opencv2
303 if ${@bb.utils.contains('PACKAGECONFIG', 'samples', 'true', 'false', d)}; then
304 install -d ${D}${datadir}/OpenCV/samples/data
305 cp -r ${S}/samples/data/* ${D}${datadir}/OpenCV/samples/data
306 install -d ${D}${datadir}/OpenCV/samples/bin/
307 cp -f bin/example_* ${D}${datadir}/OpenCV/samples/bin/
308 fi
309 if ${@bb.utils.contains('PACKAGECONFIG', 'tests-imx', 'true', 'false', d)}; then
310 cp -r share/opencv4/testdata/cv/face/* ${D}${datadir}/opencv4/testdata/cv/face/
311 fi
312}
313
314FILES:${PN}-samples += "${datadir}/OpenCV/samples"
315
316COMPATIBLE_MACHINE = "(mx8-nxp-bsp|mx9-nxp-bsp)"
317
318########## End of i.MX overrides ##########