summaryrefslogtreecommitdiff
path: root/media-libs/opencv
diff options
context:
space:
mode:
Diffstat (limited to 'media-libs/opencv')
-rw-r--r--media-libs/opencv/Manifest21
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-ade-0.1.2a.tar.gz.patch18
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-drop-python2-detection.patch23
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-eliminate-lto-compiler-warnings.patch36
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-libpng16.patch58
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-opencv_test.patch18
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-python3_12-support.patch25
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-use-system-flatbuffers.patch36
-rw-r--r--media-libs/opencv/files/opencv-4.8.1-use-system-opencl.patch25
-rw-r--r--media-libs/opencv/files/opencv_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch20
-rw-r--r--media-libs/opencv/files/opencv_contrib-4.8.1-rgbd.patch15
-rw-r--r--media-libs/opencv/metadata.xml34
-rw-r--r--media-libs/opencv/opencv-4.8.1-r1.ebuild646
-rw-r--r--media-libs/opencv/opencv-4.8.1.ebuild614
14 files changed, 959 insertions, 630 deletions
diff --git a/media-libs/opencv/Manifest b/media-libs/opencv/Manifest
index 915a6b9c73bc..7cf5d19a67ff 100644
--- a/media-libs/opencv/Manifest
+++ b/media-libs/opencv/Manifest
@@ -7,6 +7,18 @@ AUX opencv-4.8.0-arm64-fp16.patch 12222 BLAKE2B 18803d74cb57bbc303c8159ca69d24dc
AUX opencv-4.8.0-fix-cuda-12.2.0.patch 1920 BLAKE2B c43157c4859666a962fa40ed435aeab6b17ac01b9b67dbba0955fb7c009504b1780f5de2a40ee63db245cadf0da41b40fda0d7e06ad719071b12ba385f693ea2 SHA512 5ab0c15811748307971e8939a40c08c2c9cf3e38d2acafff72a3890f6d7c7133d8c7a087cf1a05b2dbe1907dd88911872c61c10f7638edb46ee679f658b265c6
AUX opencv-4.8.0-fix-flatbuffer.patch 1764 BLAKE2B 806f61bf7017fbcb5b5058686db9dd2272eb61d6a2952f0f029bc76d62172a18f9a21661426f13cfd5066fc60710b218bb9b2dfded61e33040469da0e0b72c94 SHA512 2679f52c3df16b7daac1fafa0b24796568a2555de03805ee6ee6b2e08a2be9f63fca44c1b472f5ffe2dfb7fe8b3d754b3ba39a71419974613a9b3de70a09cefb
AUX opencv-4.8.0-fix-protobuf.patch 543 BLAKE2B 2c3ac7ddeda366cb117d5deddefe732dd6918bc54e468b1cc8d95e40bb9e5cde1776046a894e8f26416edffa39dc6c97547cbd688e0566587f9690e721b4c1e1 SHA512 799e3f3d019624476a285c2795d28f022bb126e9b9f511b153aef131a7cae2e3fb6361bd21b7ea34dfea984e3ef9e1a0a40d09a5a72a808a31e1eb15548b15a7
+AUX opencv-4.8.1-ade-0.1.2a.tar.gz.patch 652 BLAKE2B 91b933513485c5e4a33b3711328f01752ea8f77bf26701744ff9a7d56f899227c1f5899dd68ec7050929c2068e2d5dc805533173543ac0ab5a5db827a6d075c3 SHA512 61267dae88ca1e9f5d99e6d57101c0a0a2df2bc5fc9f646d14953707f8c1f4fc9f58e7861b007f5970603f267f797c43cbc35e29aa66e343fcfa6e568750934e
+AUX opencv-4.8.1-drop-python2-detection.patch 1041 BLAKE2B bd7c4f66b36d04b57a4493df1b00ee6700ed6f28464f2538bde62d2b2a3d29ebb82946a1765540e6977ce6ee111dc2f37c3419ee74536f9c55340ae2e550d48a SHA512 7e5e36fa1fc312a4c791c099618c73b2f4ed5810a66f4de4ead5d0f5917d60c191c55289538bf908bcfa45522939ddfac62505e79fbfb7c3ea046a2027b576ff
+AUX opencv-4.8.1-eliminate-lto-compiler-warnings.patch 1241 BLAKE2B eead5a16616fd9afcced21180e8e336e32ad387ff4010c55e5edcf2f81f09244c4914c98ab0439911f5ab8df1f61527a83ff5f09db65743fc5266748fc8bf969 SHA512 b3907b9d9f96f107fd27189961fe1a15b5706f66524cf21ea342ed04eedfa21c08d7572001d3afb70c54a7bfef56093fd7f8ac7a5dd9ea768f1b0412b5658eec
+AUX opencv-4.8.1-libpng16.patch 2299 BLAKE2B 2aa6e7c2e35106b5c9243ad04b55eff650dc5351d73eafa2d4f703e2a965992c2145ba80f32e5e3c8a35b2370f301cb716387d9366cfc729add455a734243f6d SHA512 35b5441e78e7f62e5965350e1eae3060f258be26ac27d5a8c723b18b14e381327bb202409dfa0915ee81903b4f5ca660abd689967119ee6b3eb3bdb32072be4f
+AUX opencv-4.8.1-opencv_test.patch 724 BLAKE2B 0b56c5a7a9bd86c0d85b740284f00ecddecf2a36319565074cf23966599adf632747d67dac0dd55471a4110b157173849558920fe8cc2fa4b7126542eb546fac SHA512 a1ba01ce63f27fd8f3197860af5153940a4e751bb56cec2cd978ca3c1495da9ee9bac8e70187f1e6ef0a7d3585f8625f79753b10c41500344d35104b4f774795
+AUX opencv-4.8.1-python3_12-support.patch 1354 BLAKE2B 6f1e5c7b8c3ddd3bbbe3bc9f4123ef114312155cab5eec34e431574cbc7e564f1ac87152a8adf11af75d386b2701bf4f7c337eb1941a6c699170b400013d5683 SHA512 2638f1cfb638de73e5e8a46b415844961d02ae9f398d9748535ec392c410ece010b3ee8d82a6510a153879f213aa07008f445e1cfa1144e7fd9ffbfe13e94e82
+AUX opencv-4.8.1-use-system-flatbuffers.patch 1522 BLAKE2B a9000e3269266cf9e85b6ba247fd977eb1c2e0bf771d0ba1432ba1f56802f72062402e55e7327e91085be870338e452ac08ec8a958d3cf51fdd9a8daf0cfee76 SHA512 50d7ee7de6513ea56974c598641c2d9edb7679f273f6313c1dd7e68ba667688ad50fd61691661702fab75ddfa1165cd96a52ebebd19c8c09116612c90c8b11d3
+AUX opencv-4.8.1-use-system-opencl.patch 933 BLAKE2B 557448d74771f6b9fc8b2fa5af79e6287c1dbad9a6c5dabe520080c7481d033002164cbfdd5a767d3b4cc54ec1344423ea8a0bbbd13a873ca955d95787924d10 SHA512 1602b74e829cd8842efbe6535e91a426a88c9ae08280d863bc4150cbe2a9d3ebef02b2abe98ee470f26412bb6fca653529492bf54b87f4d53fe20f242ef03771
+AUX opencv_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch 1158 BLAKE2B c4b139198ac5c33974d6c4fac8ebcf288f15d9edf09e55b30e47071931abdf8924dc51c2d8cb27103edb3b815ba9f7e5ea334cfb1849be7b59ff4cd076f6771a SHA512 03d4442af9b98115126473cca0a9f581bd0c0e983b8d5b7f34fdd0ea7455d4a73163f853c80438f4390c5da4c7cc419c59c24643529df9eb4222915c80e654fe
+AUX opencv_contrib-4.8.1-rgbd.patch 477 BLAKE2B 0120e631199d7099bae437d459f0c950c3cbd11e5f0a900d687ca5aedf1d7602f7faa3be5ba1a9b3e0758f3fd70574450f97bd7429e447df7440d58326ceb99b SHA512 6fe2ef40bf26d40e4f52d84b17183f6e536b2fe51bf65266be6a59865def0b9c074aa5eff58a60d673afec776a7ba03acaba667c917b78751950b77f68759d96
+DIST NVIDIAOpticalFlowSDK-edb50da3cf849840d680249aa6dbef248ebce2ca.tar.gz 8771 BLAKE2B f579960448bdaf57fbefd5e88002d8f6f4dbb828429b0f3a0112916c03039d4e4de65263eb8464a4d62924c1b77f0a61c2d93b7307657439bfbf7d59785f1533 SHA512 85dfdc52260f54f62c980508f4b6ab384e44200bd1c13761c4947f9a898c08f0faed2d734a85a4ba7a46f8788ed58ee89f12f61cee97881b69ba626bbd04f655
+DIST ade-0.1.2a.tar.gz 116737 BLAKE2B 9ac2af2f21aab8cb5d599e0b653bb6126642588e508f55e5fbfe5ce9607267f25e5187fd31ed69349064551c06e15b2ba548319708ed5f70e7761470775cc6e0 SHA512 d3ed210ff25f4c05393b0039cb4a73a6ceb8b42ba3d776e0469da2362899d3f76564cc6a06965b7de91f38517e1cd4ff4b18c00185d2b1a0af5a34ecf0d9dd44
DIST opencv-3.4.0-face_landmark_model.tar.gz 63299830 BLAKE2B 58f08cd8c030ee1c8b66e76a561fd625e112face427d001185f8d7c0eaace55adbd8474663021841a1382bfe393a210e64c51223441713cdb9156fac866a845c SHA512 2cd29ce42c08b2966db3ef4a2bc217ab3d07051819757ec6de8f3deea29e28f60abab39f101dba03f766f17018598e411bd687a7eaab0c681c113e10a2de2b23
DIST opencv-3.4.0-res10_300x300-caffeemodel.tar.gz 10036604 BLAKE2B 2a2de48fc420f13e7be146ac88f311901c5b4e409c30e466152e33cae1f8afd87dcb6d758af447c268d90bd67989c8798cd80cab172b10499a6ad5224509dbdf SHA512 96fee9f447d5739bc01a5cab37c453cf7237457dfb5d2bf93ac37f8e5aa557ac222316f449cd58e37e856abe4d8e9d4a7820daaba32f0b22cbcde8e340287d4b
DIST opencv-4.4.0_extdep.tar.gz 65334871 BLAKE2B 89fa0083da428e986bb4287295bdbff626d0f84866377413649c1d7ca77338288141f22d2a3c0b64d6d0fc1db98f918c8b33a665274cee4c4aefb44359e4333d SHA512 7b758099ce4abef151051e3e9e1e45b73e4054669d3aa53051e4d4c5f43d9373c9bda5ecbce51f6b024562cb566bd1117505af29ab5f3c36a493f185111a3b4e
@@ -14,7 +26,12 @@ DIST opencv-4.8.0.tar.gz 91992565 BLAKE2B eede5479acdcef7dfb49d260b696ed14e85a27
DIST opencv-4.8.0_contrib.tar.gz 59201076 BLAKE2B e30c4f17e1e89c8b0821bbf8ea44b6b4ce505ad2761222a8b119c5aee5ae4ef50e06a73f41fee3b2fa60b71c736989904f6d1fb31a16abfe39e605e2d32d851b SHA512 81cc41cfe1ea03e60b0657edeaa76a90926e5e79a9f93a482e17bc9edbf1b5ce36b13d108fd8fb097f2fb3d6381fbeb102811f44bfc761c2de7f69bf3c5298a1
DIST opencv-4.8.1.tar.gz 92006711 BLAKE2B 54728a37e3e8a528bd8d2e6df5963a996820a51160d05ac72b350234ce5372f99c037af96e13c55de1452e517fffb478c2335b9e1cbc07a36c78f99351eabd58 SHA512 b98d89b8e7b8ae8138bce00c5226816b761b53fbeb8f28ca516e08c5d130f216f9388a81785cd6684034530f768e097cbe12f19a9361f362b7d2048bfc427a65
DIST opencv-4.8.1_contrib.tar.gz 59200293 BLAKE2B 8cf3ee60cb38a9fa2649013b9b4704022abe5cc65c331078dc7ea87028bc99df8b0de12f835905f5bb5c00a811f256754cac018ca8e02739ac5c6fe36aa4346d SHA512 e3df49e6a1411f55eebbc02f4534ddefabff961b4f63c69b21fe06ff3df894773a8643ab0cb123b83c2bdc8fa02698b332d3c243e8546c894e6c6c8ecaa65500
+DIST opencv_3rdparty-34e4206aef44d50e6bbcd0ab06354b52e7466d26.tar.gz 397901 BLAKE2B 9adbe14ee3a2c90b890be694aa80d65b67e23a23f47ccabee4564e31eb9857d717b5a751df32004cfa5d6a53a9e1d8ea8d8943b705a0eaea5ca741169e2222f6 SHA512 8a92555aed2ac8752818586ab9762dd96ec128c5465cb87e402f15b15d16f7d371b3de045ef7295526e9ef99ec817766bb685a21d24dba29c650cf44e384a4e3
+DIST opencv_3rdparty-8afa57abc8229d611c4937165d20e2a2d9fc5a12.tar.gz 63301261 BLAKE2B 923dc944edfda4c292d42207290bee414bfe21998f6ffe341ea3b38b6f2f581f3a243653e2c1fd3fa86084068ad6e7acd5ca73ab43094aa15f124d379833a5d8 SHA512 68cce870da0846cbd12a093ec7896b510e34590dad2b91699be1df5d4f72d343f9789d54c45c1b801784f7e57e0e80b19ba65dd99855225da99b4193dae97aaa
+DIST opencv_3rdparty-a8b69ccc738421293254aec5ddb38bd523503252.tar.gz 920403 BLAKE2B 5f834e8ccef9d88d0650f8ae5d215a2d07d0a356aaad4de1622068e0b2a7def88fccc84bc4397f0182732e836fcd6e363ae25a2cdeaa4d458a7d8ef9afc81da5 SHA512 5611b9db40477759213ab35320570c198f1f224f92ca801ca3accd1f7620faf3d44f306e44abefd10be118acee9b56da643ca82abaa7c4d2102fe92e5b298a6e
+DIST opencv_3rdparty-b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f.tar.gz 10036903 BLAKE2B c13559569808db24105049e2081bc466c0e8b6dab58bcc69001e49ff82e03ec4701e25648b5e542b7df2c8e522abfbd82c9825e66c37d6a673847b41bf6effae SHA512 3fc44f12802aa1dad0b12372d53242ae2134a2d74ca0b6d8e4639551623426106781a41d77ebfce79ac625a49aec26b0d7425e0d31f09bab6a15e3d43caef8bc
+DIST opencv_3rdparty-fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d.tar.gz 1470898 BLAKE2B f1794cc8f8684501f670db3d720c02f35c57ebe91f276cc21dea1f1c1426740d03569143fec74380e941703b5086db5f013ca913fb296eda99559115fd53ca30 SHA512 07118b9d688bf0ff34a6e4ca1548006124d80d11e7b48f08c9e1910b64249b1dad0ace460f50adda0ecb69b90871fc59cc25f451570c63f7c6d6ba2b92d8801c
DIST vgg_boostdesc-3.2.0.tar.gz 1867770 BLAKE2B 1fa5b58e73b6fa56ecf8d19af22298f729942ee1369082e173445d09d3de767bf844bad3d2b462efc1199c392f37c88ba49a9996ba8bfd84b4abeba7de94db63 SHA512 4a046aedd639c8eb4b295b0f499e756deb66210ca083f0124c75531e540663367cb58f6d175f66c4713324177036cd89a8869bdab2de8d1736dafc7f00ef9f44
EBUILD opencv-4.8.0-r1.ebuild 21546 BLAKE2B 188f2883b59013f491619ef99bce3a7baedaf63876f6a1783cc7216b850dbf16196779dca3cc1928c634a1fbacd20b99efe438bd831373f05486bfcd10b52805 SHA512 67a521b21c3126826377fd9d8f1b179860d1e030022931bd0bc9f6965ee0b2de2e3fc6aeaf33d670e9b5dd8e718396624be9b8a22538279aea27e21f0f79a358
-EBUILD opencv-4.8.1.ebuild 22010 BLAKE2B f45246f83b047a92b03a544571a50517e4c982fae42190afd01bc1d77e1c6aa40d157ea0d580ea570ab9871fccf3bb07755ea3730a88182a42ea66a411c66709 SHA512 78be48109a65ed6e0a648acbf87d11cc6183af1a701dcb186e806e367cff7e074ab4d90c2bcbeff60310064791c15bd2b43d9eb5b1ba9fdfc53bf6b3fe3de9e0
-MISC metadata.xml 3328 BLAKE2B 98c8c2d01ef460e9a52f36d7aed03f61295aba32d977498cfa60411c4c428dcca0447e5062861134aeb7e3d3d1f02fab9f57438d5794ce99df6d57c18418fc5a SHA512 a1f749b3dfb3cc2912c3f8041f8d5ecb5ce7c7e61189c5d1f063a0034da88b9fc35b6aaa81f8c3cc0b22f09096cecefe2ad6c64ef6a22d446f6da71b7d2735f8
+EBUILD opencv-4.8.1-r1.ebuild 21641 BLAKE2B 066ba03a545f0952f15b2061e183beb8ab6fafebbd8ae9c6d13f687189889abcb5158e8baffc106dd5e2ee2971ad2b658aa3699cf64c8f5adead3a266d6553ec SHA512 453233aa0c6075722810ba736c5f04bfb0eefdb852c51185aeea19f62d254a667e4b46757cbcb393024114cb9bbd16bbd0fe172241156a53dfc1a7cca9d49b8f
+MISC metadata.xml 3496 BLAKE2B 8b592d16ed3235c2bcd5f199a7a59c2c33c8d2d4cf5e7c894b09a82134c0b2a9339e79da7bb55be15a038142f9396be38265d5c8a8a28d347d2b4db86b550aed SHA512 58d09b8dfa586c9d7abb4d0eedbff2e079233627d7748c2c0504b5596227590e0bd5c77aae699b3f12bd33e298dde585ac9bd73f746cb19affe6dbe483ef5ea6
diff --git a/media-libs/opencv/files/opencv-4.8.1-ade-0.1.2a.tar.gz.patch b/media-libs/opencv/files/opencv-4.8.1-ade-0.1.2a.tar.gz.patch
new file mode 100644
index 000000000000..056553695ee2
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-ade-0.1.2a.tar.gz.patch
@@ -0,0 +1,18 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Use tar.gz instead of zip to make CI happy.
+
+diff --git a/modules/gapi/cmake/DownloadADE.cmake b/modules/gapi/cmake/DownloadADE.cmake
+index e22c4f1..fb0c10a 100644
+--- a/modules/gapi/cmake/DownloadADE.cmake
++++ b/modules/gapi/cmake/DownloadADE.cmake
+@@ -1,7 +1,7 @@
+ set(ade_src_dir "${OpenCV_BINARY_DIR}/3rdparty/ade")
+-set(ade_filename "v0.1.2a.zip")
++set(ade_filename "v0.1.2a.tar.gz")
+ set(ade_subdir "ade-0.1.2a")
+-set(ade_md5 "fa4b3e25167319cb0fa9432ef8281945")
++set(ade_md5 "89fd5f32c2796d3fecf62273c4aa7c4d")
+ ocv_download(FILENAME ${ade_filename}
+ HASH ${ade_md5}
+ URL
diff --git a/media-libs/opencv/files/opencv-4.8.1-drop-python2-detection.patch b/media-libs/opencv/files/opencv-4.8.1-drop-python2-detection.patch
new file mode 100644
index 000000000000..5a3a89f665b4
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-drop-python2-detection.patch
@@ -0,0 +1,23 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Python2 is long gone. So don't try finding it.
+
+diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
+index 599b2eb..345e3ef 100644
+--- a/cmake/OpenCVDetectPython.cmake
++++ b/cmake/OpenCVDetectPython.cmake
+@@ -268,14 +268,6 @@ if(OPENCV_PYTHON_SKIP_DETECTION)
+ return()
+ endif()
+
+-find_python("" "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
+- PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
+- PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
+- PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
+- PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
+- PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH
+- PYTHON2_NUMPY_INCLUDE_DIRS PYTHON2_NUMPY_VERSION)
+-
+ option(OPENCV_PYTHON3_VERSION "Python3 version" "")
+ find_python("${OPENCV_PYTHON3_VERSION}" "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
+ PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
diff --git a/media-libs/opencv/files/opencv-4.8.1-eliminate-lto-compiler-warnings.patch b/media-libs/opencv/files/opencv-4.8.1-eliminate-lto-compiler-warnings.patch
new file mode 100644
index 000000000000..7d6a5456a63f
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-eliminate-lto-compiler-warnings.patch
@@ -0,0 +1,36 @@
+https://github.com/opencv/opencv/pull/23991
+
+From 4ee0f212cc19f7e77483d34d4cf8378945e3da31 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=E4=B8=8D=E9=B1=BC=E5=84=BF?=
+ <36976072+buyuer@users.noreply.github.com>
+Date: Fri, 14 Jul 2023 08:45:14 +0000
+Subject: [PATCH] Eliminating compilation warnings when using lto in gcc12 and
+ later versions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+use -flto=auto when use gcc12 or later
+
+Signed-off-by: 不鱼儿 <36976072+buyuer@users.noreply.github.com>
+---
+ cmake/OpenCVCompilerOptions.cmake | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
+index d4600943fb0d..8bd86681303e 100644
+--- a/cmake/OpenCVCompilerOptions.cmake
++++ b/cmake/OpenCVCompilerOptions.cmake
+@@ -261,7 +261,11 @@ if(CV_GCC OR CV_CLANG)
+ endif()
+
+ if(ENABLE_LTO)
+- add_extra_compiler_option(-flto)
++ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
++ add_extra_compiler_option(-flto=auto)
++ else()
++ add_extra_compiler_option(-flto)
++ endif()
+ endif()
+ if(ENABLE_THIN_LTO)
+ add_extra_compiler_option(-flto=thin)
diff --git a/media-libs/opencv/files/opencv-4.8.1-libpng16.patch b/media-libs/opencv/files/opencv-4.8.1-libpng16.patch
new file mode 100644
index 000000000000..a5b2aedb063a
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-libpng16.patch
@@ -0,0 +1,58 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Gentoo installs libpng as libpng16, so adjust the detection.
+
+diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
+index 46b5108..0ff88ea 100644
+--- a/cmake/OpenCVFindLibsGrfmt.cmake
++++ b/cmake/OpenCVFindLibsGrfmt.cmake
+@@ -245,9 +245,9 @@ if(NOT HAVE_SPNG AND WITH_PNG)
+ include(FindPNG)
+ if(PNG_FOUND)
+ include(CheckIncludeFile)
+- check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
+- if(HAVE_LIBPNG_PNG_H)
+- ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
++ check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" HAVE_LIBPNG16_PNG_H)
++ if(HAVE_LIBPNG16_PNG_H)
++ ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
+ else()
+ ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
+ endif()
+@@ -255,7 +255,7 @@ if(NOT HAVE_SPNG AND WITH_PNG)
+ endif()
+
+ if(NOT PNG_FOUND)
+- ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
++ ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG16_PNG_H PNG_DEFINITIONS)
+
+ set(PNG_LIBRARY libpng CACHE INTERNAL "")
+ set(PNG_LIBRARIES ${PNG_LIBRARY})
+diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in
+index d6c7875..005e9b3 100644
+--- a/cmake/templates/cvconfig.h.in
++++ b/cmake/templates/cvconfig.h.in
+@@ -79,7 +79,7 @@
+ #cmakedefine HAVE_JPEG
+
+ /* libpng/png.h needs to be included */
+-#cmakedefine HAVE_LIBPNG_PNG_H
++#cmakedefine HAVE_LIBPNG16_PNG_H
+
+ /* GDCM DICOM codec */
+ #cmakedefine HAVE_GDCM
+diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp
+index 388a3fc..4dde181 100644
+--- a/modules/imgcodecs/src/grfmt_png.cpp
++++ b/modules/imgcodecs/src/grfmt_png.cpp
+@@ -58,8 +58,8 @@
+ # define _FILE_OFFSET_BITS 0
+ #endif
+
+-#ifdef HAVE_LIBPNG_PNG_H
+-#include <libpng/png.h>
++#ifdef HAVE_LIBPNG16_PNG_H
++#include <libpng16/png.h>
+ #else
+ #include <png.h>
+ #endif
diff --git a/media-libs/opencv/files/opencv-4.8.1-opencv_test.patch b/media-libs/opencv/files/opencv-4.8.1-opencv_test.patch
new file mode 100644
index 000000000000..2bdc2d830570
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-opencv_test.patch
@@ -0,0 +1,18 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+We don't package quirc, so the misplaced #ifdef breaks compilation.
+
+diff --git a/modules/objdetect/test/test_qrcode.cpp b/modules/objdetect/test/test_qrcode.cpp
+index 5e6ec6f..6dc14cc 100644
+--- a/modules/objdetect/test/test_qrcode.cpp
++++ b/modules/objdetect/test/test_qrcode.cpp
+@@ -374,8 +374,8 @@ TEST_P(Objdetect_QRCode_Multi, regression)
+ qrcode = QRCodeDetectorAruco();
+ }
+ std::vector<Point> corners;
+-#ifdef HAVE_QUIRC
+ std::vector<cv::String> decoded_info;
++#ifdef HAVE_QUIRC
+ std::vector<Mat> straight_barcode;
+ EXPECT_TRUE(qrcode.detectAndDecodeMulti(src, decoded_info, corners, straight_barcode));
+ ASSERT_FALSE(corners.empty());
diff --git a/media-libs/opencv/files/opencv-4.8.1-python3_12-support.patch b/media-libs/opencv/files/opencv-4.8.1-python3_12-support.patch
new file mode 100644
index 000000000000..7eae8a180ce6
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-python3_12-support.patch
@@ -0,0 +1,25 @@
+https://github.com/opencv/opencv/pull/23991
+
+From 00ca8f455e6a5588d905e3a0b268f18ee3fda5dd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=A9rgio=20M=2E=20Basto?= <sergio@serjux.com>
+Date: Sun, 1 Oct 2023 16:12:25 +0100
+Subject: [PATCH] `numpy.distutils` is removed in numpy 1.26 on Python 3.12.
+
+so we don't use numpy.distutils to get includes dirs of python-numpy
+---
+ cmake/OpenCVDetectPython.cmake | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
+index 88a434185622..d4098ce8e60d 100644
+--- a/cmake/OpenCVDetectPython.cmake
++++ b/cmake/OpenCVDetectPython.cmake
+@@ -216,7 +216,7 @@ if(NOT ${found})
+ message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
+ else()
+ # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
+- execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))"
++ execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.get_include())"
+ RESULT_VARIABLE _numpy_process
+ OUTPUT_VARIABLE _numpy_include_dirs
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
diff --git a/media-libs/opencv/files/opencv-4.8.1-use-system-flatbuffers.patch b/media-libs/opencv/files/opencv-4.8.1-use-system-flatbuffers.patch
new file mode 100644
index 000000000000..11c42aea0e6d
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-use-system-flatbuffers.patch
@@ -0,0 +1,36 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Find the system flatbuffers and allow for newer revisions.
+
+diff --git a/cmake/OpenCVDetectFlatbuffers.cmake b/cmake/OpenCVDetectFlatbuffers.cmake
+index 537b738..dbfa532 100644
+--- a/cmake/OpenCVDetectFlatbuffers.cmake
++++ b/cmake/OpenCVDetectFlatbuffers.cmake
+@@ -1,12 +1,6 @@
+ if(WITH_FLATBUFFERS)
+- set(HAVE_FLATBUFFERS 1)
+- set(flatbuffers_VERSION "23.5.9")
+- ocv_install_3rdparty_licenses(flatbuffers "${OpenCV_SOURCE_DIR}/3rdparty/flatbuffers/LICENSE.txt")
+- ocv_add_external_target(flatbuffers "${OpenCV_SOURCE_DIR}/3rdparty/flatbuffers/include" "" "HAVE_FLATBUFFERS=1")
+- set(CUSTOM_STATUS_flatbuffers " Flatbuffers:" "builtin/3rdparty (${flatbuffers_VERSION})")
+-endif()
+-
+-if(WITH_FLATBUFFERS OR HAVE_FLATBUFFERS)
++ find_package(flatbuffers REQUIRED)
++ set(HAVE_FLATBUFFERS "${flatbuffers_FOUND}")
+ list(APPEND CUSTOM_STATUS flatbuffers)
+
+ if(HAVE_FLATBUFFERS)
+diff --git a/modules/dnn/misc/tflite/schema_generated.h b/modules/dnn/misc/tflite/schema_generated.h
+index 44162ee..1c3c35a 100644
+--- a/modules/dnn/misc/tflite/schema_generated.h
++++ b/modules/dnn/misc/tflite/schema_generated.h
+@@ -10,7 +10,7 @@
+ // generated, otherwise it may not be compatible.
+ static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
+ FLATBUFFERS_VERSION_MINOR == 5 &&
+- FLATBUFFERS_VERSION_REVISION == 9,
++ FLATBUFFERS_VERSION_REVISION >= 9,
+ "Non-compatible flatbuffers version included");
+
+ namespace opencv_tflite {
diff --git a/media-libs/opencv/files/opencv-4.8.1-use-system-opencl.patch b/media-libs/opencv/files/opencv-4.8.1-use-system-opencl.patch
new file mode 100644
index 000000000000..f4efd06897df
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.8.1-use-system-opencl.patch
@@ -0,0 +1,25 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Find the system opencl and inject the include dir.
+
+diff --git a/cmake/OpenCVDetectOpenCL.cmake b/cmake/OpenCVDetectOpenCL.cmake
+index 100fb0e..ab30bf9 100644
+--- a/cmake/OpenCVDetectOpenCL.cmake
++++ b/cmake/OpenCVDetectOpenCL.cmake
+@@ -1,3 +1,8 @@
++find_package(OpenCLHeaders REQUIRED)
++if(NOT TARGET OpenCL::Headers)
++ message(FATAL_ERROR "OpenCL::Headers not found")
++endif()
++
+ set(OPENCL_FOUND ON CACHE BOOL "OpenCL library is found")
+ if(APPLE)
+ set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
+@@ -5,6 +10,7 @@ if(APPLE)
+ else()
+ set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library")
+ set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory")
++ get_target_property(OPENCL_INCLUDE_DIR OpenCL::Headers INTERFACE_INCLUDE_DIRECTORIES)
+ endif()
+ mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
+
diff --git a/media-libs/opencv/files/opencv_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch b/media-libs/opencv/files/opencv_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch
new file mode 100644
index 000000000000..fe66258b15f2
--- /dev/null
+++ b/media-libs/opencv/files/opencv_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch
@@ -0,0 +1,20 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Use tar.gz instead of zip to make CI happy.
+
+diff --git a/modules/cudaoptflow/CMakeLists.txt b/modules/cudaoptflow/CMakeLists.txt
+index b295abc..1e916e5 100644
+--- a/modules/cudaoptflow/CMakeLists.txt
++++ b/modules/cudaoptflow/CMakeLists.txt
+@@ -10,9 +10,9 @@ ocv_define_module(cudaoptflow opencv_video opencv_optflow opencv_cudaarithm open
+
+ if(NOT CUDA_VERSION VERSION_LESS "10.0")
+ set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT "edb50da3cf849840d680249aa6dbef248ebce2ca")
+- set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5 "a73cd48b18dcc0cc8933b30796074191")
++ set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5 "5626b1d1c335fbcbf893fcb27e1230be")
+ set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH "${OpenCV_BINARY_DIR}/3rdparty/NVIDIAOpticalFlowSDK_2_0_Headers")
+- ocv_download(FILENAME "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT}.zip"
++ ocv_download(FILENAME "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT}.tar.gz"
+ HASH ${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5}
+ URL "https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/"
+ DESTINATION_DIR "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH}"
diff --git a/media-libs/opencv/files/opencv_contrib-4.8.1-rgbd.patch b/media-libs/opencv/files/opencv_contrib-4.8.1-rgbd.patch
new file mode 100644
index 000000000000..0e1f12d6df46
--- /dev/null
+++ b/media-libs/opencv/files/opencv_contrib-4.8.1-rgbd.patch
@@ -0,0 +1,15 @@
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+
+Fixes compilation when using GLVND.
+
+diff --git a/modules/rgbd/CMakeLists.txt b/modules/rgbd/CMakeLists.txt
+index 79e1562..eaebc3a 100644
+--- a/modules/rgbd/CMakeLists.txt
++++ b/modules/rgbd/CMakeLists.txt
+@@ -7,5 +7,5 @@ if(NOT HAVE_EIGEN)
+ endif()
+
+ if(HAVE_OPENGL)
+- ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_LIBRARIES}")
++ ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_LIBRARIES}" GL)
+ endif()
diff --git a/media-libs/opencv/metadata.xml b/media-libs/opencv/metadata.xml
index 67f63c03fd9d..80f1912bd4fd 100644
--- a/media-libs/opencv/metadata.xml
+++ b/media-libs/opencv/metadata.xml
@@ -16,32 +16,38 @@
</longdescription>
<use>
<flag name="contrib">Install user contributed scripts from opencv_contrib (Experimental!)</flag>
+ <flag name="contribcvv">Enable CVV in contrib (requires Qt5)</flag>
+ <flag name="contribdnn">Enable DNN module contrib (requires tinydnn)</flag>
+ <flag name="contribfreetype">Enable Drawing UTF-8 strings with <pkg>media-libs/freetype</pkg>&amp;<pkg>media-libs/harfbuzz</pkg></flag>
+ <flag name="contribhdf">Enable HDF module (requires <pkg>sci-libs/hdf5</pkg>)</flag>
+ <flag name="contribovis">Enable OGRE vision module support (<pkg>dev-games/ogre</pkg>)</flag>
+ <flag name="contribsfm">Enable SFM module (requires USE="eigen gflags glog")</flag>
+ <flag name="contribxfeatures2d" restrict="&gt;media-libs/opencv-4.8.1-r1">Enable xfeatures2d in contrib</flag>
+ <flag name="contribxfeatures2d" restrict="&lt;=media-libs/opencv-4.8.1">Enables xfeatures2d and autodownload of samples in contrib</flag>
<flag name="cuda">Enable NVIDIA Cuda computations support (Experimental!)</flag>
- <flag restrict="&gt;=media-libs/opencv-4.1.2" name="download">Enable download during cmake configure</flag>
+ <flag name="cudnn">Enable support for nVidia cuDNN library</flag>
+ <flag name="dnnsamples">Enable dnn caffeemodel samples</flag>
+ <flag name="download">Enable download during cmake configure</flag>
<flag name="eigen">Enable usage of <pkg>dev-cpp/eigen</pkg> for computations</flag>
<flag name="features2d">Enable features2d module</flag>
<flag name="gdal">Enable support for <pkg>sci-libs/gdal</pkg> library</flag>
+ <flag name="gflags">Use Google's C++ argument parsing library (<pkg>dev-cpp/gflags</pkg>)</flag>
+ <flag name="glog">Use Google's C++ logging library (<pkg>dev-cpp/glog</pkg>)</flag>
<flag name="gtk3">Enable <pkg>x11-libs/gtk+</pkg>:3 support</flag>
- <flag restrict="&gt;=media-libs/opencv-4.4.0" name="lto">Build using Link Time Optimizations (LTO)</flag>
- <flag restrict="&gt;=media-libs/opencv-4.1.2" name="opencvapps">Enable compilation with opencvapps</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="gflags">Use Google's C++ argument parsing library</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="glog">Use Google's C++ loggin library</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="contribxfeatures2d">Enables xfeatures2d and autodownload of samples in contrib</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="contribcvv">CVV module requires Qt5</flag>
- <flag restrict="&gt;=media-libs/opencv-3.3.0" name="contribdnn">DNN module contrib requires tiny dnn</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="contribhdf">HDF module requires <pkg>sci-libs/hdf5</pkg></flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="contribsfm">SFM module requires eigen, gflags, and glog</flag>
- <flag restrict="&gt;=media-libs/opencv-4.4.0" name="contribfreetype">Enable Drawing UTF-8 strings with freetype/harfbuzz</flag>
- <flag restrict="&gt;=media-libs/opencv-4.4.0" name="contribovis">Enable Ogre vision module support</flag>
- <flag restrict="&gt;=media-libs/opencv-3.4.0" name="dnnsamples">Download dnn caffeemodel samples</flag>
- <flag restrict="&gt;=media-libs/opencv-3.1.0" name="tesseract">Use Google's OCR Engine</flag>
+ <flag name="lto">Build using Link Time Optimizations (LTO)</flag>
+ <flag name="non-free">Enable non-free components</flag>
+ <flag name="opencvapps">Enable compilation with opencvapps</flag>
+ <flag name="tbb">Enable multithreading with the Intel Threads Building Block (<pkg>dev-cpp/tbb</pkg>)</flag>
+ <flag name="tesseract">Use Google's OCR Engine</flag>
<flag name="testprograms">Build and install programs for testing OpenCV (performance)</flag>
+ <flag name="video_cards_intel">Enable Video Acceleration API for hardware decoding for Intel cards</flag>
<flag name="vtk">Build new 3D visualization module viz based on <pkg>sci-libs/vtk</pkg></flag>
</use>
<upstream>
<remote-id type="cpe">cpe:/a:opencv:opencv</remote-id>
<remote-id type="github">opencv/opencv</remote-id>
<remote-id type="github">opencv/opencv_contrib</remote-id>
+ <remote-id type="github">opencv/opencv_3rdparty</remote-id>
<remote-id type="sourceforge">opencvlibrary</remote-id>
</upstream>
</pkgmetadata>
diff --git a/media-libs/opencv/opencv-4.8.1-r1.ebuild b/media-libs/opencv/opencv-4.8.1-r1.ebuild
new file mode 100644
index 000000000000..643ae918665e
--- /dev/null
+++ b/media-libs/opencv/opencv-4.8.1-r1.ebuild
@@ -0,0 +1,646 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+inherit cuda java-pkg-opt-2 java-ant-2 cmake-multilib flag-o-matic python-r1 toolchain-funcs
+
+DESCRIPTION="A collection of algorithms and sample code for various computer vision problems"
+HOMEPAGE="https://opencv.org"
+
+ADE_PV="0.1.2a" # branch master
+QRCODE_COMMIT="a8b69ccc738421293254aec5ddb38bd523503252" # branch wechat_qrcode_20210119
+DNN_SAMPLES_FACE_DETECTOR_COMMIT="b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f" # branch dnn_samples_face_detector_20170830
+XFEATURES2D_BOOSTDESC_COMMIT="34e4206aef44d50e6bbcd0ab06354b52e7466d26" # branch contrib_xfeatures2d_boostdesc_20161012
+XFEATURES2D_VGG_COMMIT="fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" # branch contrib_xfeatures2d_vgg_20160317
+FACE_ALIGNMENT_COMMIT="8afa57abc8229d611c4937165d20e2a2d9fc5a12" # branch contrib_face_alignment_20170818
+NVIDIA_OPTICAL_FLOW_COMMIT="edb50da3cf849840d680249aa6dbef248ebce2ca" # branch nvof_2_0_bsd
+
+SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
+ https://github.com/opencv/ade/archive/v${ADE_PV}.tar.gz -> ade-${ADE_PV}.tar.gz
+ contrib? (
+ https://github.com/${PN}/${PN}_contrib/archive/${PV}.tar.gz -> ${P}_contrib.tar.gz
+ dnnsamples? (
+ https://github.com/${PN}/${PN}_3rdparty/archive/${QRCODE_COMMIT}.tar.gz -> ${PN}_3rdparty-${QRCODE_COMMIT}.tar.gz
+ https://github.com/${PN}/${PN}_3rdparty/archive/${DNN_SAMPLES_FACE_DETECTOR_COMMIT}.tar.gz
+ -> ${PN}_3rdparty-${DNN_SAMPLES_FACE_DETECTOR_COMMIT}.tar.gz
+ )
+ contribxfeatures2d? (
+ https://github.com/${PN}/${PN}_3rdparty/archive/${XFEATURES2D_BOOSTDESC_COMMIT}.tar.gz
+ -> ${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}.tar.gz
+ https://github.com/${PN}/${PN}_3rdparty/archive/${XFEATURES2D_VGG_COMMIT}.tar.gz
+ -> ${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}.tar.gz
+ )
+ contribdnn? (
+ https://github.com/${PN}/${PN}_3rdparty/archive/${FACE_ALIGNMENT_COMMIT}.tar.gz
+ -> ${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}.tar.gz
+ )
+ cuda? (
+ https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz
+ -> NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz
+ )
+ )
+"
+
+LICENSE="Apache-2.0"
+SLOT="0/${PV}" # subslot = libopencv* soname version
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
+IUSE="contrib contribcvv contribdnn contribfreetype contribhdf contribovis contribsfm contribxfeatures2d cuda cudnn debug dnnsamples +eigen examples +features2d ffmpeg gdal gflags glog gphoto2 gstreamer gtk3 ieee1394 jpeg jpeg2k lapack non-free opencl openexr opengl openmp opencvapps png +python qt5 qt6 tesseract testprograms tbb tiff vaapi v4l vtk webp xine video_cards_intel"
+
+# The following lines are shamelessly stolen from ffmpeg-9999.ebuild with modifications
+ARM_CPU_FEATURES=(
+ cpu_flags_arm_neon:NEON
+ cpu_flags_arm_vfpv3:VFPV3
+)
+PPC_CPU_FEATURES=(
+ cpu_flags_ppc_vsx:VSX
+ cpu_flags_ppc_vsx3:VSX3
+)
+X86_CPU_FEATURES_RAW=(
+ sse:SSE
+ sse2:SSE2
+ sse3:SSE3
+ ssse3:SSSE3
+ sse4_1:SSE4_1
+ popcnt:POPCNT
+ sse4_2:SSE4_2
+ f16c:FP16
+ fma3:FMA3
+ avx:AVX
+ avx2:AVX2
+ avx512f:AVX_512F
+)
+X86_CPU_FEATURES=( ${X86_CPU_FEATURES_RAW[@]/#/cpu_flags_x86_} )
+CPU_FEATURES_MAP=(
+ ${ARM_CPU_FEATURES[@]}
+ ${PPC_CPU_FEATURES[@]}
+ ${X86_CPU_FEATURES[@]}
+)
+IUSE="${IUSE} ${CPU_FEATURES_MAP[@]%:*}"
+
+# OpenGL needs gtk or Qt installed to activate, otherwise build system
+# will silently disable it without the user knowing, which defeats the
+# purpose of the opengl use flag.
+# cuda needs contrib, bug #701712
+REQUIRED_USE="
+ cpu_flags_x86_avx2? ( cpu_flags_x86_f16c )
+ cpu_flags_x86_f16c? ( cpu_flags_x86_avx )
+ cuda? (
+ contrib
+ tesseract? ( opencl )
+ )
+ cudnn? ( cuda )
+ dnnsamples? ( examples )
+ gflags? ( contrib )
+ glog? ( contrib )
+ contribcvv? ( contrib || ( qt5 qt6 ) )
+ contribdnn? ( contrib )
+ contribfreetype? ( contrib )
+ contribhdf? ( contrib )
+ contribovis? ( contrib )
+ contribsfm? ( contrib eigen gflags glog )
+ contribxfeatures2d? ( contrib )
+ java? ( python )
+ opengl? ( || ( qt5 qt6 ) )
+ python? ( ${PYTHON_REQUIRED_USE} )
+ tesseract? ( contrib )
+ ?? ( gtk3 || ( qt5 qt6 ) )
+ ?? ( cuda gdal )
+ ?? ( cuda openexr )
+ ?? ( cuda tbb )
+"
+
+# The following logic is intrinsic in the build system, but we do not enforce
+# it on the useflags since this just blocks emerging pointlessly:
+# openmp? ( !tbb )
+
+RDEPEND="
+ app-arch/bzip2[${MULTILIB_USEDEP}]
+ <dev-libs/protobuf-23:=[${MULTILIB_USEDEP}]
+ sys-libs/zlib[${MULTILIB_USEDEP}]
+ cuda? ( dev-util/nvidia-cuda-toolkit:0= )
+ cudnn? ( dev-libs/cudnn:= )
+ contribdnn? ( dev-libs/flatbuffers:= )
+ contribhdf? ( sci-libs/hdf5:= )
+ contribfreetype? (
+ media-libs/freetype:2[${MULTILIB_USEDEP}]
+ media-libs/harfbuzz:=[${MULTILIB_USEDEP}]
+ )
+ contribovis? ( >=dev-games/ogre-1.12:= )
+ ffmpeg? ( media-video/ffmpeg:0=[${MULTILIB_USEDEP}] )
+ gdal? ( sci-libs/gdal:= )
+ gflags? ( dev-cpp/gflags:=[${MULTILIB_USEDEP}] )
+ glog? ( dev-cpp/glog:=[${MULTILIB_USEDEP}] )
+ gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
+ gstreamer? (
+ media-libs/gstreamer:1.0[${MULTILIB_USEDEP}]
+ media-libs/gst-plugins-base:1.0[${MULTILIB_USEDEP}]
+ )
+ gtk3? (
+ dev-libs/glib:2[${MULTILIB_USEDEP}]
+ x11-libs/gtk+:3[${MULTILIB_USEDEP}]
+ )
+ ieee1394? (
+ media-libs/libdc1394:=[${MULTILIB_USEDEP}]
+ sys-libs/libraw1394[${MULTILIB_USEDEP}]
+ )
+ java? ( >=virtual/jre-1.8:* )
+ jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
+ jpeg2k? ( media-libs/openjpeg:2=[${MULTILIB_USEDEP}] )
+ lapack? (
+ virtual/cblas
+ >=virtual/lapack-3.10
+ virtual/lapacke
+ )
+ opencl? (
+ virtual/opencl[${MULTILIB_USEDEP}]
+ dev-util/opencl-headers
+ )
+ openexr? (
+ dev-libs/imath:=
+ media-libs/openexr:=
+ )
+ opengl? (
+ virtual/opengl[${MULTILIB_USEDEP}]
+ virtual/glu[${MULTILIB_USEDEP}]
+ )
+ png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] )
+ python? (
+ ${PYTHON_DEPS}
+ dev-python/numpy[${PYTHON_USEDEP}]
+ )
+ qt5? (
+ dev-qt/qtgui:5
+ dev-qt/qtwidgets:5
+ dev-qt/qttest:5
+ dev-qt/qtconcurrent:5
+ opengl? ( dev-qt/qtopengl:5 )
+ )
+ !qt5? (
+ qt6? (
+ dev-qt/qtbase:6[gui,widgets,concurrent,opengl?]
+ )
+ )
+ tesseract? ( app-text/tesseract[opencl=,${MULTILIB_USEDEP}] )
+ tbb? ( dev-cpp/tbb:=[${MULTILIB_USEDEP}] )
+ tiff? ( media-libs/tiff:=[${MULTILIB_USEDEP}] )
+ v4l? ( >=media-libs/libv4l-0.8.3[${MULTILIB_USEDEP}] )
+ vaapi? ( media-libs/libva[${MULTILIB_USEDEP}] )
+ vtk? ( sci-libs/vtk:=[rendering,cuda=] )
+ webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+ xine? ( media-libs/xine-lib )"
+DEPEND="${RDEPEND}
+ eigen? ( >=dev-cpp/eigen-3.3.8-r1:3 )
+ java? ( >=virtual/jdk-1.8:* )"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-3.4.0-disable-download.patch"
+ "${FILESDIR}/${PN}-3.4.1-cuda-add-relaxed-constexpr.patch"
+ "${FILESDIR}/${PN}-4.1.2-opencl-license.patch"
+ "${FILESDIR}/${PN}-4.4.0-disable-native-cpuflag-detect.patch"
+ "${FILESDIR}/${PN}-4.5.0-link-with-cblas-for-lapack.patch"
+ "${FILESDIR}/${PN}-4.8.0-arm64-fp16.patch"
+ "${FILESDIR}/${PN}-4.8.0-fix-cuda-12.2.0.patch"
+
+ "${FILESDIR}/${PN}-4.8.1-use-system-flatbuffers.patch"
+ "${FILESDIR}/${PN}-4.8.1-eliminate-lto-compiler-warnings.patch"
+ "${FILESDIR}/${PN}-4.8.1-python3_12-support.patch"
+
+ "${FILESDIR}/${PN}-4.8.1-use-system-opencl.patch"
+ "${FILESDIR}/${PN}-4.8.1-opencv_test.patch"
+ "${FILESDIR}/${PN}-4.8.1-drop-python2-detection.patch"
+ "${FILESDIR}/${PN}-4.8.1-libpng16.patch"
+ "${FILESDIR}/${PN}-4.8.1-ade-0.1.2a.tar.gz.patch"
+
+ # TODO applied in src_prepare
+ # "${FILESDIR}/${PN}_contrib-${PV}-rgbd.patch"
+ # "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
+)
+
+pkg_pretend() {
+ if use cuda && [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then
+ einfo "The target CUDA architecture can be set via one of:"
+ einfo " - CUDA_GENERATION set to one of Maxwell, Pascal, Volta, Turing, Ampere, Lovelace, Hopper, Auto"
+ einfo " - CUDA_ARCH_BIN, (and optionally CUDA_ARCH_PTX) in the form of x.y tuples."
+ einfo " You can specify multiple tuple separated by \";\"."
+ einfo ""
+ einfo "The CUDA architecture tuple for your device can be found at https://developer.nvidia.com/cuda-gpus."
+ fi
+
+ if [[ ${MERGE_TYPE} == "buildonly" ]] && [[ -n "${CUDA_GENERATION}" || -n "${CUDA_ARCH_BIN}" ]]; then
+ local info_message="When building a binary package it's recommended to unset CUDA_GENERATION and CUDA_ARCH_BIN"
+ einfo "$info_message so all available architectures are build."
+ fi
+
+ [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+}
+
+pkg_setup() {
+ [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+ use java && java-pkg-opt-2_pkg_setup
+}
+
+src_unpack() {
+ unpack $(echo "${A}" | tr ' ' '\n' | grep -vP "(ade-0.1.2|NVIDIAOpticalFlowSDK)")
+}
+
+src_prepare() {
+ if use cuda; then
+ export CUDA_VERBOSE="$(usex debug "true" "false")"
+ cuda_src_prepare
+ fi
+
+ cmake_src_prepare
+
+ # remove bundled stuff
+ rm -r 3rdparty || die "Removing 3rd party components failed"
+ sed -e '/add_subdirectory(.*3rdparty.*)/ d' \
+ -i CMakeLists.txt cmake/*cmake || die
+
+ if use contrib; then
+ cd "${WORKDIR}/${PN}_contrib-${PV}" || die
+ eapply "${FILESDIR}/${PN}_contrib-${PV}-rgbd.patch"
+ eapply "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
+ cd "${S}" || die
+
+ ! use contribcvv && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/cvv" || die; }
+ # ! use contribdnn && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/dnn" || die; }
+ ! use contribfreetype && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/freetype" || die; }
+ ! use contribhdf && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/hdf" || die; }
+ ! use contribovis && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/ovis" || die; }
+ ! use contribsfm && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/sfm" || die; }
+ ! use contribxfeatures2d && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/xfeatures2d" || die; }
+ fi
+
+ mkdir -p "${S}/.cache/ade" || die
+ cp \
+ "${DISTDIR}/ade-${ADE_PV}.tar.gz" \
+ "${S}/.cache/ade/$(md5sum "${DISTDIR}/ade-${ADE_PV}.tar.gz" | cut -f 1 -d " ")-v${ADE_PV}.tar.gz" || die
+
+ if use dnnsamples; then
+ mkdir -p "${S}/.cache/wechat_qrcode" || die
+ for file in "detect.caffemodel" "detect.prototxt" "sr.prototxt" "sr.caffemodel"; do
+ mv \
+ "${WORKDIR}/${PN}_3rdparty-${QRCODE_COMMIT}/${file}" \
+ "${S}/.cache/wechat_qrcode/$( \
+ md5sum "${WORKDIR}/${PN}_3rdparty-${QRCODE_COMMIT}/${file}" | cut -f 1 -d " " \
+ )-${file}" || die
+ done
+
+ mv \
+ "${WORKDIR}/${PN}_3rdparty-${DNN_SAMPLES_FACE_DETECTOR_COMMIT}/res10_300x300_ssd_iter_140000.caffemodel" \
+ "${S}/samples/dnn/" || die
+ fi
+
+ if use contribxfeatures2d; then
+ cp \
+ "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/"*.i \
+ "${WORKDIR}/${PN}_contrib-${PV}"/modules/xfeatures2d/src/ || die
+ mkdir -p "${S}/.cache/xfeatures2d/boostdesc" || die
+ for file in "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/"*.i; do
+ mv \
+ "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/$(basename "${file}")" \
+ "${S}/.cache/xfeatures2d/boostdesc/$( \
+ md5sum "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/$(basename "${file}")" | cut -f 1 -d " " \
+ )-$(basename "${file}")" || die
+ done
+
+ cp \
+ "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/"*.i \
+ "${WORKDIR}/${PN}_contrib-${PV}"/modules/xfeatures2d/src/ || die
+ mkdir -p "${S}/.cache/xfeatures2d/vgg" || die
+ for file in "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/"*.i; do
+ mv \
+ "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/$(basename "${file}")" \
+ "${S}/.cache/xfeatures2d/vgg/$( \
+ md5sum "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/$(basename "${file}")" | cut -f 1 -d " " \
+ )-$(basename "${file}")" || die
+ done
+ fi
+
+ if use contribdnn; then
+ mkdir -p "${S}/.cache/data" || die
+ for file in "face_landmark_model.dat"; do
+ mv \
+ "${WORKDIR}/${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}/${file}" \
+ "${S}/.cache/data/$( \
+ md5sum "${WORKDIR}/${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}/${file}" | cut -f 1 -d " " \
+ )-${file}" || die
+ done
+ fi
+
+ if use cuda; then
+ mkdir -p "${S}/.cache/nvidia_optical_flow"
+ cp \
+ "${DISTDIR}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" \
+ "${S}/.cache/nvidia_optical_flow/$( \
+ md5sum "${DISTDIR}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" | cut -f 1 -d " " \
+ )-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" || die
+ fi
+
+ if use java; then
+ java-pkg-opt-2_src_prepare
+
+ # this really belongs in src_prepare() too
+ JAVA_ANT_ENCODING="iso-8859-1"
+ # set encoding so even this cmake build will pick it up.
+ export ANT_OPTS+=" -Dfile.encoding=iso-8859-1"
+ fi
+}
+
+multilib_src_configure() {
+ # bug #919101 and https://github.com/opencv/opencv/issues/19020
+ filter-lto
+
+ # please dont sort here, order is the same as in CMakeLists.txt
+ local mycmakeargs=(
+ -DMIN_VER_CMAKE=3.26
+
+ -DCMAKE_POLICY_DEFAULT_CMP0146="OLD" # FindCUDA
+ -DCMAKE_POLICY_DEFAULT_CMP0148="OLD" # FindPythonInterp
+
+ # for protobuf
+ -DCMAKE_CXX_STANDARD=14
+
+ # Optional 3rd party components
+ # ===================================================
+ -DENABLE_DOWNLOAD=yes
+ -DOPENCV_ENABLE_NONFREE=$(usex non-free)
+ -DWITH_QUIRC=OFF # Do not have dependencies
+ -DWITH_FLATBUFFERS=$(usex contribdnn)
+ -DWITH_1394=$(usex ieee1394)
+ # -DWITH_AVFOUNDATION=OFF # IOS
+ -DWITH_VTK=$(multilib_native_usex vtk)
+ -DWITH_EIGEN=$(usex eigen)
+ -DWITH_VFW=OFF # Video windows support
+ -DWITH_FFMPEG=$(usex ffmpeg)
+ -DWITH_GSTREAMER=$(usex gstreamer)
+ -DWITH_GSTREAMER_0_10=OFF # Don't want this
+ -DWITH_GTK=$(usex gtk3)
+ -DWITH_GTK_2_X=OFF # only want gtk3 nowadays
+ -DWITH_IPP=OFF
+ # Jasper was removed from tree because of security problems.
+ # Upstream were/are making progress. We use openjpeg instead.
+ # bug 734284
+ -DWITH_JASPER=OFF
+ -DWITH_JPEG=$(usex jpeg)
+ -DWITH_OPENJPEG=$(usex jpeg2k)
+ -DWITH_WEBP=$(usex webp)
+ -DWITH_OPENEXR=$(multilib_native_usex openexr)
+ -DWITH_OPENGL=$(usex opengl)
+ -DOpenGL_GL_PREFERENCE="GLVND"
+ -DWITH_OPENVX=OFF
+ -DWITH_OPENNI=OFF # Not packaged
+ -DWITH_OPENNI2=OFF # Not packaged
+ -DWITH_PNG=$(usex png)
+ -DWITH_GDCM=OFF
+ -DWITH_PVAPI=OFF
+ -DWITH_GIGEAPI=OFF
+ -DWITH_ARAVIS=OFF
+ -DWITH_WIN32UI=OFF # Windows only
+ # -DWITH_QUICKTIME=OFF
+ # -DWITH_QTKIT=OFF
+ -DWITH_TBB=$(usex tbb)
+ -DWITH_OPENMP=$(usex !tbb $(usex openmp))
+ -DWITH_CSTRIPES=OFF
+ -DWITH_PTHREADS_PF=ON
+ -DWITH_TIFF=$(usex tiff)
+ -DWITH_UNICAP=OFF # Not packaged
+ -DWITH_V4L=$(usex v4l)
+ -DWITH_LIBV4L=$(usex v4l)
+ # -DWITH_DSHOW=ON # direct show supp
+ -DWITH_MSMF=OFF
+ -DWITH_XIMEA=OFF # Windows only
+ -DWITH_XINE=$(multilib_native_usex xine)
+ -DWITH_CLP=OFF
+ -DWITH_OPENCL=$(usex opencl)
+ -DWITH_OPENCL_SVM=OFF
+ -DWITH_OPENCLAMDFFT=$(usex opencl)
+ -DWITH_OPENCLAMDBLAS=$(usex opencl)
+ -DWITH_DIRECTX=OFF
+ -DWITH_INTELPERC=OFF
+ -DWITH_IPP_A=OFF
+ -DWITH_MATLAB=OFF
+ -DWITH_VA=$(usex vaapi)
+ -DWITH_VA_INTEL=$(usex vaapi $(usex video_cards_intel))
+ -DWITH_GDAL=$(multilib_native_usex gdal)
+ -DWITH_GPHOTO2=$(usex gphoto2)
+ -DWITH_LAPACK=$(multilib_native_usex lapack)
+ -DWITH_ITT=OFF # 3dparty libs itt_notify
+ # ===================================================
+ # CUDA build components: nvidia-cuda-toolkit
+ # ===================================================
+ -DWITH_CUDA=$(multilib_native_usex cuda)
+ -DWITH_CUBLAS=$(multilib_native_usex cuda)
+ -DWITH_CUFFT=$(multilib_native_usex cuda)
+ -DWITH_CUDNN=$(multilib_native_usex cudnn)
+ -DWITH_NVCUVID="no"
+ -DCUDA_NPP_LIBRARY_ROOT_DIR=$(usex cuda "${EPREFIX}/opt/cuda" "")
+ # ===================================================
+ # OpenCV build components
+ # ===================================================
+ -DBUILD_SHARED_LIBS=ON
+ -DBUILD_JAVA=$(multilib_native_usex java) # Ant needed, no compile flag
+ -DBUILD_ANDROID_EXAMPLES=OFF
+ -DBUILD_opencv_apps=$(usex opencvapps ON OFF)
+ -DBUILD_DOCS=OFF # Doesn't install anyways.
+ -DBUILD_EXAMPLES=$(multilib_native_usex examples)
+ -DBUILD_PERF_TESTS=OFF
+ -DBUILD_TESTS=$(multilib_native_usex testprograms)
+ -DBUILD_WITH_DEBUG_INFO=$(usex debug)
+ -DOPENCV_ENABLE_MEMORY_SANITIZER=$(usex debug)
+ # -DBUILD_WITH_STATIC_CRT=OFF
+ -DBUILD_WITH_DYNAMIC_IPP=OFF
+ -DBUILD_FAT_JAVA_LIB=OFF
+ # -DBUILD_ANDROID_SERVICE=OFF
+ -DBUILD_CUDA_STUBS=$(multilib_native_usex cuda)
+ -DOPENCV_EXTRA_MODULES_PATH=$(usex contrib "${WORKDIR}/${PN}_contrib-${PV}/modules" "")
+ # ===================================================
+ # OpenCV installation options
+ # ===================================================
+ -DINSTALL_CREATE_DISTRIB=OFF
+ -DINSTALL_C_EXAMPLES=$(multilib_native_usex examples)
+ -DINSTALL_TESTS=$(multilib_native_usex testprograms)
+ -DINSTALL_PYTHON_EXAMPLES=$(multilib_native_usex examples)
+ # -DINSTALL_ANDROID_EXAMPLES=OFF
+ -DINSTALL_TO_MANGLED_PATHS=OFF
+ -DOPENCV_GENERATE_PKGCONFIG=ON
+ # opencv uses both ${CMAKE_INSTALL_LIBDIR} and ${LIB_SUFFIX}
+ # to set its destination libdir
+ -DLIB_SUFFIX=
+ # ===================================================
+ # OpenCV build options
+ # ===================================================
+ -DENABLE_CCACHE=OFF
+ # bug 733796, but PCH is a risky game in CMake anyway
+ -DENABLE_PRECOMPILED_HEADERS=OFF
+ -DENABLE_SOLUTION_FOLDERS=OFF
+ -DENABLE_PROFILING=OFF
+ -DENABLE_COVERAGE=OFF
+
+ -DHAVE_opencv_java=$(multilib_native_usex java YES NO)
+ -DENABLE_NOISY_WARNINGS=OFF
+ -DOPENCV_WARNINGS_ARE_ERRORS=OFF
+ -DENABLE_IMPL_COLLECTION=OFF
+ -DENABLE_INSTRUMENTATION=OFF
+ -DGENERATE_ABI_DESCRIPTOR=OFF
+ -DDOWNLOAD_EXTERNAL_TEST_DATA=OFF
+ # ===================================================
+ # things we want to be hard off or not yet figured out
+ # ===================================================
+ -DBUILD_PACKAGE=OFF
+ # ===================================================
+ # Not building protobuf but update files bug #631418
+ # ===================================================
+ -DWITH_PROTOBUF=ON
+ -DBUILD_PROTOBUF=OFF
+ -DPROTOBUF_UPDATE_FILES=ON
+ -DProtobuf_MODULE_COMPATIBLE=ON
+ # ===================================================
+ # things we want to be hard enabled not worth useflag
+ # ===================================================
+ -DCMAKE_SKIP_RPATH=ON
+ -DOPENCV_DOC_INSTALL_PATH=
+ -DBUILD_opencv_features2d=$(usex features2d ON OFF)
+ )
+
+ if use qt5; then
+ mycmakeargs+=(
+ -DWITH_QT=$(multilib_native_usex qt5 ON OFF)
+ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON
+ )
+ elif use qt6; then
+ mycmakeargs+=(
+ -DWITH_QT=$(multilib_native_usex qt6 ON OFF)
+ -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=ON
+ )
+ else
+ mycmakeargs+=(
+ -DWITH_QT=OFF
+ -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=ON
+ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON
+ )
+ fi
+
+ # ==================================================
+ # cpu flags, should solve 633900
+ #===================================================
+ local CPU_BASELINE=""
+ for i in "${CPU_FEATURES_MAP[@]}" ; do
+ if [[ ${ABI} != x86 || ${i%:*} != "cpu_flags_x86_avx2" ]]; then # workaround for Bug 747163
+ use ${i%:*} && CPU_BASELINE="${CPU_BASELINE}${i#*:};"
+ fi
+ done
+
+ mycmakeargs+=(
+ -DOPENCV_CPU_OPT_IMPLIES_IGNORE=ON
+ -DCPU_BASELINE="${CPU_BASELINE}"
+ -DCPU_DISPATCH=
+ )
+
+ # ===================================================
+ # OpenCV Contrib Modules
+ # ===================================================
+ if use contrib; then
+ mycmakeargs+=(
+ -DBUILD_opencv_dnn=$(usex contribdnn ON OFF)
+ -DBUILD_opencv_xfeatures2d=$(usex contribxfeatures2d ON OFF)
+ -DBUILD_opencv_cvv=$(usex contribcvv ON OFF)
+ -DBUILD_opencv_hdf=$(multilib_native_usex contribhdf ON OFF)
+ -DBUILD_opencv_sfm=$(usex contribsfm ON OFF)
+ -DBUILD_opencv_freetype=$(usex contribfreetype ON OFF)
+ -DBUILD_opencv_ovis=$(usex contribovis ON OFF)
+ )
+
+ if multilib_is_native_abi; then
+ mycmakeargs+=(
+ -DCMAKE_DISABLE_FIND_PACKAGE_Tesseract=$(usex !tesseract)
+ )
+ else
+ mycmakeargs+=(
+ -DCMAKE_DISABLE_FIND_PACKAGE_Tesseract=ON
+ )
+ fi
+ fi
+
+ # workaround for bug 413429
+ tc-export CC CXX
+
+ if use cuda; then
+ cuda_add_sandbox -w
+
+ if [[ -n "${CUDA_GENERATION}" ]]; then
+ mycmakeargs+=(
+ -DCUDA_GENERATION="${CUDA_GENERATION}"
+ )
+ fi
+
+ if [[ -n "${CUDA_ARCH_BIN}" ]]; then
+ mycmakeargs+=(
+ -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}"
+ )
+
+ if [[ -n "${CUDA_ARCH_PTX}" ]]; then
+ mycmakeargs+=(
+ -DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}"
+ )
+ fi
+ fi
+
+ local NVCCFLAGS_OpenCV="${NVCCFLAGS// /\;}"
+ mycmakeargs+=(
+ -DOPENCV_CUDA_DETECTION_NVCC_FLAGS="-ccbin=$(cuda_gccdir)"
+ -DCUDA_NVCC_FLAGS="-forward-unknown-opts;${NVCCFLAGS_OpenCV//\"/}"
+ )
+
+ use vtk && mycmakeargs+=(
+ -DCMAKE_CUDA_FLAGS="-forward-unknown-opts ${NVCCFLAGS//\;/ }"
+ )
+ fi
+
+ if multilib_is_native_abi && use python; then
+ python_configure() {
+ # Set all python variables to load the correct Gentoo paths
+ local mycmakeargs=(
+ "${mycmakeargs[@]}"
+ # python_setup alters PATH and sets this as wrapper
+ # to the correct interpreter we are building for
+ -DPYTHON_DEFAULT_EXECUTABLE="${EPYTHON}"
+ -DINSTALL_PYTHON_EXAMPLES="$(usex examples)"
+ )
+ cmake_src_configure
+ use java && java-ant-2_src_configure
+ }
+
+ python_foreach_impl python_configure
+ else
+ mycmakeargs+=(
+ -DPYTHON_EXECUTABLE=OFF
+ -DINSTALL_PYTHON_EXAMPLES=OFF
+ -DBUILD_opencv_python2=OFF
+ -DBUILD_opencv_python3=OFF
+ )
+ cmake_src_configure
+ use java && java-ant-2_src_configure
+ fi
+
+}
+
+multilib_src_compile() {
+ if multilib_is_native_abi && use python; then
+ python_foreach_impl cmake_src_compile
+ else
+ cmake_src_compile
+ fi
+}
+
+multilib_src_install() {
+ if multilib_is_native_abi && use python; then
+ python_foreach_impl cmake_src_install
+ python_foreach_impl python_optimize
+ else
+ cmake_src_install
+ fi
+}
diff --git a/media-libs/opencv/opencv-4.8.1.ebuild b/media-libs/opencv/opencv-4.8.1.ebuild
deleted file mode 100644
index 3f219f22a627..000000000000
--- a/media-libs/opencv/opencv-4.8.1.ebuild
+++ /dev/null
@@ -1,614 +0,0 @@
-# Copyright 1999-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-# No 3.12 yet for bug #912987
-PYTHON_COMPAT=( python3_{10..11} )
-inherit flag-o-matic java-pkg-opt-2 java-ant-2 cmake-multilib python-r1 toolchain-funcs
-
-DESCRIPTION="A collection of algorithms and sample code for various computer vision problems"
-HOMEPAGE="https://opencv.org"
-TINY_DNN_PV="1.0.0a3"
-SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
- dnnsamples? ( https://dev.gentoo.org/~amynka/snap/${PN}-3.4.0-res10_300x300-caffeemodel.tar.gz )
- download? ( https://github.com/rossbridger/opencv-extdep/archive/4.4.0.tar.gz -> ${PN}-4.4.0_extdep.tar.gz )
- contrib? (
- https://github.com/${PN}/${PN}_contrib/archive/${PV}.tar.gz -> ${P}_contrib.tar.gz
- contribdnn? ( https://dev.gentoo.org/~amynka/snap/${PN}-3.4.0-face_landmark_model.tar.gz )
- contribxfeatures2d? ( https://dev.gentoo.org/~amynka/snap/vgg_boostdesc-3.2.0.tar.gz )
- )"
-
-LICENSE="Apache-2.0"
-SLOT="0/${PV}" # subslot = libopencv* soname version
-KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
-IUSE="contrib contribcvv contribdnn contribfreetype contribhdf contribovis contribsfm contribxfeatures2d cuda debug dnnsamples download +eigen examples +features2d ffmpeg gdal gflags glog gphoto2 gstreamer gtk3 ieee1394 jpeg jpeg2k lapack lto opencl openexr opengl openmp opencvapps png +python qt5 qt6 tesseract testprograms threads tiff vaapi v4l vtk webp xine"
-
-# The following lines are shamelessly stolen from ffmpeg-9999.ebuild with modifications
-ARM_CPU_FEATURES=(
- cpu_flags_arm_neon:NEON
- cpu_flags_arm_vfpv3:VFPV3
-)
-PPC_CPU_FEATURES=(
- cpu_flags_ppc_vsx:VSX
- cpu_flags_ppc_vsx3:VSX3
-)
-X86_CPU_FEATURES_RAW=(
- avx:AVX
- avx2:AVX2
- avx512f:AVX_512F
- f16c:FP16
- fma3:FMA3
- popcnt:POPCNT
- sse:SSE
- sse2:SSE2
- sse3:SSE3
- ssse3:SSSE3
- sse4_1:SSE4_1
- sse4_2:SSE4_2
-)
-X86_CPU_FEATURES=( ${X86_CPU_FEATURES_RAW[@]/#/cpu_flags_x86_} )
-CPU_FEATURES_MAP=(
- ${ARM_CPU_FEATURES[@]}
- ${PPC_CPU_FEATURES[@]}
- ${X86_CPU_FEATURES[@]}
-)
-IUSE="${IUSE} ${CPU_FEATURES_MAP[@]%:*}"
-
-# OpenGL needs gtk or Qt installed to activate, otherwise build system
-# will silently disable it Wwithout the user knowing, which defeats the
-# purpose of the opengl use flag.
-# cuda needs contrib, bug #701712
-REQUIRED_USE="
- cpu_flags_x86_avx2? ( cpu_flags_x86_f16c )
- cpu_flags_x86_f16c? ( cpu_flags_x86_avx )
- cuda? ( contrib
- tesseract? ( opencl ) )
- dnnsamples? ( examples )
- gflags? ( contrib )
- glog? ( contrib )
- contribcvv? ( contrib || ( qt5 qt6 ) )
- contribdnn? ( contrib )
- contribfreetype? ( contrib )
- contribhdf? ( contrib )
- contribovis? ( contrib )
- contribsfm? ( contrib eigen gflags glog )
- contribxfeatures2d? ( contrib download )
- examples? ( contribdnn )
- java? ( python )
- opengl? ( || ( qt5 qt6 ) )
- python? ( ${PYTHON_REQUIRED_USE} )
- tesseract? ( contrib )
- ?? ( gtk3 || ( qt5 qt6 ) )"
-
-# The following logic is intrinsic in the build system, but we do not enforce
-# it on the useflags since this just blocks emerging pointlessly:
-# openmp? ( !threads )
-
-RDEPEND="
- app-arch/bzip2[${MULTILIB_USEDEP}]
- dev-libs/protobuf:=[${MULTILIB_USEDEP}]
- sys-libs/zlib[${MULTILIB_USEDEP}]
- cuda? ( dev-util/nvidia-cuda-toolkit:0= )
- contribdnn? ( dev-libs/flatbuffers:= )
- contribhdf? ( sci-libs/hdf5:= )
- contribfreetype? (
- media-libs/freetype:2[${MULTILIB_USEDEP}]
- media-libs/harfbuzz:=[${MULTILIB_USEDEP}]
- )
- contribovis? ( dev-games/ogre:0/1.12 )
- ffmpeg? ( media-video/ffmpeg:0=[${MULTILIB_USEDEP}] )
- gdal? ( sci-libs/gdal:= )
- gflags? ( dev-cpp/gflags:=[${MULTILIB_USEDEP}] )
- glog? ( dev-cpp/glog:=[${MULTILIB_USEDEP}] )
- gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
- gstreamer? (
- media-libs/gstreamer:1.0[${MULTILIB_USEDEP}]
- media-libs/gst-plugins-base:1.0[${MULTILIB_USEDEP}]
- )
- gtk3? (
- dev-libs/glib:2[${MULTILIB_USEDEP}]
- x11-libs/gtk+:3[${MULTILIB_USEDEP}]
- )
- ieee1394? (
- media-libs/libdc1394:=[${MULTILIB_USEDEP}]
- sys-libs/libraw1394[${MULTILIB_USEDEP}]
- )
- java? ( >=virtual/jre-1.8:* )
- jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
- jpeg2k? ( media-libs/openjpeg:2=[${MULTILIB_USEDEP}] )
- lapack? (
- virtual/cblas
- >=virtual/lapack-3.10
- )
- opencl? ( virtual/opencl[${MULTILIB_USEDEP}] )
- openexr? (
- dev-libs/imath:=
- media-libs/openexr:=
- )
- opengl? (
- virtual/opengl[${MULTILIB_USEDEP}]
- virtual/glu[${MULTILIB_USEDEP}]
- )
- png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] )
- python? (
- ${PYTHON_DEPS}
- dev-python/numpy[${PYTHON_USEDEP}]
- )
- qt5? (
- dev-qt/qtgui:5=
- dev-qt/qtwidgets:5=
- dev-qt/qttest:5=
- dev-qt/qtconcurrent:5=
- opengl? ( dev-qt/qtopengl:5= )
- )
- !qt5? (
- qt6? (
- dev-qt/qtbase:6=[gui,widgets,concurrent,opengl?]
- )
- )
- tesseract? ( app-text/tesseract[opencl=,${MULTILIB_USEDEP}] )
- threads? ( dev-cpp/tbb:=[${MULTILIB_USEDEP}] )
- tiff? ( media-libs/tiff:=[${MULTILIB_USEDEP}] )
- v4l? ( >=media-libs/libv4l-0.8.3[${MULTILIB_USEDEP}] )
- vaapi? ( media-libs/libva[${MULTILIB_USEDEP}] )
- vtk? ( sci-libs/vtk[rendering] )
- webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
- xine? ( media-libs/xine-lib )"
-DEPEND="${RDEPEND}
- eigen? ( >=dev-cpp/eigen-3.3.8-r1:3 )
- java? ( >=virtual/jdk-1.8:* )"
-BDEPEND="virtual/pkgconfig"
-
-MULTILIB_WRAPPED_HEADERS=(
- # [opencv4]
- /usr/include/opencv4/opencv2/cvconfig.h
- /usr/include/opencv4/opencv2/opencv_modules.hpp
- # [cudev]
- /usr/include/opencv4/opencv2/cudaarithm.hpp
- /usr/include/opencv4/opencv2/cudabgsegm.hpp
- /usr/include/opencv4/opencv2/cudacodec.hpp
- /usr/include/opencv4/opencv2/cudafeatures2d.hpp
- /usr/include/opencv4/opencv2/cudafilters.hpp
- /usr/include/opencv4/opencv2/cudaimgproc.hpp
- /usr/include/opencv4/opencv2/cudalegacy.hpp
- /usr/include/opencv4/opencv2/cudalegacy/NCVBroxOpticalFlow.hpp
- /usr/include/opencv4/opencv2/cudalegacy/NCVHaarObjectDetection.hpp
- /usr/include/opencv4/opencv2/cudalegacy/NCV.hpp
- /usr/include/opencv4/opencv2/cudalegacy/NCVPyramid.hpp
- /usr/include/opencv4/opencv2/cudalegacy/NPP_staging.hpp
- /usr/include/opencv4/opencv2/cudaobjdetect.hpp
- /usr/include/opencv4/opencv2/cudaoptflow.hpp
- /usr/include/opencv4/opencv2/cudastereo.hpp
- /usr/include/opencv4/opencv2/cudawarping.hpp
- /usr/include/opencv4/opencv2/cudev/block/block.hpp
- /usr/include/opencv4/opencv2/cudev/block/detail/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/block/detail/reduce_key_val.hpp
- /usr/include/opencv4/opencv2/cudev/block/dynamic_smem.hpp
- /usr/include/opencv4/opencv2/cudev/block/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/block/scan.hpp
- /usr/include/opencv4/opencv2/cudev/block/vec_distance.hpp
- /usr/include/opencv4/opencv2/cudev/common.hpp
- /usr/include/opencv4/opencv2/cudev/expr/binary_func.hpp
- /usr/include/opencv4/opencv2/cudev/expr/binary_op.hpp
- /usr/include/opencv4/opencv2/cudev/expr/color.hpp
- /usr/include/opencv4/opencv2/cudev/expr/deriv.hpp
- /usr/include/opencv4/opencv2/cudev/expr/expr.hpp
- /usr/include/opencv4/opencv2/cudev/expr/per_element_func.hpp
- /usr/include/opencv4/opencv2/cudev/expr/reduction.hpp
- /usr/include/opencv4/opencv2/cudev/expr/unary_func.hpp
- /usr/include/opencv4/opencv2/cudev/expr/unary_op.hpp
- /usr/include/opencv4/opencv2/cudev/expr/warping.hpp
- /usr/include/opencv4/opencv2/cudev/functional/color_cvt.hpp
- /usr/include/opencv4/opencv2/cudev/functional/detail/color_cvt.hpp
- /usr/include/opencv4/opencv2/cudev/functional/functional.hpp
- /usr/include/opencv4/opencv2/cudev/functional/tuple_adapter.hpp
- /usr/include/opencv4/opencv2/cudev/grid/copy.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/copy.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/histogram.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/integral.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/minmaxloc.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/pyr_down.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/pyr_up.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/reduce_to_column.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/reduce_to_row.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/split_merge.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/transform.hpp
- /usr/include/opencv4/opencv2/cudev/grid/detail/transpose.hpp
- /usr/include/opencv4/opencv2/cudev/grid/histogram.hpp
- /usr/include/opencv4/opencv2/cudev/grid/integral.hpp
- /usr/include/opencv4/opencv2/cudev/grid/pyramids.hpp
- /usr/include/opencv4/opencv2/cudev/grid/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/grid/reduce_to_vec.hpp
- /usr/include/opencv4/opencv2/cudev/grid/split_merge.hpp
- /usr/include/opencv4/opencv2/cudev/grid/transform.hpp
- /usr/include/opencv4/opencv2/cudev/grid/transpose.hpp
- /usr/include/opencv4/opencv2/cudev.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/constant.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/deriv.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/detail/gpumat.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/extrapolation.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/glob.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/gpumat.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/interpolation.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/lut.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/mask.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/remap.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/resize.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/texture.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/traits.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/transform.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/warping.hpp
- /usr/include/opencv4/opencv2/cudev/ptr2d/zip.hpp
- /usr/include/opencv4/opencv2/cudev/util/atomic.hpp
- /usr/include/opencv4/opencv2/cudev/util/detail/tuple.hpp
- /usr/include/opencv4/opencv2/cudev/util/detail/type_traits.hpp
- /usr/include/opencv4/opencv2/cudev/util/limits.hpp
- /usr/include/opencv4/opencv2/cudev/util/saturate_cast.hpp
- /usr/include/opencv4/opencv2/cudev/util/simd_functions.hpp
- /usr/include/opencv4/opencv2/cudev/util/tuple.hpp
- /usr/include/opencv4/opencv2/cudev/util/type_traits.hpp
- /usr/include/opencv4/opencv2/cudev/util/vec_math.hpp
- /usr/include/opencv4/opencv2/cudev/util/vec_traits.hpp
- /usr/include/opencv4/opencv2/cudev/warp/detail/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/warp/detail/reduce_key_val.hpp
- /usr/include/opencv4/opencv2/cudev/warp/reduce.hpp
- /usr/include/opencv4/opencv2/cudev/warp/scan.hpp
- /usr/include/opencv4/opencv2/cudev/warp/shuffle.hpp
- /usr/include/opencv4/opencv2/cudev/warp/warp.hpp
- # [contrib_cvv]
- /usr/include/opencv4/opencv2/cvv/call_meta_data.hpp
- /usr/include/opencv4/opencv2/cvv/cvv.hpp
- /usr/include/opencv4/opencv2/cvv/debug_mode.hpp
- /usr/include/opencv4/opencv2/cvv/dmatch.hpp
- /usr/include/opencv4/opencv2/cvv/filter.hpp
- /usr/include/opencv4/opencv2/cvv/final_show.hpp
- /usr/include/opencv4/opencv2/cvv.hpp
- /usr/include/opencv4/opencv2/cvv/show_image.hpp
- # [contrib_hdf]
- /usr/include/opencv4/opencv2/hdf/hdf5.hpp
- /usr/include/opencv4/opencv2/hdf.hpp
- # [contrib_ovis]
- /usr/include/opencv4/opencv2/ovis.hpp
- # [contrib_sfm]
- /usr/include/opencv4/opencv2/sfm.hpp
- /usr/include/opencv4/opencv2/sfm/conditioning.hpp
- /usr/include/opencv4/opencv2/sfm/fundamental.hpp
- /usr/include/opencv4/opencv2/sfm/io.hpp
- /usr/include/opencv4/opencv2/sfm/numeric.hpp
- /usr/include/opencv4/opencv2/sfm/projection.hpp
- /usr/include/opencv4/opencv2/sfm/reconstruct.hpp
- /usr/include/opencv4/opencv2/sfm/robust.hpp
- /usr/include/opencv4/opencv2/sfm/simple_pipeline.hpp
- /usr/include/opencv4/opencv2/sfm/triangulation.hpp
- # [vtk]
- /usr/include/opencv4/opencv2/viz.hpp
- /usr/include/opencv4/opencv2/viz/types.hpp
- /usr/include/opencv4/opencv2/viz/viz3d.hpp
- /usr/include/opencv4/opencv2/viz/vizcore.hpp
- /usr/include/opencv4/opencv2/viz/widget_accessor.hpp
- /usr/include/opencv4/opencv2/viz/widgets.hpp
-)
-
-PATCHES=(
- "${FILESDIR}"/${PN}-3.4.0-disable-download.patch
- "${FILESDIR}"/${PN}-3.4.1-cuda-add-relaxed-constexpr.patch
- "${FILESDIR}"/${PN}-4.1.2-opencl-license.patch
- "${FILESDIR}"/${PN}-4.4.0-disable-native-cpuflag-detect.patch
- "${FILESDIR}"/${PN}-4.5.0-link-with-cblas-for-lapack.patch
- "${FILESDIR}"/${PN}-4.8.0-fix-protobuf.patch
- "${FILESDIR}"/${PN}-4.8.0-fix-flatbuffer.patch
- "${FILESDIR}"/${PN}-4.8.0-arm64-fp16.patch
- "${FILESDIR}"/${PN}-4.8.0-fix-cuda-12.2.0.patch
-)
-
-pkg_pretend() {
- [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
-}
-
-pkg_setup() {
- [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
- java-pkg-opt-2_pkg_setup
-}
-
-src_prepare() {
- # https://bugs.gentoo.org/838274
- replace-flags -O3 -O2
-
- cmake_src_prepare
-
- # remove bundled stuff
- rm -r 3rdparty || die "Removing 3rd party components failed"
- sed -e '/add_subdirectory(.*3rdparty.*)/ d' \
- -i CMakeLists.txt cmake/*cmake || die
-
- if use dnnsamples; then
- mv "${WORKDIR}/res10_300x300_ssd_iter_140000.caffemodel" "${WORKDIR}/${P}/samples/dnn/" || die
- fi
-
- if use contrib; then
- cd "${WORKDIR}/${PN}_contrib-${PV}" || die
- if use contribxfeatures2d; then
- mv "${WORKDIR}"/*.i "${WORKDIR}/${PN}_contrib-${PV}"/modules/xfeatures2d/src/ || die
- fi
- fi
-
- if use download; then
- mv "${WORKDIR}/${PN}-extdep-4.4.0" "${WORKDIR}/${P}/.cache/" || die
- fi
-
- java-pkg-opt-2_src_prepare
-
- # this really belongs in src_prepare() too
- JAVA_ANT_ENCODING="iso-8859-1"
- # set encoding so even this cmake build will pick it up.
- export ANT_OPTS+=" -Dfile.encoding=iso-8859-1"
- java-ant-2_src_configure
-}
-
-multilib_src_configure() {
- # please dont sort here, order is the same as in CMakeLists.txt
- GLOBALCMAKEARGS=(
- # for protobuf
- -DCMAKE_CXX_STANDARD=14
-
- # Optional 3rd party components
- # ===================================================
- -DENABLE_DOWNLOAD=$(usex download)
- -DWITH_QUIRC=OFF # Do not have dependencies
- -DWITH_FLATBUFFERS=$(usex contribdnn)
- -DWITH_1394=$(usex ieee1394)
- # -DWITH_AVFOUNDATION=OFF # IOS
- -DWITH_VTK=$(multilib_native_usex vtk)
- -DWITH_EIGEN=$(usex eigen)
- -DWITH_VFW=OFF # Video windows support
- -DWITH_FFMPEG=$(usex ffmpeg)
- -DWITH_GSTREAMER=$(usex gstreamer)
- -DWITH_GSTREAMER_0_10=OFF # Don't want this
- -DWITH_GTK=$(usex gtk3)
- -DWITH_GTK_2_X=OFF # only want gtk3 nowadays
- -DWITH_IPP=OFF
- # Jasper was removed from tree because of security problems.
- # Upstream were/are making progress. We use openjpeg instead.
- # bug 734284
- -DWITH_JASPER=OFF
- -DWITH_JPEG=$(usex jpeg)
- -DWITH_OPENJPEG=$(usex jpeg2k)
- -DWITH_WEBP=$(usex webp)
- -DWITH_OPENEXR=$(multilib_native_usex openexr)
- -DWITH_OPENGL=$(usex opengl)
- -DWITH_OPENVX=OFF
- -DWITH_OPENNI=OFF # Not packaged
- -DWITH_OPENNI2=OFF # Not packaged
- -DWITH_PNG=$(usex png)
- -DWITH_GDCM=OFF
- -DWITH_PVAPI=OFF
- -DWITH_GIGEAPI=OFF
- -DWITH_ARAVIS=OFF
- -DWITH_WIN32UI=OFF # Windows only
- # -DWITH_QUICKTIME=OFF
- # -DWITH_QTKIT=OFF
- -DWITH_TBB=$(usex threads)
- -DWITH_OPENMP=$(usex openmp)
- -DWITH_CSTRIPES=OFF
- -DWITH_PTHREADS_PF=ON
- -DWITH_TIFF=$(usex tiff)
- -DWITH_UNICAP=OFF # Not packaged
- -DWITH_V4L=$(usex v4l)
- -DWITH_LIBV4L=$(usex v4l)
- # -DWITH_DSHOW=ON # direct show supp
- -DWITH_MSMF=OFF
- -DWITH_XIMEA=OFF # Windows only
- -DWITH_XINE=$(multilib_native_usex xine)
- -DWITH_CLP=OFF
- -DWITH_OPENCL=$(usex opencl)
- -DWITH_OPENCL_SVM=OFF
- -DWITH_OPENCLAMDFFT=$(usex opencl)
- -DWITH_OPENCLAMDBLAS=$(usex opencl)
- -DWITH_DIRECTX=OFF
- -DWITH_INTELPERC=OFF
- -DWITH_IPP_A=OFF
- -DWITH_MATLAB=OFF
- -DWITH_VA=$(usex vaapi)
- -DWITH_VA_INTEL=$(usex vaapi)
- -DWITH_GDAL=$(multilib_native_usex gdal)
- -DWITH_GPHOTO2=$(usex gphoto2)
- -DWITH_LAPACK=$(multilib_native_usex lapack)
- -DWITH_ITT=OFF # 3dparty libs itt_notify
- # ===================================================
- # CUDA build components: nvidia-cuda-toolkit takes care of GCC version
- # ===================================================
- -DWITH_CUDA=$(multilib_native_usex cuda)
- -DWITH_CUBLAS=$(multilib_native_usex cuda)
- -DWITH_CUFFT=$(multilib_native_usex cuda)
- -DWITH_NVCUVID=OFF
- # -DWITH_NVCUVID=$(usex cuda)
- -DCUDA_NPP_LIBRARY_ROOT_DIR=$(usex cuda "${EPREFIX}/opt/cuda" "")
- # ===================================================
- # OpenCV build components
- # ===================================================
- -DBUILD_SHARED_LIBS=ON
- -DBUILD_JAVA=$(multilib_native_usex java) # Ant needed, no compile flag
- -DBUILD_ANDROID_EXAMPLES=OFF
- -DBUILD_opencv_apps=$(usex opencvapps ON OFF)
- -DBUILD_DOCS=OFF # Doesn't install anyways.
- -DBUILD_EXAMPLES=$(multilib_native_usex examples)
- -DBUILD_PERF_TESTS=OFF
- -DBUILD_TESTS=$(multilib_native_usex testprograms)
- -DBUILD_WITH_DEBUG_INFO=$(usex debug)
- # -DBUILD_WITH_STATIC_CRT=OFF
- -DBUILD_WITH_DYNAMIC_IPP=OFF
- -DBUILD_FAT_JAVA_LIB=OFF
- # -DBUILD_ANDROID_SERVICE=OFF
- -DBUILD_CUDA_STUBS=$(multilib_native_usex cuda)
- -DOPENCV_EXTRA_MODULES_PATH=$(usex contrib "${WORKDIR}/opencv_contrib-${PV}/modules" "")
- # ===================================================
- # OpenCV installation options
- # ===================================================
- -DINSTALL_CREATE_DISTRIB=OFF
- -DINSTALL_C_EXAMPLES=$(multilib_native_usex examples)
- -DINSTALL_TESTS=$(multilib_native_usex testprograms)
- -DINSTALL_PYTHON_EXAMPLES=$(multilib_native_usex examples)
- # -DINSTALL_ANDROID_EXAMPLES=OFF
- -DINSTALL_TO_MANGLED_PATHS=OFF
- -DOPENCV_GENERATE_PKGCONFIG=ON
- # opencv uses both ${CMAKE_INSTALL_LIBDIR} and ${LIB_SUFFIX}
- # to set its destination libdir
- -DLIB_SUFFIX=
- # ===================================================
- # OpenCV build options
- # ===================================================
- -DENABLE_CCACHE=OFF
- # bug 733796, but PCH is a risky game in CMake anyway
- -DENABLE_PRECOMPILED_HEADERS=OFF
- -DENABLE_SOLUTION_FOLDERS=OFF
- -DENABLE_PROFILING=OFF
- -DENABLE_COVERAGE=OFF
-
- -DHAVE_opencv_java=$(multilib_native_usex java YES NO)
- -DENABLE_NOISY_WARNINGS=OFF
- -DOPENCV_WARNINGS_ARE_ERRORS=OFF
- -DENABLE_IMPL_COLLECTION=OFF
- -DENABLE_INSTRUMENTATION=OFF
- -DGENERATE_ABI_DESCRIPTOR=OFF
- -DDOWNLOAD_EXTERNAL_TEST_DATA=OFF
- -DENABLE_LTO=$(usex lto)
- # ===================================================
- # things we want to be hard off or not yet figured out
- # ===================================================
- -DBUILD_PACKAGE=OFF
- # ===================================================
- # Not building protobuf but update files bug #631418
- # ===================================================
- -DWITH_PROTOBUF=ON
- -DBUILD_PROTOBUF=OFF
- -DPROTOBUF_UPDATE_FILES=ON
- -Dprotobuf_MODULE_COMPATIBLE=ON
- # ===================================================
- # things we want to be hard enabled not worth useflag
- # ===================================================
- -DCMAKE_SKIP_RPATH=ON
- -DOPENCV_DOC_INSTALL_PATH=
- -DBUILD_opencv_features2d=$(usex features2d ON OFF)
- )
-
- if use qt5; then
- GLOBALCMAKEARGS+=(
- -DWITH_QT=$(multilib_native_usex qt5 ON OFF)
- -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON
- )
- elif use qt6; then
- GLOBALCMAKEARGS+=(
- -DWITH_QT=$(multilib_native_usex qt6 ON OFF)
- -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=ON
- )
- else
- GLOBALCMAKEARGS+=(
- -DWITH_QT=OFF
- -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=ON
- -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON
- )
- fi
-
- # ==================================================
- # cpu flags, should solve 633900
- #===================================================
- local CPU_BASELINE=""
- for i in "${CPU_FEATURES_MAP[@]}" ; do
- if [[ ${ABI} != x86 || ${i%:*} != "cpu_flags_x86_avx2" ]]; then # workaround for Bug 747163
- use ${i%:*} && CPU_BASELINE="${CPU_BASELINE}${i#*:};"
- fi
- done
-
- GLOBALCMAKEARGS+=(
- -DOPENCV_CPU_OPT_IMPLIES_IGNORE=ON
- -DCPU_BASELINE=${CPU_BASELINE}
- -DCPU_DISPATCH=
- )
-
- # ===================================================
- # OpenCV Contrib Modules
- # ===================================================
- if use contrib; then
- GLOBALCMAKEARGS+=(
- -DBUILD_opencv_dnn=$(usex contribdnn ON OFF)
- -DTINYDNN_ROOT="${WORKDIR}/tiny-dnn-${TINY_DNN_PV}"
- -DBUILD_opencv_dnns_easily_fooled=OFF
- -DBUILD_opencv_xfeatures2d=$(usex contribxfeatures2d ON OFF)
- -DBUILD_opencv_cvv=$(usex contribcvv ON OFF)
- -DBUILD_opencv_hdf=$(multilib_native_usex contribhdf ON OFF)
- -DBUILD_opencv_sfm=$(usex contribsfm ON OFF)
- -DBUILD_opencv_freetype=$(usex contribfreetype ON OFF)
- -DBUILD_opencv_ovis=$(usex contribovis ON OFF)
- )
-
- if multilib_is_native_abi; then
- GLOBALCMAKEARGS+=(
- -DCMAKE_DISABLE_FIND_PACKAGE_Tesseract=$(usex !tesseract)
- )
- else
- GLOBALCMAKEARGS+=(
- -DCMAKE_DISABLE_FIND_PACKAGE_Tesseract=ON
- )
- fi
- fi
-
- # workaround for bug 413429
- tc-export CC CXX
-
- local mycmakeargs=(
- ${GLOBALCMAKEARGS[@]}
- -DPYTHON_EXECUTABLE=OFF
- -DINSTALL_PYTHON_EXAMPLES=OFF
- -DBUILD_opencv_python2=OFF
- -DBUILD_opencv_python3=OFF
- )
-
- cmake_src_configure
-
- # Copy face_land_model to ${CMAKE_BINARY_DIR}/${OPENCV_TEST_DATA_INSTALL_PATH}
- # TODO patch ocv_download to copy files into destination dirs
- if use contribdnn; then
- mkdir -p "${BUILD_DIR}"/share/OpenCV/testdata/cv/face/ || die
- cp "${WORKDIR}"/face_landmark_model.dat "${BUILD_DIR}"/share/OpenCV/testdata/cv/face/ || die
- fi
-
-}
-
-python_module_compile() {
- local BUILD_DIR="${orig_BUILD_DIR}"
- local mycmakeargs=( ${GLOBALCMAKEARGS[@]} )
-
- # Set all python variables to load the correct Gentoo paths
- mycmakeargs+=(
- # python_setup alters PATH and sets this as wrapper
- # to the correct interpreter we are building for
- -DPYTHON_DEFAULT_EXECUTABLE=${EPYTHON}
- -DINSTALL_PYTHON_EXAMPLES=$(usex examples)
- )
-
- # Regenerate cache file. Can't use rebuild_cache as it won't
- # have the Gentoo specific options.
- rm CMakeCache.txt || die "rm failed"
- cmake_src_configure
- cmake_src_compile
- cmake_src_install
-
- # Remove compiled binary so new version compiles
- # Avoid conflicts with new module builds as build system doesn't
- # really support it.
- rm -r modules/python3 || die "rm failed"
-
- python_optimize "${ED}"/$(python_get_sitedir)
-}
-
-multilib_src_install() {
- cmake_src_install
-
- # Build and install the python modules for all targets
- if multilib_is_native_abi && use python; then
- local orig_BUILD_DIR="${BUILD_DIR}"
- python_foreach_impl python_module_compile
- fi
-}