ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.33k stars 3.05k forks source link

error: use of undeclared identifier 'facedetect_cnn' #337

Closed rajhlinux closed 2 years ago

rajhlinux commented 2 years ago

PC info: OS: FreeBSD 13.1-RELEASE-p1 amd64 Resolution: 3840x2160 DE: Plasma 5.24.6 WM: KWin Theme: [Plasma], Breeze [GTK2/3] Icons: [Plasma], breeze-dark [GTK2/3] Terminal: dolphin CPU: AMD FX-8350 (8) @ 3.991GHz GPU: Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] Memory: 7781MiB / 32684MiB

using clang++: clang++ -v -g /home/user/libfacedetection/example/detect-camera.cpp -o /home/user/libfacedetection/example/detect-camera $(pkg-config --cflags --libs opencv4) -I /usr/local/include/opencv4/

Error:

/home/user/libfacedetection/example/detect-camera.cpp:97:24: error: use of undeclared identifier 'facedetect_cnn'
            pResults = facedetect_cnn(pBuffer, (unsigned char*)(image.ptr(0)), image.cols, image.rows, (int)image.step);

What could be the issue?

Also will this project work with CPU that have AVX and not AVX2?

Thanks.

fengyuentau commented 2 years ago

Please, use CMake to build this project. https://github.com/ShiqiYu/libfacedetection/blob/master/CMakeLists.txt

rajhlinux commented 2 years ago

Hello fengyuentau, Thanks for your reply. I will try that.

Also my CPU does not have AVX2 (it does have AVX), should it work regardless?

Edit:

I was able to compile the examples using cmake.

However, I get this error when trying the "detect-image-demo":

$ ./detect-image-demo face.jpg 
Illegal instruction (core dumped)

Also when running the "detect-camera-demo", nothing happens:

$ ./detect-camera-demo /dev/video4
$ 

For "benchmark" demo:

$ ./benchmark face.jpg 
There are 8 threads, 8 processors.
Illegal instruction (core dumped)

I compiled "AVX2" OFF and the "detect-camera-demo" worked well:

$ ./detect-image-demo face.jpg 

time = 4260.43ms
6 faces detected.
face 0: confidence=99, [980, 847, 39, 48] (995,864) (1011,865) (1004,873) (994,880) (1008,881)
face 1: confidence=99, [873, 864, 20, 25] (879,873) (887,874) (884,878) (880,882) (887,882)
face 2: confidence=99, [373, 864, 28, 36] (377,876) (388,877) (379,883) (378,890) (386,891)
face 3: confidence=49, [452, 554, 16, 19] (457,560) (464,560) (461,564) (458,568) (464,568)
face 4: confidence=29, [421, 551, 16, 19] (424,557) (431,557) (428,561) (425,565) (431,565)
face 5: confidence=25, [1358, 362, 8, 9] (1360,365) (1363,365) (1361,367) (1360,369) (1363,369)

It's really amazing how the program is able to output programmatically of the face quantity detected.

However running the "detect-camera-demo", nothing happens with "AVX2" OFF compiled:

$ ./detect-camera-demo /dev/video4
$ 

"benchmark" demo seem to work with "AVX2" OFF compiled::

$ ./benchmark face.jpg 
There is 1 thread.

Thanks.

fengyuentau commented 2 years ago

Also when running the "detect-camera-demo", nothing happens:

$ ./detect-camera-demo /dev/video4

I think the parameter should be the number of the webcam on your pc (start from 0). See following lines from detect-camera.cpp:

https://github.com/ShiqiYu/libfacedetection/blob/14abaa7b171e18c7450d1778bf22dddf03c53a32/example/detect-camera.cpp#L69-L77

rajhlinux commented 2 years ago

Hello fengyuentau, thanks for the reply.

Thank You very much, I got it running now, using: $ ./detect-camera-demo 4

screenshot

Are there any ways I can implement this code on OpenCL or AMD GPU? Is there any manual for using the library?

Thanks.

fengyuentau commented 2 years ago

Are there any ways I can implement this code on OpenCL or AMD GPU?

You need to do this yourself, or try OpenCV which comes with OpenCL support. Simply set the corresponding backend (cv.dnn.DNN_BACKEND_DEFAULT) and target (cv.dnn.DNN_TARGET_OPENCL): https://github.com/ShiqiYu/libfacedetection/blob/14abaa7b171e18c7450d1778bf22dddf03c53a32/opencv_dnn/python/detect.py#L38-L46

Is there any manual for using the library?

There is a section in compile.md on the usage: https://github.com/ShiqiYu/libfacedetection/blob/master/COMPILE.md#usage

rajhlinux commented 2 years ago

Thanks for the reply, will look into it.

I installed dlib and now get errors when running the same executable for "detect-camera-demo":

It threw an error about: "libopencv_gapi.so.405" not found which is required by detect-camera-demo

So I deleted everything and recompiled again and now get core dump error:

$ ./detect-camera-demo 4

[ WARN:0@0.326] global /wrkdirs/usr/ports/graphics/opencv/work/opencv-4.6.0/modules/videoio/src/cap_gstreamer.cpp (1405) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
time = 2892.56ms
2 faces detected.
face 0: confidence=84, [184, 451, 30, 36] (190,464) (201,464) (193,471) (191,477) (199,477)
face 1: confidence=29, [454, 411, 136, 136] (523,479) (544,485) (536,503) (519,510) (535,515)
Abort trap (core dumped)

Thanks.

rajhlinux commented 2 years ago

Alright, I figured out what caused the issue. It seems that I can run the compiled binaries again if I completely remove OpenCV 4.5 which was installed on my PC or compile to the latest version of OpenCV 4.6 which will not conflict when running the compiled binaries.

Thanks.