Bug 507101 - OpenCV 4.12 exception and face classifier not working
Summary: OpenCV 4.12 exception and face classifier not working
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Recognition (other bugs)
Version First Reported In: 8.7.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-16 09:25 UTC by kevinpr
Modified: 2025-07-20 09:37 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 8.8.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kevinpr 2025-07-16 09:25:46 UTC
SUMMARY


STEPS TO REPRODUCE
1. Open DigiKam
2. Try to recognize and classify faces

OBSERVED RESULT
It detects the faces, but it can't classify it, it writes all as "Unrecognized" face

EXPECTED RESULT
Putting faces in their "people" tags

SOFTWARE/OS VERSIONS
Archlinux latest updates 16/July/2025
KDE Plasma Version: Not using KDE
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION
Error shows at start:
$ digikam
Fontconfig warning: using without calling FcInit()
digikam.facesengine: FaceClassifier::loadTrainingData: exception:  OpenCV(4.12.0) /usr/include/opencv4/opencv2/core/mat.inl.hpp:921: error: (-215:Assertion failed) (unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()) in function 'at'
Comment 1 Maik Qualmann 2025-07-16 09:28:07 UTC

*** This bug has been marked as a duplicate of bug 506663 ***
Comment 2 Maik Qualmann 2025-07-16 09:31:09 UTC
I cannot reproduce the exception on 3 Windows machines, nor on my development version of OpenSUSE Tumbleweed.

Please test whether the problem can be reproduced with our AppImage.

Maik
Comment 3 kevinpr 2025-07-16 10:36:11 UTC
(In reply to Maik Qualmann from comment #2)
> I cannot reproduce the exception on 3 Windows machines, nor on my
> development version of OpenSUSE Tumbleweed.
> 
> Please test whether the problem can be reproduced with our AppImage.
> 
> Maik

Hi
With the AppImage is working fine. Seems AppImage is using libOpenCV 4.11.0 also (As information shows it)
Comment 4 Maik Qualmann 2025-07-16 11:00:43 UTC
The exception must occur here, I think. In principle, the exception could only occur if there were no column in the training data array. Let's see...

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/facesengine/recognition/faceclassifier.cpp?ref_type=heads#L322

Maik
Comment 5 caulier.gilles 2025-07-16 11:27:35 UTC
Maik,

I plan to update OpenCV to 4.12 in all Bundles. I do it soon or i wait a little bit ?

Gilles
Comment 6 Maik Qualmann 2025-07-16 11:56:42 UTC
Hi Gilles,

I think we're still waiting for 4.12. I just noticed that Tumbleweed is also still on 4.11. It might be an API change in the cv::ml::TrainData class or a bug. I'll keep researching it.

Maik
Comment 7 Maik Qualmann 2025-07-16 12:21:23 UTC
Could be an explanation...

https://github.com/opencv/opencv/wiki/OpenCV-Change-Logs#updated-dnn-deep-learning-inference-module

Maik
Comment 8 Maik Qualmann 2025-07-16 16:31:30 UTC
Git commit afe5772bf982e95bdf312dd627031bf838564249 by Maik Qualmann.
Committed on 16/07/2025 at 16:29.
Pushed by mqualmann into branch 'master'.

try to fix exception with OpenCV-4.12
Related: bug 506663

M  +1    -1    core/libs/facesengine/recognition/faceclassifier.cpp

https://invent.kde.org/graphics/digikam/-/commit/afe5772bf982e95bdf312dd627031bf838564249
Comment 9 caulier.gilles 2025-07-19 20:04:31 UTC
kevinpr@jkanetwork.com 

The digiKam 8.8.0 pre-relelase AppImage have been rebuilt using last Qt 6.9.1,
OpenCV 4.12, and KDE framework 6.16.

https://files.kde.org/digikam/digiKam-8.8.0-20250719T191430-Qt6-x86-64.appimage.mirrorlist

Can you reproduce the problem with this version?

Best regards

Gilles Caulier
Comment 10 Malte Gerken 2025-07-19 21:08:53 UTC
I also experienced the bug on Arch Linux and have rebuilt the package locally with the patch by Maik applied. The issue is resolved by that, face recognition works again and there is also no more error on startup.

As that patch is most likely included in the latest AppImage I would assume that this also works, but have not tested it.
Comment 11 Maik Qualmann 2025-07-20 04:21:46 UTC
Thanks for the feedback on Arch Linux, I also confirm that AppImage works with OpenCV-4.12.

Maik
Comment 12 kevinpr 2025-07-20 09:20:32 UTC
(In reply to caulier.gilles from comment #9)
> kevinpr@jkanetwork.com 
> 
> The digiKam 8.8.0 pre-relelase AppImage have been rebuilt using last Qt
> 6.9.1,
> OpenCV 4.12, and KDE framework 6.16.
> 
> https://files.kde.org/digikam/digiKam-8.8.0-20250719T191430-Qt6-x86-64.
> appimage.mirrorlist
> 
> Can you reproduce the problem with this version?
> 
> Best regards
> 
> Gilles Caulier

Works for me also :)
Thanks to all
Comment 13 Malte Gerken 2025-07-20 09:37:58 UTC
The patch has been applied to the Arch Linux Package, so it is also fixed downstream. Thanks a lot to all involved.