Bug 2007780

Summary: Add DNN support in opencv
Product: Red Hat Enterprise Linux 8 Reporter: Troy Dawson <tdawson>
Component: opencvAssignee: Jiri Kucera <jkucera>
Status: CLOSED ERRATA QA Contact: Evgeny Fedin <efedin>
Severity: unspecified Docs Contact: Šárka Jana <sjanderk>
Priority: unspecified    
Version: 8.6CC: databases-maint, efedin, jharuda, jkucera, ovasik, sjanderk
Target Milestone: rcKeywords: Triaged
Target Release: 8.6Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: opencv-3.4.6-7.el8 Doc Type: Enhancement
Doc Text:
.The `dnn` and `text` modules are available in the `opencv` package The `dnn` module containing Deep Neural Networks for image classification inference and the `text` module for scene text detection and recognition are now available in the `opencv` package.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 14:29:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1991296    
Deadline: 2021-12-06   

Description Troy Dawson 2021-09-24 20:32:49 UTC
Description of problem:
There are no dnn libraries in the RHEL8 version of opencv.
DNN (Deep Neural Networks) is one of the libraries of opencv.

It's not that the libraries weren't built for RHEL8, but they are removed after being built, due to dependency issues.
As of RHEL 8.5 (or possibly 8.6), all of the dependencies will now be in RHEL8.

Please rebuild opencv again for RHEL8, without removing the dnn libraries.

Version-Release number of selected component (if applicable):
opencv-3.4.6-6.el8

How reproducible:
100%

Steps to Reproduce:
1. mock -r epel-next-8-x86_64 --rebuild digikam-7.2.0-4.fc34.src.rpm
2.
3.

Actual results:
Fails with:

-- Could NOT find OpenCV (missing: dnn) (found version "3.4.6")
CMake Warning at core/cmake/modules/MacroOpenCV.cmake:22 (find_package):


Expected results:
It should find the dnn libraries and build correctly.

Additional info:
digikam uses the dnn library to do facial recognition.
We've tried building it without dnn and facial recognition, but it is considered a core library, and pretty much everything else fails without it.

Comment 1 Troy Dawson 2021-09-24 20:52:29 UTC
The following creates a same version opencv for RHEL8, but with the dnn libraries available.

diff --git a/opencv.spec b/opencv.spec
index d58e256..5459688 100644
--- a/opencv.spec
+++ b/opencv.spec
@@ -54,7 +54,7 @@
 
 Name:           opencv
 Version:        3.4.6
-Release:        6%{?dist}
+Release:        7%{?dist}
 Summary:        Collection of algorithms for computer vision
 # This is normal three clause BSD.
 License:        BSD
@@ -212,16 +212,9 @@ to provide decent performance and stability.
 %setup -q -a1
 # we don't use pre-built contribs
 rm -r 3rdparty/
-# missing dependecies for dnn module in Fedora (protobuf-cpp)
-rm -r modules/dnn/
 
 %patch1 -p1 -b .install_3rdparty_licenses
 
-pushd %{name}_contrib-%{version}
-# missing dependecies for dnn_modern module in Fedora (tiny-dnn)
-#rm -r modules/dnn_modern/
-popd
-
 # fix dos end of lines
 #sed -i 's|\r||g'  samples/c/adaptiveskindetector.cpp
 
@@ -323,6 +316,7 @@ popd
 %{_datadir}/licenses/opencv3/
 %{_libdir}/libopencv_calib3d.so.%{abiver}*
 %{_libdir}/libopencv_core.so.%{abiver}*
+%{_libdir}/libopencv_dnn.so.%%{abiver}*
 %{_libdir}/libopencv_features2d.so.%{abiver}*
 %{_libdir}/libopencv_flann.so.%{abiver}*
 %{_libdir}/libopencv_highgui.so.%{abiver}*
@@ -359,8 +353,7 @@ popd
 %{_libdir}/libopencv_ccalib.so.%{abiver}*
 %{_libdir}/libopencv_cvv.so.%{abiver}*
 %{_libdir}/libopencv_datasets.so.%{abiver}*
-# Disabled because of missing dependency package in fedora (protobuf-cpp)
-#{_libdir}/libopencv_dnn.so.%%{abiver}*
+%{_libdir}/libopencv_dnn_objdetect.so.%%{abiver}*
 %{_libdir}/libopencv_dpm.so.%{abiver}*
 %{_libdir}/libopencv_face.so.%{abiver}*
 %{_libdir}/libopencv_freetype.so.%{abiver}*
@@ -377,8 +370,7 @@ popd
 %{_libdir}/libopencv_stereo.so.%{abiver}*
 %{_libdir}/libopencv_structured_light.so.%{abiver}*
 %{_libdir}/libopencv_surface_matching.so.%{abiver}*
-#Module opencv_text disabled because opencv_dnn dependency can't be resolved!
-#{_libdir}/libopencv_text.so.%%{abiver}*
+%{_libdir}/libopencv_text.so.%%{abiver}*
 %{_libdir}/libopencv_tracking.so.%{abiver}*
 %{_libdir}/libopencv_ximgproc.so.%{abiver}*
 %{_libdir}/libopencv_xobjdetect.so.%{abiver}*

Comment 13 Troy Dawson 2022-03-15 14:40:57 UTC
I have successfully build digikam with the new opencv in epel8-next (which uses centos stream 8 as it's buildroot).
So this is successful.
I realize that this will not be fully released until RHEL 8.6, but I am glad that I am able to test it now.
Thank you very much.

Comment 16 errata-xmlrpc 2022-05-10 14:29:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (opencv bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:1958