opencv-4.10.0.ebuild 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. PYTHON_COMPAT=( python3_{11..13} )
  5. inherit cuda java-pkg-opt-2 cmake-multilib flag-o-matic python-r1 toolchain-funcs virtualx
  6. DESCRIPTION="A collection of algorithms and sample code for various computer vision problems"
  7. HOMEPAGE="https://opencv.org"
  8. if [[ ${PV} = *9999* ]] ; then
  9. inherit git-r3
  10. EGIT_REPO_URI="https://github.com/${PN}/${PN}.git"
  11. else
  12. # branch master
  13. ADE_PV="0.1.2d"
  14. # branch wechat_qrcode_20210119
  15. QRCODE_COMMIT="a8b69ccc738421293254aec5ddb38bd523503252"
  16. # branch dnn_samples_face_detector_20170830
  17. DNN_SAMPLES_FACE_DETECTOR_COMMIT="b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f"
  18. # branch contrib_xfeatures2d_boostdesc_20161012
  19. XFEATURES2D_BOOSTDESC_COMMIT="34e4206aef44d50e6bbcd0ab06354b52e7466d26"
  20. # branch contrib_xfeatures2d_vgg_20160317
  21. XFEATURES2D_VGG_COMMIT="fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
  22. # branch contrib_face_alignment_20170818
  23. FACE_ALIGNMENT_COMMIT="8afa57abc8229d611c4937165d20e2a2d9fc5a12"
  24. # branch nvof_2_0_bsd
  25. NVIDIA_OPTICAL_FLOW_COMMIT="edb50da3cf849840d680249aa6dbef248ebce2ca"
  26. SRC_URI="
  27. https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
  28. https://github.com/opencv/ade/archive/v${ADE_PV}.tar.gz -> ade-${ADE_PV}.tar.gz
  29. contrib? (
  30. https://github.com/${PN}/${PN}_contrib/archive/${PV}.tar.gz -> ${PN}_contrib-${PV}.tar.gz
  31. dnnsamples? (
  32. https://github.com/${PN}/${PN}_3rdparty/archive/${QRCODE_COMMIT}.tar.gz -> ${PN}_3rdparty-${QRCODE_COMMIT}.tar.gz
  33. https://github.com/${PN}/${PN}_3rdparty/archive/${DNN_SAMPLES_FACE_DETECTOR_COMMIT}.tar.gz
  34. -> ${PN}_3rdparty-${DNN_SAMPLES_FACE_DETECTOR_COMMIT}.tar.gz
  35. )
  36. contribxfeatures2d? (
  37. https://github.com/${PN}/${PN}_3rdparty/archive/${XFEATURES2D_BOOSTDESC_COMMIT}.tar.gz
  38. -> ${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}.tar.gz
  39. https://github.com/${PN}/${PN}_3rdparty/archive/${XFEATURES2D_VGG_COMMIT}.tar.gz
  40. -> ${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}.tar.gz
  41. )
  42. contribdnn? (
  43. https://github.com/${PN}/${PN}_3rdparty/archive/${FACE_ALIGNMENT_COMMIT}.tar.gz
  44. -> ${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}.tar.gz
  45. )
  46. cuda? (
  47. https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz
  48. -> NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz
  49. )
  50. https://github.com/${PN}/${PN}_contrib/commit/667a66ee0e99f3f3263c1ef2de1b90d9244b7bd4.patch
  51. -> ${PN}_contrib-4.10.0-3607.patch
  52. )
  53. test? (
  54. https://github.com/${PN}/${PN}_extra/archive/refs/tags/${PV}.tar.gz -> ${PN}_extra-${PV}.tar.gz
  55. )
  56. "
  57. KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
  58. fi
  59. LICENSE="Apache-2.0"
  60. SLOT="0/${PV}" # subslot = libopencv* soname version
  61. # general options
  62. IUSE="debug doc +eigen flatbuffers gflags glog java non-free lto onnx opencvapps +python test testprograms"
  63. # modules
  64. IUSE+=" contrib contribcvv contribdnn contribfreetype contribhdf contribovis contribsfm contribxfeatures2d dnnsamples examples +features2d"
  65. # hardware
  66. IUSE+=" cuda cudnn opencl video_cards_intel"
  67. # video
  68. IUSE+=" +ffmpeg gstreamer xine vaapi v4l vulkan gphoto2 ieee1394"
  69. # image
  70. IUSE+=" avif gdal jasper jpeg jpeg2k openexr png quirc tesseract tiff webp"
  71. # gui
  72. IUSE+=" gtk3 qt6 opengl vtk truetype wayland"
  73. # parallel
  74. IUSE+=" openmp tbb"
  75. # lapack options
  76. IUSE+=" atlas lapack mkl"
  77. # from cmake/OpenCVCompilerOptimizations.cmake
  78. # TODO make this only relevant for binhost
  79. CPU_FEATURES_MAP=(
  80. cpu_flags_arm_neon:NEON
  81. cpu_flags_arm_vfpv3:VFPV3
  82. # cpu_flags_arm_fp:FP16
  83. cpu_flags_arm_asimddp:NEON_DOTPROD
  84. # cpu_flags_arm_neon_fp16:NEON_FP16
  85. # cpu_flags_arm_neon_bf16:NEON_BF16
  86. # cpu_flags_loong_lsx:LSX
  87. # cpu_flags_loong_lasx:LASX
  88. # cpu_flags_mips_msa:MSA
  89. cpu_flags_ppc_vsx:VSX # (always available on Power8)
  90. cpu_flags_ppc_vsx3:VSX3 # (always available on Power9)
  91. # cpu_flags_riscv_rvv:RVV
  92. cpu_flags_x86_sse:SSE # (always available on 64-bit CPUs)
  93. cpu_flags_x86_sse2:SSE2 # (always available on 64-bit CPUs)
  94. cpu_flags_x86_sse3:SSE3
  95. cpu_flags_x86_ssse3:SSSE3
  96. cpu_flags_x86_sse4_1:SSE4_1
  97. cpu_flags_x86_popcnt:POPCNT
  98. cpu_flags_x86_sse4_2:SSE4_2
  99. cpu_flags_x86_f16c:FP16
  100. cpu_flags_x86_fma3:FMA3
  101. cpu_flags_x86_avx:AVX
  102. cpu_flags_x86_avx2:AVX2
  103. cpu_flags_x86_avx512_bitalg:AVX_512BITALG
  104. cpu_flags_x86_avx512_vbmi2:AVX_512VBMI2
  105. cpu_flags_x86_avx512_vnni:AVX_512VNNI
  106. cpu_flags_x86_avx512_vpopcntdq:AVX_512VPOPCNTDQ
  107. cpu_flags_x86_avx512bw:AVX_512BW
  108. cpu_flags_x86_avx512cd:AVX_512CD
  109. cpu_flags_x86_avx512dq:AVX_512DQ
  110. cpu_flags_x86_avx512f:AVX_512F
  111. cpu_flags_x86_avx512ifma:AVX_512IFMA
  112. cpu_flags_x86_avx512vbmi:AVX_512VBMI
  113. cpu_flags_x86_avx512vl:AVX_512VL
  114. # AVX512_KNL_EXTRA
  115. cpu_flags_x86_avx512er:AVX_512ER
  116. cpu_flags_x86_avx512pf:AVX_512PF
  117. # AVX512_KNM_EXTRA
  118. cpu_flags_x86_avx512_4fmaps:AVX_5124FMAPS
  119. cpu_flags_x86_avx512_4vnniw:AVX_5124VNNIW
  120. )
  121. IUSE+=" ${CPU_FEATURES_MAP[*]%:*}"
  122. REQUIRED_USE="
  123. amd64? (
  124. cpu_flags_x86_sse
  125. cpu_flags_x86_sse2
  126. cpu_flags_x86_avx2? ( cpu_flags_x86_f16c )
  127. cpu_flags_x86_f16c? ( cpu_flags_x86_avx )
  128. cpu_flags_x86_avx512er? ( cpu_flags_x86_avx512pf )
  129. cpu_flags_x86_avx512pf? ( cpu_flags_x86_avx512er )
  130. cpu_flags_x86_avx512_4fmaps? ( cpu_flags_x86_avx512_4fmaps )
  131. cpu_flags_x86_avx512_4vnniw? ( cpu_flags_x86_avx512_4vnniw )
  132. )
  133. cuda? (
  134. contrib
  135. tesseract? ( opencl )
  136. non-free
  137. )
  138. cudnn? ( cuda contribdnn )
  139. dnnsamples? ( examples )
  140. gflags? ( contrib )
  141. glog? ( contrib )
  142. contribcvv? ( contrib qt6 )
  143. contribdnn? ( contrib flatbuffers )
  144. contribfreetype? ( contrib )
  145. contribhdf? ( contrib )
  146. contribovis? ( contrib )
  147. contribsfm? ( contrib eigen gflags glog )
  148. contribxfeatures2d? ( contrib )
  149. java? ( python )
  150. opengl? ( ?? ( gtk3 qt6 ) )
  151. jasper? ( !abi_x86_32 )
  152. python? ( ${PYTHON_REQUIRED_USE} )
  153. tesseract? ( contrib )
  154. onnx? ( flatbuffers )
  155. ?? ( gtk3 qt6 )
  156. ?? ( cuda gdal )
  157. ?? ( opengl vulkan )
  158. testprograms? ( test )
  159. test? ( || ( ffmpeg gstreamer ) jpeg png tiff features2d )
  160. "
  161. RESTRICT="!test? ( test )"
  162. COMMON_DEPEND="
  163. app-arch/bzip2[${MULTILIB_USEDEP}]
  164. dev-libs/protobuf:=[${MULTILIB_USEDEP}]
  165. sys-libs/zlib[${MULTILIB_USEDEP}]
  166. avif? ( media-libs/libavif:=[${MULTILIB_USEDEP}] )
  167. cuda? ( dev-util/nvidia-cuda-toolkit:= )
  168. cudnn? (
  169. dev-cpp/abseil-cpp:=
  170. dev-libs/cudnn:=
  171. )
  172. contribhdf? ( sci-libs/hdf5:= )
  173. contribfreetype? (
  174. media-libs/freetype:2[${MULTILIB_USEDEP}]
  175. media-libs/harfbuzz:=[${MULTILIB_USEDEP}]
  176. )
  177. contribovis? ( >=dev-games/ogre-1.12:= )
  178. ffmpeg? ( media-video/ffmpeg:0=[${MULTILIB_USEDEP}] )
  179. flatbuffers? ( >=dev-libs/flatbuffers-23.5.9:= )
  180. gdal? ( sci-libs/gdal:= )
  181. gflags? ( dev-cpp/gflags:=[${MULTILIB_USEDEP}] )
  182. glog? ( dev-cpp/glog:=[${MULTILIB_USEDEP}] )
  183. gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
  184. gstreamer? (
  185. media-libs/gstreamer:1.0[${MULTILIB_USEDEP}]
  186. media-libs/gst-plugins-base:1.0[${MULTILIB_USEDEP}]
  187. )
  188. gtk3? (
  189. dev-libs/glib:2[${MULTILIB_USEDEP}]
  190. x11-libs/gtk+:3[${MULTILIB_USEDEP}]
  191. )
  192. ieee1394? (
  193. media-libs/libdc1394:=[${MULTILIB_USEDEP}]
  194. sys-libs/libraw1394[${MULTILIB_USEDEP}]
  195. )
  196. java? ( >=virtual/jre-1.8:* )
  197. jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
  198. jpeg2k? (
  199. jasper? ( media-libs/jasper:= )
  200. !jasper? ( media-libs/openjpeg:2=[${MULTILIB_USEDEP}] )
  201. )
  202. lapack? (
  203. atlas? ( sci-libs/atlas )
  204. mkl? ( sci-libs/mkl )
  205. !atlas? (
  206. !mkl? (
  207. virtual/cblas
  208. >=virtual/lapack-3.10
  209. virtual/lapacke
  210. )
  211. )
  212. )
  213. opencl? (
  214. virtual/opencl[${MULTILIB_USEDEP}]
  215. dev-util/opencl-headers
  216. )
  217. openexr? (
  218. dev-libs/imath:=
  219. media-libs/openexr:=
  220. )
  221. onnx? ( >=sci-libs/onnxruntime-1.12.0 )
  222. opencl? ( virtual/opencl[${MULTILIB_USEDEP}] )
  223. openexr? ( media-libs/openexr:=[${MULTILIB_USEDEP}] )
  224. opengl? (
  225. virtual/opengl[${MULTILIB_USEDEP}]
  226. virtual/glu[${MULTILIB_USEDEP}]
  227. )
  228. png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] )
  229. python? (
  230. ${PYTHON_DEPS}
  231. dev-python/numpy:=[${PYTHON_USEDEP}]
  232. )
  233. qt6? (
  234. dev-qt/qtbase:6[gui,widgets,concurrent,opengl?]
  235. )
  236. quirc? ( media-libs/quirc )
  237. tesseract? ( app-text/tesseract[opencl=,${MULTILIB_USEDEP}] )
  238. tbb? ( dev-cpp/tbb:=[${MULTILIB_USEDEP}] )
  239. tiff? ( media-libs/tiff:=[${MULTILIB_USEDEP}] )
  240. v4l? ( >=media-libs/libv4l-0.8.3[${MULTILIB_USEDEP}] )
  241. vaapi? ( media-libs/libva[${MULTILIB_USEDEP}] )
  242. vtk? (
  243. sci-libs/vtk:=[rendering,cuda=]
  244. || (
  245. (
  246. sci-libs/vtk[opencascade(+)]
  247. sci-libs/opencascade[-ffmpeg]
  248. )
  249. sci-libs/vtk[-opencascade(-)]
  250. )
  251. )
  252. wayland? ( >=dev-libs/wayland-1.18.0[${MULTILIB_USEDEP}] )
  253. webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
  254. xine? ( media-libs/xine-lib )
  255. "
  256. GST_TEST_DEPEND="
  257. media-plugins/gst-plugins-aom[${MULTILIB_USEDEP}]
  258. media-plugins/gst-plugins-mpeg2enc[${MULTILIB_USEDEP}]
  259. media-plugins/gst-plugins-openh264[${MULTILIB_USEDEP}]
  260. "
  261. DEPEND="
  262. ${COMMON_DEPEND}
  263. eigen? ( >=dev-cpp/eigen-3.3.8-r1:3 )
  264. java? ( >=virtual/jdk-1.8:* )
  265. test? (
  266. gstreamer? (
  267. amd64? ( ${GST_TEST_DEPEND} )
  268. arm64? ( ${GST_TEST_DEPEND} )
  269. x86? ( ${GST_TEST_DEPEND} )
  270. arm? ( media-plugins/gst-plugins-openh264[${MULTILIB_USEDEP}] )
  271. media-plugins/gst-plugins-jpeg[${MULTILIB_USEDEP}]
  272. media-plugins/gst-plugins-libav[${MULTILIB_USEDEP}]
  273. media-plugins/gst-plugins-mpeg2dec[${MULTILIB_USEDEP}]
  274. media-plugins/gst-plugins-mpg123[${MULTILIB_USEDEP}]
  275. media-plugins/gst-plugins-x264[${MULTILIB_USEDEP}]
  276. !ppc? ( !ppc64? (
  277. media-plugins/gst-plugins-vpx[${MULTILIB_USEDEP}]
  278. ) )
  279. )
  280. )
  281. "
  282. RDEPEND="
  283. ${COMMON_DEPEND}
  284. java? ( >=virtual/jre-1.8:* )
  285. "
  286. unset COMMON_DEPEND
  287. BDEPEND="
  288. dev-util/patchelf
  289. virtual/pkgconfig
  290. cuda? ( dev-util/nvidia-cuda-toolkit:= )
  291. doc? (
  292. app-text/doxygen[dot]
  293. python? (
  294. dev-python/beautifulsoup4[${PYTHON_USEDEP}]
  295. )
  296. )
  297. java? ( >=dev-java/ant-1.10.14-r3 )
  298. "
  299. PATCHES=(
  300. "${FILESDIR}/${PN}-3.4.0-disable-download.patch"
  301. "${FILESDIR}/${PN}-3.4.1-cuda-add-relaxed-constexpr.patch"
  302. "${FILESDIR}/${PN}-4.1.2-opencl-license.patch"
  303. "${FILESDIR}/${PN}-4.4.0-disable-native-cpuflag-detect.patch"
  304. "${FILESDIR}/${PN}-4.5.0-link-with-cblas-for-lapack.patch"
  305. "${FILESDIR}/${PN}-4.8.1-use-system-flatbuffers.patch"
  306. "${FILESDIR}/${PN}-4.8.1-use-system-opencl.patch"
  307. "${FILESDIR}/${PN}-4.9.0-drop-python2-detection.patch"
  308. "${FILESDIR}/${PN}-4.9.0-ade-0.1.2d.tar.gz.patch"
  309. "${FILESDIR}/${PN}-4.9.0-cmake-cleanup.patch"
  310. "${FILESDIR}/${PN}-4.10.0-fix-build-with-vtk9.patch"
  311. "${FILESDIR}/${PN}-4.10.0-dnn-explicitly-include-abseil-cpp.patch"
  312. "${FILESDIR}/${PN}-4.10.0-cudnn-9.patch" # 25841
  313. "${FILESDIR}/${PN}-4.10.0-cuda-fp16.patch" # 25880
  314. "${FILESDIR}/${PN}-4.10.0-26234.patch" # 26234
  315. "${FILESDIR}/${PN}-4.10.0-tbb-detection.patch"
  316. # TODO applied in src_prepare
  317. # "${FILESDIR}/${PN}_contrib-4.8.1-rgbd.patch"
  318. # "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
  319. # "${FILESDIR}/${PN}_contrib-4.10.0-CUDA-12.6-tuple_size.patch" # 3785
  320. )
  321. cuda_get_host_compiler() {
  322. if [[ -n "${NVCC_CCBIN}" ]]; then
  323. echo "${NVCC_CCBIN}"
  324. return
  325. fi
  326. if [[ -n "${CUDAHOSTCXX}" ]]; then
  327. echo "${CUDAHOSTCXX}"
  328. return
  329. fi
  330. einfo "Trying to find working CUDA host compiler"
  331. if ! tc-is-gcc && ! tc-is-clang; then
  332. die "$(tc-get-compiler-type) compiler is not supported"
  333. fi
  334. local compiler compiler_type compiler_version
  335. local package package_version
  336. local -x NVCC_CCBIN
  337. local NVCC_CCBIN_default
  338. compiler_type="$(tc-get-compiler-type)"
  339. compiler_version="$("${compiler_type}-major-version")"
  340. # try the default compiler first
  341. NVCC_CCBIN="$(tc-getCXX)"
  342. NVCC_CCBIN_default="${NVCC_CCBIN}-${compiler_version}"
  343. compiler="${NVCC_CCBIN/%-${compiler_version}}"
  344. # store the package so we can re-use it later
  345. package="sys-devel/${compiler_type}"
  346. package_version="${package}"
  347. ebegin "testing ${NVCC_CCBIN_default} (default)"
  348. while ! nvcc - -x cu <<<"int main(){}" &>/dev/null; do
  349. eend 1
  350. while true; do
  351. # prepare next version
  352. if ! package_version="<$(best_version "${package_version}")"; then
  353. die "could not find a supported version of ${compiler}"
  354. fi
  355. NVCC_CCBIN="${compiler}-$(ver_cut 1 "${package_version/#<${package}-/}")"
  356. [[ "${NVCC_CCBIN}" != "${NVCC_CCBIN_default}" ]] && break
  357. done
  358. ebegin "testing ${NVCC_CCBIN}"
  359. done
  360. eend $?
  361. echo "${NVCC_CCBIN}"
  362. export NVCC_CCBIN
  363. }
  364. cuda_get_host_native_arch() {
  365. [[ -n ${CUDAARCHS} ]] && echo "${CUDAARCHS}"
  366. __nvcc_device_query || die "failed to query the native device"
  367. }
  368. pkg_pretend() {
  369. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  370. if use cuda && [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then # TODO CUDAARCHS
  371. einfo "The target CUDA architecture can be set via one of:"
  372. einfo " - CUDA_GENERATION set to one of Maxwell, Pascal, Volta, Turing, Ampere, Lovelace, Hopper, Auto"
  373. einfo " - CUDA_ARCH_BIN, (and optionally CUDA_ARCH_PTX) in the form of x.y tuples."
  374. einfo " You can specify multiple tuple separated by \";\"."
  375. einfo ""
  376. einfo "The CUDA architecture tuple for your device can be found at https://developer.nvidia.com/cuda-gpus."
  377. fi
  378. # When building binpkgs you probably want to include all targets
  379. if use cuda && [[ ${MERGE_TYPE} == "buildonly" ]] && [[ -n "${CUDA_GENERATION}" || -n "${CUDA_ARCH_BIN}" ]]; then
  380. local info_message="When building a binary package it's recommended to unset CUDA_GENERATION and CUDA_ARCH_BIN"
  381. einfo "$info_message so all available architectures are build."
  382. fi
  383. }
  384. pkg_setup() {
  385. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  386. use java && java-pkg-opt-2_pkg_setup
  387. if use cuda && [[ ! -e /dev/nvidia-uvm ]]; then
  388. # NOTE We try to load nvidia-uvm and nvidia-modeset here,
  389. # so __nvcc_device_query does not fail later.
  390. nvidia-modprobe -m -u -c 0 || true
  391. fi
  392. }
  393. src_prepare() {
  394. if use cuda; then
  395. export CUDA_VERBOSE="$(usex debug "true" "false")"
  396. cuda_src_prepare
  397. fi
  398. cmake_src_prepare
  399. # remove bundled stuff
  400. rm -r 3rdparty || die "Removing 3rd party components failed"
  401. sed -e '/add_subdirectory(.*3rdparty.*)/ d' \
  402. -i CMakeLists.txt cmake/*cmake || die
  403. sed \
  404. -e 's:truetype/wqy:wqy-microhei:g' \
  405. -i \
  406. modules/gapi/test/render/gapi_render_tests_ocv.cpp \
  407. modules/gapi/test/render/ftp_render_test.cpp \
  408. || die
  409. if use contrib; then
  410. cd "${WORKDIR}/${PN}_contrib-${PV}" || die
  411. eapply "${FILESDIR}/${PN}_contrib-4.8.1-rgbd.patch"
  412. eapply "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
  413. if type -P nvcc &> /dev/null && ver_test "$(nvcc --version | tail -n 1 | cut -d '_' -f 2- | cut -d '.' -f 1-2)" -ge 12.4; then
  414. eapply "${DISTDIR}/${PN}_contrib-4.10.0-3607.patch"
  415. eapply "${FILESDIR}/${PN}_contrib-4.10.0-CUDA-12.6-tuple_size.patch" # 3785
  416. fi
  417. cd "${S}" || die
  418. ! use contribcvv && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/cvv" || die; }
  419. ! use contribdnn && { rm -R "${S}/modules/dnn" || die; }
  420. ! use contribfreetype && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/freetype" || die; }
  421. ! use contribhdf && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/hdf" || die; }
  422. ! use contribovis && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/ovis" || die; }
  423. ! use contribsfm && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/sfm" || die; }
  424. ! use contribxfeatures2d && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/xfeatures2d" || die; }
  425. fi
  426. mkdir -p "${S}/.cache/ade" || die
  427. cp \
  428. "${DISTDIR}/ade-${ADE_PV}.tar.gz" \
  429. "${S}/.cache/ade/$(md5sum "${DISTDIR}/ade-${ADE_PV}.tar.gz" | cut -f 1 -d " ")-v${ADE_PV}.tar.gz" || die
  430. if use dnnsamples; then
  431. mkdir -p "${S}/.cache/wechat_qrcode" || die
  432. for file in "detect.caffemodel" "detect.prototxt" "sr.prototxt" "sr.caffemodel"; do
  433. mv \
  434. "${WORKDIR}/${PN}_3rdparty-${QRCODE_COMMIT}/${file}" \
  435. "${S}/.cache/wechat_qrcode/$( \
  436. md5sum "${WORKDIR}/${PN}_3rdparty-${QRCODE_COMMIT}/${file}" | cut -f 1 -d " " \
  437. )-${file}" || die
  438. done
  439. mv \
  440. "${WORKDIR}/${PN}_3rdparty-${DNN_SAMPLES_FACE_DETECTOR_COMMIT}/res10_300x300_ssd_iter_140000.caffemodel" \
  441. "${S}/samples/dnn/" || die
  442. fi
  443. if use contribxfeatures2d; then
  444. cp \
  445. "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/"*.i \
  446. "${WORKDIR}/${PN}_contrib-${PV}"/modules/xfeatures2d/src/ || die
  447. mkdir -p "${S}/.cache/xfeatures2d/boostdesc" || die
  448. for file in "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/"*.i; do
  449. mv \
  450. "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/$(basename "${file}")" \
  451. "${S}/.cache/xfeatures2d/boostdesc/$( \
  452. md5sum "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_BOOSTDESC_COMMIT}/$(basename "${file}")" | cut -f 1 -d " " \
  453. )-$(basename "${file}")" || die
  454. done
  455. cp \
  456. "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/"*.i \
  457. "${WORKDIR}/${PN}_contrib-${PV}"/modules/xfeatures2d/src/ || die
  458. mkdir -p "${S}/.cache/xfeatures2d/vgg" || die
  459. for file in "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/"*.i; do
  460. mv \
  461. "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/$(basename "${file}")" \
  462. "${S}/.cache/xfeatures2d/vgg/$( \
  463. md5sum "${WORKDIR}/${PN}_3rdparty-${XFEATURES2D_VGG_COMMIT}/$(basename "${file}")" | cut -f 1 -d " " \
  464. )-$(basename "${file}")" || die
  465. done
  466. fi
  467. if use contribdnn; then
  468. mkdir -p "${S}/.cache/data" || die
  469. mkdir -p "${WORKDIR}/${PN}_extra-${PV}/testdata/cv/face/" || die
  470. file="face_landmark_model.dat"
  471. cp \
  472. "${WORKDIR}/${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}/${file}" \
  473. "${WORKDIR}/${PN}_extra-${PV}/testdata/cv/face/" \
  474. || die
  475. mv \
  476. "${WORKDIR}/${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}/${file}" \
  477. "${S}/.cache/data/$( \
  478. md5sum "${WORKDIR}/${PN}_3rdparty-${FACE_ALIGNMENT_COMMIT}/${file}" | cut -f 1 -d " " \
  479. )-${file}" || die
  480. fi
  481. if use cuda; then
  482. mkdir -p "${S}/.cache/nvidia_optical_flow"
  483. cp \
  484. "${DISTDIR}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" \
  485. "${S}/.cache/nvidia_optical_flow/$( \
  486. md5sum "${DISTDIR}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" | cut -f 1 -d " " \
  487. )-${NVIDIA_OPTICAL_FLOW_COMMIT}.tar.gz" || die
  488. fi
  489. if use java; then
  490. java-pkg-opt-2_src_prepare
  491. # set encoding so even this cmake build will pick it up.
  492. ANT_OPTS+=" -Dfile.encoding=iso-8859-1"
  493. ANT_OPTS+=" -Dant.build.javac.source=$(java-pkg_get-source)"
  494. ANT_OPTS+=" -Dant.build.javac.target=$(java-pkg_get-target)"
  495. fi
  496. if multilib_native_use testprograms; then
  497. sed \
  498. -e 's:share/OpenCV/testdata:@OPENCV_TEST_DATA_INSTALL_PATH@:g' \
  499. -i "${S}/cmake/templates/opencv_run_all_tests_unix.sh.in" || die
  500. fi
  501. }
  502. multilib_src_configure() {
  503. CMAKE_BUILD_TYPE=$(usex debug "RelWithDebInfo" "Release")
  504. if use opencl ; then
  505. append-cppflags -DCL_TARGET_OPENCL_VERSION=120
  506. fi
  507. # bug #919101 and https://github.com/opencv/opencv/issues/19020
  508. filter-lto
  509. if tc-is-gcc && [[ $(gcc-major-version) -ge 15 ]] && use contribdnn; then
  510. append-cxxflags "-fno-tree-vectorize"
  511. fi
  512. # please don't sort here, order is the same as in CMakeLists.txt
  513. local mycmakeargs=(
  514. -DMIN_VER_CMAKE=3.26
  515. -DCMAKE_POLICY_DEFAULT_CMP0148="OLD" # FindPythonInterp
  516. # for protobuf
  517. -DCMAKE_CXX_STANDARD=17
  518. # Optional 3rd party components
  519. # ===================================================
  520. -DENABLE_DOWNLOAD="no"
  521. -DOPENCV_ENABLE_NONFREE="$(usex non-free)"
  522. -DWITH_QUIRC="$(usex quirc)"
  523. -DWITH_FLATBUFFERS="$(usex flatbuffers)"
  524. -DWITH_1394="$(usex ieee1394)"
  525. # -DWITH_AVFOUNDATION="no" # IOS
  526. -DWITH_VTK="$(multilib_native_usex vtk)"
  527. -DWITH_EIGEN="$(usex eigen)"
  528. -DWITH_VFW="no" # Video windows support
  529. -DWITH_FFMPEG="$(usex ffmpeg)"
  530. -DWITH_GSTREAMER="$(usex gstreamer)"
  531. -DWITH_GTK="$(usex gtk3)"
  532. -DWITH_GTK_2_X="no" # only want gtk3 nowadays
  533. -DWITH_IPP="no"
  534. -DWITH_JASPER="$(usex jpeg2k "$(multilib_native_usex jasper)")"
  535. -DWITH_VULKAN="$(usex vulkan)"
  536. -DWITH_JPEG="$(usex jpeg)"
  537. -DWITH_OPENJPEG="$(usex jpeg2k "$(multilib_native_usex !jasper)")"
  538. -DWITH_WEBP="$(usex webp)"
  539. -DWITH_OPENEXR="$(multilib_native_usex openexr)"
  540. -DWITH_OPENGL="$(usex opengl)"
  541. -DOpenGL_GL_PREFERENCE="GLVND"
  542. -DWITH_OPENVX="no"
  543. -DWITH_OPENNI="no" # Not packaged
  544. -DWITH_OPENNI2="no" # Not packaged
  545. -DWITH_PNG="$(usex png)"
  546. -DWITH_GDCM="no"
  547. -DWITH_PVAPI="no"
  548. -DWITH_GIGEAPI="no"
  549. -DWITH_ARAVIS="no"
  550. -DWITH_WAYLAND="$(usex wayland)"
  551. -DWITH_WIN32UI="no" # Windows only
  552. # -DWITH_QUICKTIME="no"
  553. # -DWITH_QTKIT="no"
  554. -DWITH_TBB="$(usex tbb)"
  555. -DWITH_OPENMP="$(usex openmp)"
  556. -DWITH_CSTRIPES="no"
  557. -DWITH_PTHREADS_PF="yes"
  558. -DWITH_TIFF="$(usex tiff)"
  559. -DWITH_UNICAP="no" # Not packaged
  560. -DWITH_V4L="$(usex v4l)"
  561. -DWITH_LIBV4L="$(usex v4l)"
  562. # -DWITH_DSHOW="yes" # direct show supp
  563. -DWITH_MSMF="no"
  564. -DWITH_XIMEA="no" # Windows only
  565. -DWITH_XINE="$(multilib_native_usex xine)"
  566. -DWITH_CLP="no"
  567. -DWITH_ONNX="$(usex onnx)"
  568. -DWITH_OPENCL="$(usex opencl)"
  569. -DWITH_OPENCL_SVM="no" # "$(usex opencl)"
  570. -DWITH_DIRECTX="no"
  571. -DWITH_INTELPERC="no"
  572. -DWITH_IPP_A="no"
  573. -DWITH_MATLAB="no"
  574. -DWITH_VA="$(usex vaapi)"
  575. -DWITH_VA_INTEL="$(usex vaapi "$(usex video_cards_intel)")"
  576. -DWITH_GDAL="$(multilib_native_usex gdal)"
  577. -DWITH_GPHOTO2="$(usex gphoto2)"
  578. -DWITH_LAPACK="$(multilib_native_usex lapack)"
  579. -DWITH_ITT="no" # 3dparty libs itt_notify
  580. -DWITH_AVIF="$(usex avif)"
  581. -DWITH_FREETYPE="$(usex truetype)"
  582. # ===================================================
  583. # CUDA build components: nvidia-cuda-toolkit
  584. # ===================================================
  585. -DWITH_CUDA="$(multilib_native_usex cuda)"
  586. -DWITH_CUBLAS="$(multilib_native_usex cuda)"
  587. -DWITH_CUFFT="$(multilib_native_usex cuda)"
  588. -DWITH_CUDNN="$(multilib_native_usex cudnn)"
  589. -DOPENCV_DNN_CUDA="$(multilib_native_usex cudnn)"
  590. # NOTE set this via MYCMAKEARGS if needed
  591. -DWITH_NVCUVID="no" # TODO needs NVIDIA Video Codec SDK
  592. -DWITH_NVCUVENC="no" # TODO needs NVIDIA Video Codec SDK
  593. -DCUDA_NPP_LIBRARY_ROOT_DIR="$(usex cuda "${CUDA_PATH:=${EPREFIX}/opt/cuda}" "")"
  594. -DCUDA_FAST_MATH="$(multilib_native_usex cuda)"
  595. # ===================================================
  596. # OpenCV build components
  597. # ===================================================
  598. -DBUILD_SHARED_LIBS="yes"
  599. -DBUILD_JAVA="$(multilib_native_usex java)" # Ant needed, no compile flag
  600. -DBUILD_ANDROID_EXAMPLES="no"
  601. -DBUILD_opencv_apps="$(usex opencvapps)"
  602. -DBUILD_DOCS="$(usex doc)" # Doesn't install anyways.
  603. -DBUILD_EXAMPLES="$(multilib_native_usex examples)"
  604. -DBUILD_TESTS="$(multilib_native_usex test "yes" "$(multilib_native_usex testprograms)")"
  605. -DBUILD_PERF_TESTS="no"
  606. -DBUILD_WITH_DEBUG_INFO="$(usex debug)"
  607. -DOPENCV_ENABLE_MEMORY_SANITIZER="$(usex debug)"
  608. # -DBUILD_WITH_STATIC_CRT="no"
  609. -DBUILD_WITH_DYNAMIC_IPP="no"
  610. -DBUILD_FAT_JAVA_LIB="no"
  611. # -DBUILD_ANDROID_SERVICE="no"
  612. -DBUILD_CUDA_STUBS="$(multilib_native_usex cuda)"
  613. -DOPENCV_EXTRA_MODULES_PATH="$(usex contrib "${WORKDIR}/${PN}_contrib-${PV}/modules" "")"
  614. # ===================================================
  615. # OpenCV installation options
  616. # ===================================================
  617. -DINSTALL_CREATE_DISTRIB="no"
  618. -DINSTALL_BIN_EXAMPLES="$(multilib_native_usex examples)"
  619. -DINSTALL_C_EXAMPLES="$(multilib_native_usex examples)"
  620. -DINSTALL_TESTS="$(multilib_native_usex testprograms)"
  621. -DINSTALL_PYTHON_EXAMPLES="$(multilib_native_usex examples)"
  622. # -DINSTALL_ANDROID_EXAMPLES="no"
  623. -DINSTALL_TO_MANGLED_PATHS="no"
  624. -DOPENCV_GENERATE_PKGCONFIG="yes"
  625. -DOPENCV_ENABLE_NONFREE="$(multilib_native_usex non-free)"
  626. # -DOPENCV_README_FILE="no"
  627. # -DOPENCV_LICENSE_FILE="no"
  628. # opencv uses both ${CMAKE_INSTALL_LIBDIR} and ${LIB_SUFFIX}
  629. # to set its destination libdir
  630. -DLIB_SUFFIX=
  631. # ===================================================
  632. # OpenCV build options
  633. # ===================================================
  634. -DENABLE_CCACHE="no"
  635. # bug 733796, but PCH is a risky game in CMake anyway
  636. -DBUILD_USE_SYMLINKS="yes"
  637. -DENABLE_PRECOMPILED_HEADERS="no"
  638. -DENABLE_SOLUTION_FOLDERS="no"
  639. -DENABLE_PROFILING="no"
  640. -DENABLE_COVERAGE="no"
  641. -DOPENCV_DOWNLOAD_TRIES_LIST="0"
  642. -DHAVE_opencv_java="$(multilib_native_usex java)"
  643. -DBUILD_WITH_DEBUG_INFO="$(usex debug)"
  644. -DOPENCV_ENABLE_MEMORY_SANITIZER="$(usex debug)"
  645. -DCV_TRACE="$(usex debug)"
  646. -DENABLE_NOISY_WARNINGS="$(usex debug)"
  647. -DOPENCV_WARNINGS_ARE_ERRORS="no"
  648. -DENABLE_IMPL_COLLECTION="no"
  649. -DENABLE_INSTRUMENTATION="no"
  650. -DGENERATE_ABI_DESCRIPTOR="no"
  651. -DENABLE_LTO="$(usex lto)"
  652. # ===================================================
  653. # things we want to be hard off or not yet figured out
  654. # ===================================================
  655. -DBUILD_PACKAGE="no"
  656. # ===================================================
  657. # Not building protobuf but update files bug #631418
  658. # ===================================================
  659. -DWITH_PROTOBUF="yes"
  660. -DBUILD_PROTOBUF="no"
  661. -DPROTOBUF_UPDATE_FILES="yes"
  662. -DProtobuf_MODULE_COMPATIBLE="yes"
  663. # ===================================================
  664. # things we want to be hard enabled not worth useflag
  665. # ===================================================
  666. -DOPENCV_DOC_INSTALL_PATH="share/doc/${PF}"
  667. -DOPENCV_SAMPLES_BIN_INSTALL_PATH="libexec/${PN}/bin/samples"
  668. -DBUILD_IPP_IW="no"
  669. -DBUILD_ITT="no"
  670. # ===================================================
  671. # configure modules to be build
  672. # ===================================================
  673. -DBUILD_opencv_gapi="$(usex ffmpeg yes "$(usex gstreamer)")"
  674. -DBUILD_opencv_features2d="$(usex features2d)"
  675. -DBUILD_opencv_java_bindings_generator="$(usex java)"
  676. -DBUILD_opencv_js="no"
  677. -DBUILD_opencv_js_bindings_generator="no"
  678. -DBUILD_opencv_objc_bindings_generator="no"
  679. -DBUILD_opencv_python2="no"
  680. -DBUILD_opencv_ts="$(usex test)"
  681. -DBUILD_opencv_video="$(usex ffmpeg yes "$(usex gstreamer)")"
  682. -DBUILD_opencv_videoio="$(usex ffmpeg yes "$(usex gstreamer)")"
  683. -DBUILD_opencv_cudalegacy="no"
  684. # -DBUILD_opencv_world="yes"
  685. -DOPENCV_PLUGIN_VERSION=".$(ver_rs 1-2 '' "$(ver_cut 1-2)")"
  686. -DOPENCV_PLUGIN_ARCH=".${ARCH}"
  687. -DDNN_PLUGIN_LIST="all"
  688. -DHIGHGUI_ENABLE_PLUGINS="no"
  689. #-DHIGHGUI_PLUGIN_LIST="all"
  690. #-DVIDEOIO_PLUGIN_LIST="all"
  691. )
  692. local VIDEOIO_PLUGIN_LIST=()
  693. if use ffmpeg; then
  694. VIDEOIO_PLUGIN_LIST+=("ffmpeg")
  695. fi
  696. if use gstreamer; then
  697. VIDEOIO_PLUGIN_LIST+=("gstreamer")
  698. fi
  699. mycmakeargs+=(
  700. -DVIDEOIO_PLUGIN_LIST="$(IFS=';'; echo "${VIDEOIO_PLUGIN_LIST[*]}")"
  701. )
  702. if use qt6; then
  703. mycmakeargs+=(
  704. -DWITH_QT="$(multilib_native_usex qt6)"
  705. -DCMAKE_DISABLE_FIND_PACKAGE_Qt5="yes"
  706. )
  707. else
  708. mycmakeargs+=(
  709. -DWITH_QT="no"
  710. -DCMAKE_DISABLE_FIND_PACKAGE_Qt5="yes"
  711. -DCMAKE_DISABLE_FIND_PACKAGE_Qt6="yes"
  712. )
  713. fi
  714. # ==================================================
  715. # cpu flags, should solve 633900
  716. #===================================================
  717. # TODO binhost https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
  718. local CPU_BASELINE=""
  719. for i in "${CPU_FEATURES_MAP[@]}" ; do
  720. if [[ ${ABI} != x86 || ${i%:*} != "cpu_flags_x86_avx2" ]]; then # workaround for Bug 747163
  721. local value
  722. # These are merged into one flag internally
  723. if [[ ${ABI} == amd64 ]]; then
  724. case "${i%:*}" in
  725. cpu_flags_x86_avx512er|cpu_flags_x86_avx512pf)
  726. value="AVX512_KNL_EXTRA"
  727. ;;
  728. cpu_flags_x86_avx512_4fmaps|cpu_flags_x86_avx512_4vnniw)
  729. value="AVX512_KNM_EXTRA"
  730. ;;
  731. *)
  732. value="${i#*:}"
  733. ;;
  734. esac
  735. else
  736. value=${i#*:}
  737. fi
  738. use "${i%:*}" && CPU_BASELINE="${CPU_BASELINE}${value};"
  739. fi
  740. done
  741. unset CPU_FEATURES_MAP
  742. mycmakeargs+=(
  743. -DCPU_BASELINE="${CPU_BASELINE}"
  744. )
  745. if [[ ${MERGE_TYPE} != "buildonly" ]]; then
  746. mycmakeargs+=(
  747. -DOPENCV_CPU_OPT_IMPLIES_IGNORE="yes"
  748. -DCPU_DISPATCH=
  749. )
  750. fi
  751. # ===================================================
  752. # OpenCV Contrib Modules
  753. # ===================================================
  754. # NOTE
  755. # we remove unused modules,
  756. # so we shouldn't need to disable options for unused modules
  757. if use contrib; then
  758. mycmakeargs+=(
  759. -DBUILD_opencv_cvv="$(usex contribcvv)"
  760. -DBUILD_opencv_dnn="$(usex contribdnn)"
  761. -DOPENCV_DNN_OPENCL="$(usex opencl)"
  762. -DOPENCV_DNN_CUDA="$(multilib_native_usex cudnn)"
  763. -DBUILD_opencv_dnns_easily_fooled=OFF
  764. -DBUILD_opencv_freetype="$(usex contribfreetype)"
  765. -DBUILD_opencv_hdf="$(multilib_native_usex contribhdf)"
  766. -DBUILD_opencv_ovis="$(usex contribovis)"
  767. -DBUILD_opencv_sfm="$(usex contribsfm)"
  768. -DBUILD_opencv_xfeatures2d="$(usex contribxfeatures2d)"
  769. )
  770. if ! multilib_native_use tesseract; then
  771. mycmakeargs+=(
  772. -DCMAKE_DISABLE_FIND_PACKAGE_Tesseract="yes"
  773. )
  774. fi
  775. fi
  776. # workaround for bug 413429
  777. tc-export CC CXX
  778. if multilib_native_use cuda; then
  779. cuda_add_sandbox -w
  780. addwrite "/proc/self/task"
  781. if ! test -w /dev/nvidiactl; then
  782. # eqawarn "Can't access the GPU at /dev/nvidiactl."
  783. # eqawarn "User $(id -nu) is not in the group \"video\"."
  784. if [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then
  785. # build all targets
  786. mycmakeargs+=(
  787. -DCUDA_GENERATION=""
  788. )
  789. fi
  790. else
  791. local -x CUDAARCHS
  792. : "${CUDAARCHS:="$(cuda_get_host_native_arch)"}"
  793. fi
  794. local -x CUDAHOSTCXX CUDAHOSTLD
  795. CUDAHOSTCXX="$(cuda_get_host_compiler)"
  796. CUDAHOSTLD="$(tc-getCXX)"
  797. if tc-is-gcc; then
  798. # Filter out IMPLICIT_LINK_DIRECTORIES picked up by CMAKE_DETERMINE_COMPILER_ABI(CUDA)
  799. # See /usr/share/cmake/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst
  800. CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES_EXCLUDE=$(
  801. "${CUDAHOSTLD}" -E -v - <<<"int main(){}" |& \
  802. grep LIBRARY_PATH | cut -d '=' -f 2 | cut -d ':' -f 1
  803. )
  804. fi
  805. local NVCCFLAGS_OpenCV="${NVCCFLAGS// /\;}"
  806. mycmakeargs+=(
  807. -DENABLE_CUDA_FIRST_CLASS_LANGUAGE="yes"
  808. -DCUDA_NVCC_FLAGS="-forward-unknown-opts;-fno-lto;${NVCCFLAGS_OpenCV//\"/}"
  809. )
  810. fi
  811. if use ffmpeg; then
  812. mycmakeargs+=(
  813. -DOPENCV_GAPI_GSTREAMER="no"
  814. -DOPENCV_FFMPEG_DISABLE_MEDIASDK="yes"
  815. )
  816. fi
  817. # according to modules/java/jar/CMakeLists.txt:23-26
  818. if use java; then
  819. mycmakeargs+=(
  820. -DOPENCV_JAVA_SOURCE_VERSION="$(java-pkg_get-source)"
  821. -DOPENCV_JAVA_TARGET_VERSION="$(java-pkg_get-target)"
  822. )
  823. fi
  824. if use mkl; then
  825. mycmakeargs+=(
  826. -DLAPACK_IMPL="MKL"
  827. -DMKL_WITH_OPENMP="$(usex openmp)"
  828. -DMKL_WITH_TBB="$(usex tbb)"
  829. )
  830. fi
  831. # NOTE set this via MYCMAKEARGS if needed
  832. if use opencl; then
  833. if has_version sci-libs/clfft; then
  834. mycmakeargs+=( -DWITH_OPENCLAMDFFT="yes" )
  835. else
  836. mycmakeargs+=( -DWITH_OPENCLAMDFFT="no" )
  837. fi
  838. if has_version sci-libs/clblas; then
  839. mycmakeargs+=( -DWITH_OPENCLAMDBLAS="yes" )
  840. else
  841. mycmakeargs+=( -DWITH_OPENCLAMDBLAS="no" )
  842. fi
  843. else
  844. mycmakeargs+=(
  845. -DWITH_OPENCLAMDFFT="no"
  846. -DWITH_OPENCLAMDBLAS="no"
  847. )
  848. fi
  849. # NOTE due to multilib we can't do
  850. # if multilib_native_use test; then
  851. if use test; then
  852. # opencv tests assume to be build in Release mode
  853. local -x CMAKE_BUILD_TYPE="Release"
  854. mycmakeargs+=(
  855. -DOPENCV_TEST_DATA_PATH="${WORKDIR}/${PN}_extra-${PV}/testdata"
  856. )
  857. if use vtk; then
  858. mycmakeargs+=(
  859. -DVTK_MPI_NUMPROCS="$(makeopts_jobs)" # TODO
  860. )
  861. fi
  862. fi
  863. if multilib_native_use testprograms; then
  864. # NOTE do this so testprograms do not fail
  865. mycmakeargs+=(
  866. -DOPENCV_TEST_INSTALL_PATH="libexec/${PN}/bin/test"
  867. )
  868. fi
  869. if multilib_native_use python; then
  870. python_configure() {
  871. # Set all python variables to load the correct Gentoo paths
  872. local mycmakeargs=(
  873. "${mycmakeargs[@]}"
  874. # python_setup alters PATH and sets this as wrapper
  875. # to the correct interpreter we are building for
  876. -DBUILD_opencv_python3="yes"
  877. -DBUILD_opencv_python_bindings_generator="yes"
  878. -DBUILD_opencv_python_tests="$(usex test)"
  879. -DPYTHON_DEFAULT_EXECUTABLE="${EPYTHON}"
  880. -DINSTALL_PYTHON_EXAMPLES="$(usex examples)"
  881. -DBUILD_NEW_PYTHON_SUPPORT="ON"
  882. )
  883. cmake_src_configure
  884. }
  885. python_foreach_impl python_configure
  886. else
  887. mycmakeargs+=(
  888. -DPYTHON_EXECUTABLE="no"
  889. -DINSTALL_PYTHON_EXAMPLES="no"
  890. -DBUILD_opencv_python2="no"
  891. -DBUILD_opencv_python3="no"
  892. -DBUILD_opencv_python_bindings_generator="no"
  893. -DBUILD_opencv_python_tests="no"
  894. )
  895. cmake_src_configure
  896. fi
  897. }
  898. multilib_src_compile() {
  899. if multilib_native_use python; then
  900. python_foreach_impl cmake_src_compile
  901. else
  902. cmake_src_compile
  903. fi
  904. }
  905. multilib_src_test() {
  906. # no tests on ABI_X86_32
  907. ! multilib_is_native_abi && return
  908. # NOTE we don't run the tests
  909. use testprograms && return
  910. declare -xA OPENCV_SKIP_TESTS
  911. local -x OPENCV_SKIP_TESTS_core=(
  912. 'hal_intrin128.*32x4_CPP_EMULATOR'
  913. 'hal_intrin128.*64x2_CPP_EMULATOR'
  914. )
  915. local -x OPENCV_SKIP_TESTS_gapi=(
  916. 'AsyncAPICancelation/cancel/*.basic'
  917. )
  918. local -x OPENCV_SKIP_TESTS_videoio=(
  919. '*mfx*'
  920. 'videoio/videoio_bunny.frame_count/12'
  921. )
  922. local -x OPENCV_SKIP_TESTS_video=(
  923. 'GOTURN.accuracy'
  924. 'DaSiamRPN.accuracy'
  925. 'NanoTrack.accuracy_NanoTrack_V1'
  926. 'NanoTrack.accuracy_NanoTrack_V2'
  927. 'Tracking/DistanceAndOverlap.GOTURN*'
  928. )
  929. if ! use gtk3 && ! use qt6; then
  930. local -x OPENCV_SKIP_TESTS_highgui=(
  931. 'Highgui_GUI.*'
  932. )
  933. else
  934. addpredict /dev/fuse
  935. fi
  936. if multilib_native_use cuda; then
  937. local -x OPENCV_SKIP_TESTS_cudaoptflow=(
  938. 'CUDA_OptFlow/BroxOpticalFlow.Regression/0'
  939. 'CUDA_OptFlow/BroxOpticalFlow.OpticalFlowNan/0'
  940. 'CUDA_OptFlow/NvidiaOpticalFlow_1_0.Regression/0'
  941. 'CUDA_OptFlow/NvidiaOpticalFlow_2_0.Regression/0'
  942. )
  943. if use opengl; then
  944. local -x OPENCV_SKIP_TESTS_cudaarithm=(
  945. 'OpenGL/Buffer.MapDevice/*'
  946. 'OpenGL/*Gpu*'
  947. )
  948. fi
  949. fi
  950. if use contribdnn; then
  951. local -x OPENCV_SKIP_TESTS_dnn=(
  952. 'Test_ONNX_layers.LSTM_cell_forward/*'
  953. 'Test_ONNX_layers.LSTM_cell_bidirectional/*'
  954. 'Test_TensorFlow_layers.Convolution3D/*'
  955. 'Test_TensorFlow_layers.concat_3d/*'
  956. )
  957. local -x OPENCV_SKIP_TESTS_objdetect=(
  958. 'Objdetect_face_detection.regression'
  959. 'Objdetect_face_recognition.regression' 'Objdetect_QRCode_Encode_Decode_Structured_Append.regression'
  960. )
  961. else
  962. local -x OPENCV_SKIP_TESTS_objdetect=(
  963. 'Objdetect_face_detection.regression'
  964. 'Objdetect_face_recognition.regression'
  965. )
  966. OPENCV_SKIP_TESTS_video+=(
  967. 'vittrack.accuracy_vittrack'
  968. )
  969. fi
  970. if use dnnsamples; then
  971. local -x OPENCV_SKIP_TESTS_wechat_qrcode=(
  972. 'Objdetect_QRCode_points_position.rotate45'
  973. 'Objdetect_QRCode_Big.regression'
  974. 'Objdetect_QRCode_Tiny.regression'
  975. 'Objdetect_QRCode_Multi.regression/*'
  976. 'Objdetect_QRCode_Easy_Multi.regression/1'
  977. )
  978. fi
  979. if multilib_native_use cuda; then
  980. if ! SANDBOX_WRITE=/dev/nvidiactl test -w /dev/nvidiactl ; then
  981. eerror "Can't access the GPU at /dev/nvidiactl."
  982. eerror "User $(id -nu) is not in the group \"video\"."
  983. local -x TEST_CUDA="false"
  984. # local -x OPENCV_PARALLEL_BACKEND="threads"
  985. # local -x DNN_BACKEND_OPENCV="cuda"
  986. local -x OPENCV_SKIP_TESTS_photo=( "CUDA_*" )
  987. local -x OPENCV_SKIP_TESTS_stitching=( "CUDA_*" )
  988. OPENCV_SKIP_TESTS_video+=( "CUDA_*" )
  989. else
  990. cuda_add_sandbox -w
  991. addwrite "/dev/dri/"
  992. [[ -e /dev/udmabuf ]] && addwrite /dev/udmabuf
  993. fi
  994. fi
  995. opencv_test() {
  996. cd "${BUILD_DIR}" || die
  997. # directories to search for _core_ plugins
  998. local -x OPENCV_CORE_PLUGIN_PATH="${BUILD_DIR}/lib"
  999. # directories to search for _dnn_ plugins
  1000. local -x OPENCV_DNN_PLUGIN_PATH="${BUILD_DIR}/lib"
  1001. # directories to search for _videoio_ plugins
  1002. local -x OPENCV_VIDEOIO_PLUGIN_PATH="${BUILD_DIR}/lib"
  1003. # # path to extra OpenVINO plugins
  1004. # local -x OPENCV_DNN_IE_EXTRA_PLUGIN_PATH="${BUILD_DIR}/lib"
  1005. local -x OPENCV_TEMP_PATH="${T}"
  1006. local -x OPENCV_TEST_DATA_PATH="${WORKDIR}/${PN}_extra-${PV}/testdata"
  1007. local test_opts_base=(
  1008. --skip_unstable=1
  1009. --test_threads="$(makeopts_jobs)"
  1010. )
  1011. local results=()
  1012. local tests
  1013. readarray -t tests <<< "$(find "${BUILD_DIR}/bin" -name 'opencv_test_*')"
  1014. for test in "${tests[@]}" ; do
  1015. if [[ ${TEST_CUDA} == "false" && ${test} = *opencv_test_cu* ]] ; then
  1016. eqawarn "Skipping test ${test}"
  1017. continue
  1018. fi
  1019. local test_opts=(
  1020. --gtest_color=yes
  1021. --gtest_output="json:${BUILD_DIR}/test-reports/$(basename "${test}").json"
  1022. )
  1023. local testname
  1024. testname="OPENCV_SKIP_TESTS_$(basename "${test//opencv_test_/}")[*]"
  1025. if [[ -n "${!testname}" ]]; then
  1026. test_opts+=(
  1027. --gtest_filter="-$(IFS=':'; echo "${!testname}")"
  1028. )
  1029. fi
  1030. einfo "${test} ${test_opts_base[*]} ${test_opts[*]}"
  1031. if ! "${test}" "${test_opts_base[@]}" "${test_opts[@]}"; then
  1032. results+=( "$(basename "${test}")" )
  1033. if [[ -z "${OPENCV_TEST_CONTINUE_ON_FAIL}" ]]; then
  1034. eerror "${results[*]} failed"
  1035. die
  1036. fi
  1037. fi
  1038. done
  1039. if [[ -n "${results[*]}" ]]; then
  1040. eerror "failed: ${results[*]}"
  1041. die "${results[*]}"
  1042. fi
  1043. }
  1044. if multilib_native_use python; then
  1045. python_foreach_impl virtx opencv_test
  1046. else
  1047. virtx opencv_test
  1048. fi
  1049. }
  1050. multilib_src_install() {
  1051. if use abi_x86_64 && use abi_x86_32; then
  1052. MULTILIB_WRAPPED_HEADERS=( # {{{
  1053. # [opencv4]
  1054. /usr/include/opencv4/opencv2/cvconfig.h
  1055. /usr/include/opencv4/opencv2/opencv_modules.hpp
  1056. /usr/include/opencv4/opencv2/core_detect.hpp
  1057. /usr/include/opencv4/opencv2/cudaarithm.hpp
  1058. /usr/include/opencv4/opencv2/cudabgsegm.hpp
  1059. /usr/include/opencv4/opencv2/cudacodec.hpp
  1060. /usr/include/opencv4/opencv2/cudafeatures2d.hpp
  1061. /usr/include/opencv4/opencv2/cudafilters.hpp
  1062. /usr/include/opencv4/opencv2/cudaimgproc.hpp
  1063. /usr/include/opencv4/opencv2/cudalegacy.hpp
  1064. /usr/include/opencv4/opencv2/cudalegacy/NCV.hpp
  1065. /usr/include/opencv4/opencv2/cudalegacy/NCVBroxOpticalFlow.hpp
  1066. /usr/include/opencv4/opencv2/cudalegacy/NCVHaarObjectDetection.hpp
  1067. /usr/include/opencv4/opencv2/cudalegacy/NCVPyramid.hpp
  1068. /usr/include/opencv4/opencv2/cudalegacy/NPP_staging.hpp
  1069. /usr/include/opencv4/opencv2/cudaobjdetect.hpp
  1070. /usr/include/opencv4/opencv2/cudaoptflow.hpp
  1071. /usr/include/opencv4/opencv2/cudastereo.hpp
  1072. /usr/include/opencv4/opencv2/cudawarping.hpp
  1073. # [cudev]
  1074. /usr/include/opencv4/opencv2/cudev.hpp
  1075. /usr/include/opencv4/opencv2/cudev/block/block.hpp
  1076. /usr/include/opencv4/opencv2/cudev/block/detail/reduce.hpp
  1077. /usr/include/opencv4/opencv2/cudev/block/detail/reduce_key_val.hpp
  1078. /usr/include/opencv4/opencv2/cudev/block/dynamic_smem.hpp
  1079. /usr/include/opencv4/opencv2/cudev/block/reduce.hpp
  1080. /usr/include/opencv4/opencv2/cudev/block/scan.hpp
  1081. /usr/include/opencv4/opencv2/cudev/block/vec_distance.hpp
  1082. /usr/include/opencv4/opencv2/cudev/common.hpp
  1083. /usr/include/opencv4/opencv2/cudev/expr/binary_func.hpp
  1084. /usr/include/opencv4/opencv2/cudev/expr/binary_op.hpp
  1085. /usr/include/opencv4/opencv2/cudev/expr/color.hpp
  1086. /usr/include/opencv4/opencv2/cudev/expr/deriv.hpp
  1087. /usr/include/opencv4/opencv2/cudev/expr/expr.hpp
  1088. /usr/include/opencv4/opencv2/cudev/expr/per_element_func.hpp
  1089. /usr/include/opencv4/opencv2/cudev/expr/reduction.hpp
  1090. /usr/include/opencv4/opencv2/cudev/expr/unary_func.hpp
  1091. /usr/include/opencv4/opencv2/cudev/expr/unary_op.hpp
  1092. /usr/include/opencv4/opencv2/cudev/expr/warping.hpp
  1093. /usr/include/opencv4/opencv2/cudev/functional/color_cvt.hpp
  1094. /usr/include/opencv4/opencv2/cudev/functional/detail/color_cvt.hpp
  1095. /usr/include/opencv4/opencv2/cudev/functional/functional.hpp
  1096. /usr/include/opencv4/opencv2/cudev/functional/tuple_adapter.hpp
  1097. /usr/include/opencv4/opencv2/cudev/grid/copy.hpp
  1098. /usr/include/opencv4/opencv2/cudev/grid/detail/copy.hpp
  1099. /usr/include/opencv4/opencv2/cudev/grid/detail/histogram.hpp
  1100. /usr/include/opencv4/opencv2/cudev/grid/detail/integral.hpp
  1101. /usr/include/opencv4/opencv2/cudev/grid/detail/minmaxloc.hpp
  1102. /usr/include/opencv4/opencv2/cudev/grid/detail/pyr_down.hpp
  1103. /usr/include/opencv4/opencv2/cudev/grid/detail/pyr_up.hpp
  1104. /usr/include/opencv4/opencv2/cudev/grid/detail/reduce.hpp
  1105. /usr/include/opencv4/opencv2/cudev/grid/detail/reduce_to_column.hpp
  1106. /usr/include/opencv4/opencv2/cudev/grid/detail/reduce_to_row.hpp
  1107. /usr/include/opencv4/opencv2/cudev/grid/detail/split_merge.hpp
  1108. /usr/include/opencv4/opencv2/cudev/grid/detail/transform.hpp
  1109. /usr/include/opencv4/opencv2/cudev/grid/detail/transpose.hpp
  1110. /usr/include/opencv4/opencv2/cudev/grid/histogram.hpp
  1111. /usr/include/opencv4/opencv2/cudev/grid/integral.hpp
  1112. /usr/include/opencv4/opencv2/cudev/grid/pyramids.hpp
  1113. /usr/include/opencv4/opencv2/cudev/grid/reduce.hpp
  1114. /usr/include/opencv4/opencv2/cudev/grid/reduce_to_vec.hpp
  1115. /usr/include/opencv4/opencv2/cudev/grid/split_merge.hpp
  1116. /usr/include/opencv4/opencv2/cudev/grid/transform.hpp
  1117. /usr/include/opencv4/opencv2/cudev/grid/transpose.hpp
  1118. /usr/include/opencv4/opencv2/cudev/ptr2d/constant.hpp
  1119. /usr/include/opencv4/opencv2/cudev/ptr2d/deriv.hpp
  1120. /usr/include/opencv4/opencv2/cudev/ptr2d/detail/gpumat.hpp
  1121. /usr/include/opencv4/opencv2/cudev/ptr2d/extrapolation.hpp
  1122. /usr/include/opencv4/opencv2/cudev/ptr2d/glob.hpp
  1123. /usr/include/opencv4/opencv2/cudev/ptr2d/gpumat.hpp
  1124. /usr/include/opencv4/opencv2/cudev/ptr2d/interpolation.hpp
  1125. /usr/include/opencv4/opencv2/cudev/ptr2d/lut.hpp
  1126. /usr/include/opencv4/opencv2/cudev/ptr2d/mask.hpp
  1127. /usr/include/opencv4/opencv2/cudev/ptr2d/remap.hpp
  1128. /usr/include/opencv4/opencv2/cudev/ptr2d/resize.hpp
  1129. /usr/include/opencv4/opencv2/cudev/ptr2d/texture.hpp
  1130. /usr/include/opencv4/opencv2/cudev/ptr2d/traits.hpp
  1131. /usr/include/opencv4/opencv2/cudev/ptr2d/transform.hpp
  1132. /usr/include/opencv4/opencv2/cudev/ptr2d/warping.hpp
  1133. /usr/include/opencv4/opencv2/cudev/ptr2d/zip.hpp
  1134. /usr/include/opencv4/opencv2/cudev/util/atomic.hpp
  1135. /usr/include/opencv4/opencv2/cudev/util/detail/tuple.hpp
  1136. /usr/include/opencv4/opencv2/cudev/util/detail/type_traits.hpp
  1137. /usr/include/opencv4/opencv2/cudev/util/limits.hpp
  1138. /usr/include/opencv4/opencv2/cudev/util/saturate_cast.hpp
  1139. /usr/include/opencv4/opencv2/cudev/util/simd_functions.hpp
  1140. /usr/include/opencv4/opencv2/cudev/util/tuple.hpp
  1141. /usr/include/opencv4/opencv2/cudev/util/type_traits.hpp
  1142. /usr/include/opencv4/opencv2/cudev/util/vec_math.hpp
  1143. /usr/include/opencv4/opencv2/cudev/util/vec_traits.hpp
  1144. /usr/include/opencv4/opencv2/cudev/warp/detail/reduce.hpp
  1145. /usr/include/opencv4/opencv2/cudev/warp/detail/reduce_key_val.hpp
  1146. /usr/include/opencv4/opencv2/cudev/warp/reduce.hpp
  1147. /usr/include/opencv4/opencv2/cudev/warp/scan.hpp
  1148. /usr/include/opencv4/opencv2/cudev/warp/shuffle.hpp
  1149. /usr/include/opencv4/opencv2/cudev/warp/warp.hpp
  1150. # [contribcvv]
  1151. /usr/include/opencv4/opencv2/cvv.hpp
  1152. /usr/include/opencv4/opencv2/cvv/call_meta_data.hpp
  1153. /usr/include/opencv4/opencv2/cvv/cvv.hpp
  1154. /usr/include/opencv4/opencv2/cvv/debug_mode.hpp
  1155. /usr/include/opencv4/opencv2/cvv/dmatch.hpp
  1156. /usr/include/opencv4/opencv2/cvv/filter.hpp
  1157. /usr/include/opencv4/opencv2/cvv/final_show.hpp
  1158. /usr/include/opencv4/opencv2/cvv/show_image.hpp
  1159. # [contribdnn]
  1160. /usr/include/opencv4/opencv2/dnn.hpp
  1161. /usr/include/opencv4/opencv2/dnn/all_layers.hpp
  1162. /usr/include/opencv4/opencv2/dnn/dict.hpp
  1163. /usr/include/opencv4/opencv2/dnn/dnn.hpp
  1164. /usr/include/opencv4/opencv2/dnn/dnn.inl.hpp
  1165. /usr/include/opencv4/opencv2/dnn/layer.details.hpp
  1166. /usr/include/opencv4/opencv2/dnn/layer.hpp
  1167. /usr/include/opencv4/opencv2/dnn/shape_utils.hpp
  1168. /usr/include/opencv4/opencv2/dnn/utils/debug_utils.hpp
  1169. /usr/include/opencv4/opencv2/dnn/utils/inference_engine.hpp
  1170. /usr/include/opencv4/opencv2/dnn/version.hpp
  1171. /usr/include/opencv4/opencv2/dnn_superres.hpp
  1172. # [contribhdf]
  1173. /usr/include/opencv4/opencv2/hdf.hpp
  1174. /usr/include/opencv4/opencv2/hdf/hdf5.hpp
  1175. /usr/include/opencv4/opencv2/mcc.hpp
  1176. /usr/include/opencv4/opencv2/mcc/ccm.hpp
  1177. /usr/include/opencv4/opencv2/mcc/checker_detector.hpp
  1178. /usr/include/opencv4/opencv2/mcc/checker_model.hpp
  1179. /usr/include/opencv4/opencv2/text.hpp
  1180. /usr/include/opencv4/opencv2/text/erfilter.hpp
  1181. /usr/include/opencv4/opencv2/text/ocr.hpp
  1182. /usr/include/opencv4/opencv2/text/swt_text_detection.hpp
  1183. /usr/include/opencv4/opencv2/text/textDetector.hpp
  1184. # [qt6]
  1185. /usr/include/opencv4/opencv2/viz.hpp
  1186. /usr/include/opencv4/opencv2/viz/types.hpp
  1187. /usr/include/opencv4/opencv2/viz/viz3d.hpp
  1188. /usr/include/opencv4/opencv2/viz/vizcore.hpp
  1189. /usr/include/opencv4/opencv2/viz/widget_accessor.hpp
  1190. /usr/include/opencv4/opencv2/viz/widgets.hpp
  1191. /usr/include/opencv4/opencv2/wechat_qrcode.hpp
  1192. ) # }}}
  1193. fi
  1194. if multilib_native_use python; then
  1195. python_foreach_impl cmake_src_install
  1196. python_foreach_impl python_optimize
  1197. else
  1198. cmake_src_install
  1199. fi
  1200. for plugin in "${ED}/usr/$(get_libdir)/libopencv_"*".$(ver_rs 1-2 '' "$(ver_cut 1-2)").${ARCH}"* ; do
  1201. patchelf --set-soname "$(basename "${plugin}" ".$(get_libname)")" "${plugin}"
  1202. done
  1203. }