Bug Summary

File:/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp
Warning:line 143, column 39
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple aarch64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name dnnfacedetectoryolo.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/home/gilles/Devel/8.x/build.scan/core/libs/facesengine -fcoverage-compilation-dir=/home/gilles/Devel/8.x/build.scan/core/libs/facesengine -resource-dir /usr/lib/llvm-18/lib/clang/18 -D BUILDING_XMPCOMPAREANDMERGE_AS_STATIC=1 -D BUILDING_XMPCOMPAREANDMERGE_LIB=1 -D BanAllEntityUsage=1 -D CMS_NO_REGISTER_KEYWORD=1 -D EnablePluginManager=0 -D HAVE_FFMPEG_VERSION5 -D LIBPGF_DISABLE_OPENMP -D LINKING_XMPCORE_LIB=1 -D MAGICKCORE_HDRI_ENABLE=0 -D MAGICKCORE_QUANTUM_DEPTH=16 -D QT_DEPRECATED_WARNINGS -D QT_DEPRECATED_WARNINGS_SINCE=0x060000 -D QT_DISABLE_DEPRECATED_BEFORE=0x050E00 -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_FROM_BYTEARRAY -D QT_NO_CAST_TO_ASCII -D QT_NO_FOREACH -D QT_NO_KEYWORDS -D QT_NO_NARROWING_CONVERSIONS_IN_CONNECT -D QT_NO_URL_CAST_FROM_STRING -D QT_STRICT_ITERATORS -D QT_USE_QSTRINGBUILDER -D TRANSLATION_DOMAIN="digikam" -D UNIX_ENV=1 -D USE_JASPER -D USE_JPEG -D USE_JPEG8 -D XMP_COMPONENT_INT_NAMESPACE=AdobeXMPCompareAndMerge_Int -D XMP_StaticBuild=1 -D _GNU_SOURCE -D _LARGEFILE64_SOURCE -D digikamcore_EXPORTS -D qDNGDebug=0 -D qDNGLittleEndian=1 -D qDNGThreadSafe=1 -D qDNGUseLibJPEG=1 -D qDNGUseStdInt=1 -D qDNGUseXMP=1 -D qDNGValidateTarget=1 -D qDNGXMPDocOps=0 -D qDNGXMPFiles=0 -D qLinux=1 -D qMacOS=0 -D qWinOS=0 -I /home/gilles/Devel/8.x/build.scan/core/libs/facesengine -I /home/gilles/Devel/8.x/core/libs/facesengine -I /home/gilles/Devel/8.x/build.scan/core/libs/facesengine/core_digikamfacesengine_obj_autogen/include -I /home/gilles/Devel/8.x/core/libs/video/player/qtmm -I /home/gilles/Devel/8.x/core/libs/album/engine -I /home/gilles/Devel/8.x/core/libs/album/manager -I /home/gilles/Devel/8.x/core/libs/album/treeview -I /home/gilles/Devel/8.x/core/libs/album/widgets -I /home/gilles/Devel/8.x/core/libs/database/collection -I /home/gilles/Devel/8.x/core/libs/database/coredb -I /home/gilles/Devel/8.x/core/libs/database/dbjobs -I /home/gilles/Devel/8.x/core/libs/database/engine -I /home/gilles/Devel/8.x/core/libs/database/haar -I /home/gilles/Devel/8.x/core/libs/database/history -I /home/gilles/Devel/8.x/core/libs/database/item/containers -I /home/gilles/Devel/8.x/core/libs/database/item/lister -I /home/gilles/Devel/8.x/core/libs/database/item/query -I /home/gilles/Devel/8.x/core/libs/database/item/scanner -I /home/gilles/Devel/8.x/core/libs/database/models -I /home/gilles/Devel/8.x/core/libs/database/server -I /home/gilles/Devel/8.x/core/libs/database/similaritydb -I /home/gilles/Devel/8.x/core/libs/database/tags -I /home/gilles/Devel/8.x/core/libs/database/thumbsdb -I /home/gilles/Devel/8.x/core/libs/database/utils/ifaces -I /home/gilles/Devel/8.x/core/libs/database/utils/scan -I /home/gilles/Devel/8.x/core/libs/database/utils/widgets -I /home/gilles/Devel/8.x/core/libs/dialogs -I /home/gilles/Devel/8.x/core/libs/dimg/color -I /home/gilles/Devel/8.x/core/libs/dimg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/auto -I /home/gilles/Devel/8.x/core/libs/dimg/filters/bcg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/bw -I /home/gilles/Devel/8.x/core/libs/dimg/filters/cb -I /home/gilles/Devel/8.x/core/libs/dimg/filters/curves -I /home/gilles/Devel/8.x/core/libs/dimg/filters/decorate -I /home/gilles/Devel/8.x/core/libs/dimg/filters -I /home/gilles/Devel/8.x/core/libs/dimg/filters/film -I /home/gilles/Devel/8.x/core/libs/dimg/filters/fx -I /home/gilles/Devel/8.x/core/libs/dimg/filters/greycstoration/cimg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/greycstoration -I /home/gilles/Devel/8.x/core/libs/dimg/filters/hotpixels -I /home/gilles/Devel/8.x/core/libs/dimg/filters/hsl -I /home/gilles/Devel/8.x/core/libs/dimg/filters/icc -I /home/gilles/Devel/8.x/core/libs/dimg/filters/lc -I /home/gilles/Devel/8.x/core/libs/dimg/filters/lens -I /home/gilles/Devel/8.x/core/libs/dimg/filters/levels -I /home/gilles/Devel/8.x/core/libs/dimg/filters/nr -I /home/gilles/Devel/8.x/core/libs/dimg/filters/raw -I /home/gilles/Devel/8.x/core/libs/dimg/filters/redeye -I /home/gilles/Devel/8.x/core/libs/dimg/filters/sharp -I /home/gilles/Devel/8.x/core/libs/dimg/filters/transform -I /home/gilles/Devel/8.x/core/libs/dimg/filters/wb -I /home/gilles/Devel/8.x/core/libs/dimg/history -I /home/gilles/Devel/8.x/core/libs/dimg/loaders -I /home/gilles/Devel/8.x/core/libs/dngwriter -I /home/gilles/Devel/8.x/core/libs/dnnmodelmanager -I /home/gilles/Devel/8.x/core/libs/dplugins/core -I /home/gilles/Devel/8.x/core/libs/dplugins/iface -I /home/gilles/Devel/8.x/core/libs/dplugins/setup -I /home/gilles/Devel/8.x/core/libs/dplugins/webservices -I /home/gilles/Devel/8.x/core/libs/dplugins/widgets -I /home/gilles/Devel/8.x/core/libs/dragdrop -I /home/gilles/Devel/8.x/core/libs/dtrash -I /home/gilles/Devel/8.x/core/libs/facesengine/common -I /home/gilles/Devel/8.x/core/libs/facesengine/detection -I /home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn -I /home/gilles/Devel/8.x/core/libs/facesengine/facedb -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing/recognition -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing/shape-predictor -I /home/gilles/Devel/8.x/core/libs/facesengine/recognition -I /home/gilles/Devel/8.x/core/libs/facesengine/recognition/opencv-dnn -I /home/gilles/Devel/8.x/core/libs/fileactionmanager -I /home/gilles/Devel/8.x/core/libs/filters -I /home/gilles/Devel/8.x/core/libs/imgqsort/detectors -I /home/gilles/Devel/8.x/core/libs/imgqsort -I /home/gilles/Devel/8.x/core/libs/iojobs -I /home/gilles/Devel/8.x/core/libs/jpegutils -I /home/gilles/Devel/8.x/core/libs/metadataengine/containers -I /home/gilles/Devel/8.x/core/libs/metadataengine/dmetadata -I /home/gilles/Devel/8.x/core/libs/metadataengine/engine -I /home/gilles/Devel/8.x/core/libs/metadataengine/exiftool -I /home/gilles/Devel/8.x/core/libs/metadataengine/focuspoint -I /home/gilles/Devel/8.x/core/libs/models -I /home/gilles/Devel/8.x/core/libs/networkmanager -I /home/gilles/Devel/8.x/core/libs/notificationmanager -I /home/gilles/Devel/8.x/core/libs/onlineversion -I /home/gilles/Devel/8.x/core/libs/pgfutils -I /home/gilles/Devel/8.x/core/libs/progressmanager -I /home/gilles/Devel/8.x/core/libs/properties/captions -I /home/gilles/Devel/8.x/core/libs/properties/geolocation -I /home/gilles/Devel/8.x/core/libs/properties/history -I /home/gilles/Devel/8.x/core/libs/properties/import -I /home/gilles/Devel/8.x/core/libs/properties -I /home/gilles/Devel/8.x/core/libs/rawengine -I /home/gilles/Devel/8.x/core/libs/settings -I /home/gilles/Devel/8.x/core/libs/tags/autoassignment -I /home/gilles/Devel/8.x/core/libs/tags/autoassignment/model -I /home/gilles/Devel/8.x/core/libs/tags/engine -I /home/gilles/Devel/8.x/core/libs/tags/manager/models -I /home/gilles/Devel/8.x/core/libs/tags/manager -I /home/gilles/Devel/8.x/core/libs/tags/widgets -I /home/gilles/Devel/8.x/core/libs/template -I /home/gilles/Devel/8.x/core/libs/threadimageio/engine -I /home/gilles/Devel/8.x/core/libs/threadimageio/fileio -I /home/gilles/Devel/8.x/core/libs/threadimageio/preview -I /home/gilles/Devel/8.x/core/libs/threadimageio/thumb -I /home/gilles/Devel/8.x/core/libs/threadimageio/video -I /home/gilles/Devel/8.x/core/libs/threads -I /home/gilles/Devel/8.x/core/libs/timeadjust -I /home/gilles/Devel/8.x/core/libs/transitionmngr -I /home/gilles/Devel/8.x/core/libs/versionmanager -I /home/gilles/Devel/8.x/core/libs/video -I /home/gilles/Devel/8.x/core/libs/video/manager -I /home/gilles/Devel/8.x/core/libs/video/osd -I /home/gilles/Devel/8.x/core/libs/video/player -I /home/gilles/Devel/8.x/core/libs/widgets/colors -I /home/gilles/Devel/8.x/core/libs/widgets/combo -I /home/gilles/Devel/8.x/core/libs/widgets/files -I /home/gilles/Devel/8.x/core/libs/widgets/fonts -I /home/gilles/Devel/8.x/core/libs/widgets/graphicsview -I /home/gilles/Devel/8.x/core/libs/widgets/history -I /home/gilles/Devel/8.x/core/libs/widgets/iccprofiles -I /home/gilles/Devel/8.x/core/libs/widgets/itemview -I /home/gilles/Devel/8.x/core/libs/widgets/layout -I /home/gilles/Devel/8.x/core/libs/widgets/mainview -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/config -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/exiftool -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/exiv2 -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/labels -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/utils -I /home/gilles/Devel/8.x/core/libs/widgets/range -I /home/gilles/Devel/8.x/core/libs/widgets/text -I /home/gilles/Devel/8.x/core/libs/jpegutils/libjpeg/84 -I /home/gilles/Devel/8.x/core/app/utils -I /home/gilles/Devel/8.x/build.scan/core/app/utils -I /home/gilles/Devel/8.x/core/utilities/advancedrename -I /home/gilles/Devel/8.x/core/utilities/advancedrename/common -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/modifiers -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options/database -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options/database/keys -I /home/gilles/Devel/8.x/core/utilities/extrasupport/addressbook -I /home/gilles/Devel/8.x/core/utilities/extrasupport/filesindexer -I /home/gilles/Devel/8.x/core/utilities/facemanagement/bench -I /home/gilles/Devel/8.x/core/utilities/facemanagement/database -I /home/gilles/Devel/8.x/core/utilities/facemanagement/dialogs -I /home/gilles/Devel/8.x/core/utilities/facemanagement/items -I /home/gilles/Devel/8.x/core/utilities/facemanagement/threads -I /home/gilles/Devel/8.x/core/utilities/facemanagement/widgets -I /home/gilles/Devel/8.x/core/utilities/facemanagement/workers -I /home/gilles/Devel/8.x/core/utilities/firstrun -I /home/gilles/Devel/8.x/core/utilities/focuspointmanagement -I /home/gilles/Devel/8.x/core/utilities/fuzzysearch -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/astro -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/blendings -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/core -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/data -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/graphicsitem -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/handlers/dgml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/handlers/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/parser -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/scene -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writer -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writers/dgml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writers/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/graphicsview -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/layers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/models -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/osm -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/atmosphere -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/compass -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/crosshairs -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/graticule -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/mapscale -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/measure -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/navigation -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/overviewmap -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/progress -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/cache -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpsbabel -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpx -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpx/handlers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/json -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/nominatim-reversegeocoding -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/o5mreader -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/translators -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/writers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/pn2 -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/pnt -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/projections -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/runners -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/settings -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/storage -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/tile -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/backends -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/bookmark -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/core -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/correlator -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/dragdrop -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/items -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/lookup -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/reversegeocoding -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/tiles -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/tracks -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/widgets -I /home/gilles/Devel/8.x/core/utilities/geolocation/geomapwrapper -I /home/gilles/Devel/8.x/core/utilities/geolocation/mapsearches -I /home/gilles/Devel/8.x/core/utilities/imageeditor/core -I /home/gilles/Devel/8.x/core/utilities/imageeditor/dialogs -I /home/gilles/Devel/8.x/core/utilities/imageeditor/editor -I /home/gilles/Devel/8.x/core/utilities/imageeditor/main -I /home/gilles/Devel/8.x/core/utilities/imageeditor/widgets -I /home/gilles/Devel/8.x/core/utilities/import/backend -I /home/gilles/Devel/8.x/core/utilities/import/dialogs -I /home/gilles/Devel/8.x/core/utilities/import/items -I /home/gilles/Devel/8.x/core/utilities/import/main -I /home/gilles/Devel/8.x/core/utilities/import/models -I /home/gilles/Devel/8.x/core/utilities/import/views -I /home/gilles/Devel/8.x/core/utilities/import/widgets -I /home/gilles/Devel/8.x/core/utilities/lighttable -I /home/gilles/Devel/8.x/core/utilities/maintenance/main -I /home/gilles/Devel/8.x/core/utilities/maintenance/manager -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/autotags -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/dbcleaner -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/dbscan -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/duplicates -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/facesmanagement -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/fingerprints -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/imgqsort -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/metaremover -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/metasync -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/thumbs -I /home/gilles/Devel/8.x/core/utilities/maintenance/utils -I /home/gilles/Devel/8.x/core/utilities/queuemanager/dplugins -I /home/gilles/Devel/8.x/core/utilities/queuemanager/main -I /home/gilles/Devel/8.x/core/utilities/queuemanager/manager -I /home/gilles/Devel/8.x/core/utilities/queuemanager/views -I /home/gilles/Devel/8.x/core/utilities/searchwindow -I /home/gilles/Devel/8.x/core/utilities/setup/album -I /home/gilles/Devel/8.x/core/utilities/setup/camera -I /home/gilles/Devel/8.x/core/utilities/setup/collections -I /home/gilles/Devel/8.x/core/utilities/setup/downloader -I /home/gilles/Devel/8.x/core/utilities/setup/editor -I /home/gilles/Devel/8.x/core/utilities/setup/metadata -I /home/gilles/Devel/8.x/core/utilities/setup/misc -I /home/gilles/Devel/8.x/core/utilities/setup -I /home/gilles/Devel/8.x/core/app/main -I /home/gilles/Devel/8.x/core/app/date -I /home/gilles/Devel/8.x/core/app/dragdrop -I /home/gilles/Devel/8.x/core/app/views/stack -I /home/gilles/Devel/8.x/core/app/views/utils -I /home/gilles/Devel/8.x/core/app/items/utils -I /home/gilles/Devel/8.x/core/app/items/delegate -I /home/gilles/Devel/8.x/core/app/views/sidebar -I /usr/include/opencv4 -I /usr/include/ImageMagick-6 -I /usr/include/aarch64-linux-gnu/ImageMagick-6 -I /opt/qt6/include/QtMultimedia -I /opt/qt6/include -I /opt/qt6/include/QtCore -I /opt/qt6/mkspecs/linux-g++ -I /opt/qt6/include/QtGui -I /opt/qt6/include/QtNetwork -I /opt/qt6/include/QtMultimediaWidgets -I /opt/qt6/include/QtWidgets -I /opt/qt6/include/QtXml -I /opt/qt6/include/QtSql -I /opt/qt6/include/QtConcurrent -I /opt/qt6/include/KF6/KConfig -I /opt/qt6/include/KF6/KConfigCore -I /opt/qt6/include/KF6/KI18n -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/aarch64-linux-gnu/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-long-long -Wno-deprecated-copy -std=c++20 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -fno-operator-names -fopenmp -fno-signed-char -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -analyzer-output=html -target-feature +outline-atomics -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /mnt/data/Devel/8.x/project/reports/report.scan/2024-11-03-085830-479945-1 -x c++ /home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp
1/* ============================================================
2 *
3 * This file is a part of digiKam
4 *
5 * Date : 2019-08-08
6 * Description : Derived class to perform YOLO neural network inference
7 * for face detection. Credit: Ayoosh Kathuria (for Yolov3 blog post),
8 * sthanhng (for example of face detection with Yolov3).
9 * More information with Yolov3:
10 * https://towardsdatascience.com/yolo-v3-object-detection-53fb7d3bfe6b
11 * sthanhng github on face detection with Yolov3:
12 * https://github.com/sthanhng/yoloface
13 *
14 * SPDX-FileCopyrightText: 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
15 * SPDX-FileCopyrightText: 2020-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
16 *
17 * SPDX-License-Identifier: GPL-2.0-or-later
18 *
19 * ============================================================ */
20
21#include "dnnfacedetectoryolo.h"
22
23// Qt includes
24
25#include <QList>
26#include <QRect>
27#include <QString>
28#include <QFileInfo>
29#include <QMutexLocker>
30#include <QElapsedTimer>
31#include <QStandardPaths>
32
33// Local includes
34
35#include "digikam_debug.h"
36#include "digikam_config.h"
37#include "dnnmodelnet.h"
38#include "dnnmodelmanager.h"
39
40namespace Digikam
41{
42
43DNNFaceDetectorYOLO::DNNFaceDetectorYOLO()
44 : DNNFaceDetectorBase(1.0F / 255.0F,
45 cv::Scalar(0.0, 0.0, 0.0),
46 cv::Size(416, 416))
47{
48 loadModels();
49}
50
51bool DNNFaceDetectorYOLO::loadModels()
52{
53 model = DNNModelManager::instance()->getModel(QLatin1String("YOLOv3"), DNNModelUsage::DNNUsageFaceDetection);
54
55 if (model && !model->modelLoaded)
56 {
57 try
58 {
59 // NOTE: this will throw an exception if the model can't be loaded.
60
61 cv::dnn::Net net = static_cast<DNNModelNet*>(model)->getNet();
62
63 qCDebug(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 63, static_cast<const char *>(__PRETTY_FUNCTION__), qt_category
.name()).debug()
<< "YOLOv3 model:" << model->info.displayName
64 << ", YOLOv3 data:" << model->info.configName;
65 }
66 catch (cv::Exception& e)
67 {
68 qCWarning(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtWarningMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 68, static_cast<const char *>(__PRETTY_FUNCTION__), qt_category
.name()).warning()
<< "cv::Exception:" << e.what();
69
70 return false;
71 }
72 catch (...)
73 {
74 qCWarning(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtWarningMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 74, static_cast<const char *>(__PRETTY_FUNCTION__), qt_category
.name()).warning()
<< "Default exception from OpenCV";
75
76 return false;
77 }
78 }
79
80 if (model && model->modelLoaded)
81 {
82 qCDebug(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 82, static_cast<const char *>(__PRETTY_FUNCTION__), qt_category
.name()).debug()
<< "SSD model:" << model->info.displayName << "ready";
83 }
84 else
85 {
86 qCWarning(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtWarningMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 86, static_cast<const char *>(__PRETTY_FUNCTION__), qt_category
.name()).warning()
<< "Face detection model: YOLOv3 not loaded";
87 return false;
88 }
89
90 return true;
91}
92
93void DNNFaceDetectorYOLO::detectFaces(const cv::Mat& inputImage,
94 const cv::Size& paddedSize,
95 std::vector<cv::Rect>& detectedBboxes)
96{
97 QElapsedTimer timer;
98
99 if (inputImage.empty())
1
Assuming the condition is false
2
Taking false branch
100 {
101 qCDebug(DIGIKAM_FACESENGINE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACESENGINE_LOG)()); qt_category; qt_category.control
= false) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 101, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "Invalid image given, not detecting faces.";
102
103 return;
104 }
105
106 cv::Mat inputBlob = cv::dnn::blobFromImage(inputImage, scaleFactor, inputImageSize, meanValToSubtract, true, false);
107 std::vector<cv::Mat> outs;
108
109 if (model && !static_cast<DNNModelNet*>(model)->getNet().empty())
3
Assuming field 'model' is null
110 {
111 QMutexLocker lock(&(model->mutex));
112
113 static_cast<DNNModelNet*>(model)->getNet().setInput(inputBlob);
114 timer.start();
115 static_cast<DNNModelNet*>(model)->getNet().forward(outs, getOutputsNames());
116
117 qCDebug(DIGIKAM_FACESENGINE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACESENGINE_LOG)()); qt_category; qt_category.control
= false) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 117, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "forward YOLO detection in" << timer.elapsed() << "ms";
118 }
119 else
120 {
121 qCWarning(DIGIKAM_FACEDB_LOG)for (QLoggingCategoryMacroHolder<QtWarningMsg> qt_category
((DIGIKAM_FACEDB_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 121, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).warning()
<< "Face detection model: YOLOv3 not loaded. Processed 0 images.";
4
Loop condition is false. Execution continues on line 125
122 }
123
124
125 timer.start();
126
127 postprocess(outs, paddedSize, detectedBboxes);
5
Calling 'DNNFaceDetectorYOLO::postprocess'
128
129 qCDebug(DIGIKAM_FACESENGINE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACESENGINE_LOG)()); qt_category; qt_category.control
= false) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 129, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "postprocess YOLO detection in" << timer.elapsed() << "ms";
130}
131
132void DNNFaceDetectorYOLO::postprocess(const std::vector<cv::Mat>& outs,
133 const cv::Size& paddedSize,
134 std::vector<cv::Rect>& detectedBboxes) const
135{
136 std::vector<float> goodConfidences;
137 std::vector<float> doubtConfidences;
138 std::vector<float> confidences;
139 std::vector<cv::Rect> goodBoxes;
140 std::vector<cv::Rect> doubtBoxes;
141 std::vector<cv::Rect> boxes;
142
143 const float confidenceThreshold = model->getThreshold(uiConfidenceThreshold);
6
Called C++ object pointer is null
144
145 for (size_t i = 0 ; i < outs.size() ; ++i)
146 {
147 // Scan through all the bounding boxes output from the network and keep only the
148 // ones with high confidence scores. Assign the box's class label as the class
149 // with the highest score for the box.
150
151 float* data = reinterpret_cast<float*>(outs[i].data);
152
153 for (int j = 0 ; j < outs[i].rows ; ++j, data += outs[i].cols)
154 {
155 cv::Mat scores = outs[i].row(j).colRange(5, outs[i].cols);
156
157 // Get the value and location of the maximum score.
158
159 double confidence;
160 cv::minMaxLoc(scores, nullptr, &confidence, nullptr, nullptr);
161
162 if (confidence > confidenceThreshold)
163 {
164 int centerX = (int)(data[0] * inputImageSize.width);
165 int centerY = (int)(data[1] * inputImageSize.height);
166 int width = (int)(data[2] * inputImageSize.width);
167 int height = (int)(data[3] * inputImageSize.height);
168
169 int left = centerX - width / 2;
170 int right = centerX + width / 2;
171 int top = centerY - height / 2;
172 int bottom = centerY + height / 2;
173
174 selectBbox(paddedSize,
175 confidence,
176 left,
177 right,
178 top,
179 bottom,
180 goodConfidences,
181 goodBoxes,
182 doubtConfidences,
183 doubtBoxes);
184 }
185 }
186 }
187
188 qCDebug(DIGIKAM_FACESENGINE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACESENGINE_LOG)()); qt_category; qt_category.control
= false) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 188, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "nb of doubtbox = " << doubtBoxes.size();
189 qCDebug(DIGIKAM_FACESENGINE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_FACESENGINE_LOG)()); qt_category; qt_category.control
= false) QMessageLogger(static_cast<const char *>("/home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp"
), 189, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "nb of goodbox = " << goodBoxes.size();
190
191 if (goodBoxes.empty())
192 {
193 boxes = doubtBoxes;
194 confidences = doubtConfidences;
195 }
196 else
197 {
198 boxes = goodBoxes;
199 confidences = goodConfidences;
200 }
201
202 // Perform non maximum suppression to eliminate redundant overlapping boxes with lower confidences.
203
204 std::vector<int> indices;
205 cv::dnn::NMSBoxes(boxes, confidences, confidenceThreshold, nmsThreshold, indices);
206
207 // Get detected bounding boxes.
208
209 for (size_t i = 0 ; i < indices.size() ; ++i)
210 {
211 cv::Rect bbox = boxes[indices[i]];
212 correctBbox(bbox, paddedSize);
213 detectedBboxes.push_back(cv::Rect(bbox.x, bbox.y, bbox.width, bbox.height));
214 }
215}
216
217/**
218 * Get the names of the output layers.
219 */
220std::vector<cv::String> DNNFaceDetectorYOLO::getOutputsNames() const
221{
222 static std::vector<cv::String> names;
223
224 if (!static_cast<DNNModelNet*>(model)->getNet().empty() && names.empty())
225 {
226 // Get the indices of the output layers, i.e. the layers with unconnected outputs.
227
228 std::vector<int> outLayers = static_cast<DNNModelNet*>(model)->getNet().getUnconnectedOutLayers();
229
230 // Get the names of all the layers in the network.
231
232 std::vector<cv::String> layersNames = static_cast<DNNModelNet*>(model)->getNet().getLayerNames();
233
234 // Get the names of the output layers in names.
235
236 names.resize(outLayers.size());
237
238 for (size_t i = 0 ; i < outLayers.size() ; ++i)
239 {
240 names[i] = layersNames[outLayers[i] - 1];
241 }
242 }
243
244 return names;
245}
246
247} // namespace Digikam