Lots of undefined errors while building
Closed this issue · 3 comments
Hi,
Im getting lots of undefined errors while building this :-
g++ -Wall -fexceptions -pthread -O3 -I/usr/include/opencv4 -I/usr/local/include/paddle-lite -I/usr/local/include/ncnn -c /home/ns/Face-Mask-Detection-Jetson-Nano/mask_ultra.cpp -o obj/Release/mask_ultra.o
...........
g++ -L/usr/local/lib/ -L/usr/lib/ -o bin/Release/MaskUltra obj/Release/mask_ultra.o obj/Release/UltraFace.o -pthread -fopenmp -s /usr/local/lib/paddle-lite/libpaddle_api_light_bundled.a /usr/local/lib/ncnn/libncnn.a /usr/lib/aarch64-linux-gnu/libvulkan.so /usr/local/lib/ncnn/libglslang.a /usr/local/lib/ncnn/libOGLCompiler.a /usr/local/lib/ncnn/libOSDependent.a /usr/local/lib/ncnn/libSPIRV.a
obj/Release/mask_ultra.o: In function `cv::Mat::~Mat()':
mask_ultra.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x84): undefined reference to `cv::fastFree(void*)'
mask_ultra.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x94): undefined reference to `cv::Mat::deallocate()'
obj/Release/mask_ultra.o: In function `main':
mask_ultra.cpp:(.text.startup+0x10b8): undefined reference to `cv::String::allocate(unsigned long)'
mask_ultra.cpp:(.text.startup+0x10e8): undefined reference to `cv::VideoCapture::VideoCapture(cv::String const&)'
mask_ultra.cpp:(.text.startup+0x10f0): undefined reference to `cv::String::deallocate()'
mask_ultra.cpp:(.text.startup+0x10f8): undefined reference to `cv::VideoCapture::isOpened() const'
mask_ultra.cpp:(.text.startup+0x1128): undefined reference to `cv::VideoCapture::~VideoCapture()'
mask_ultra.cpp:(.text.startup+0x1200): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
mask_ultra.cpp:(.text.startup+0x1274): undefined reference to `cv::destroyAllWindows()'
mask_ultra.cpp:(.text.startup+0x1494): undefined reference to `cv::fastFree(void*)'
mask_ultra.cpp:(.text.startup+0x15ac): undefined reference to `cv::format(char const*, ...)'
mask_ultra.cpp:(.text.startup+0x15fc): undefined reference to `cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
mask_ultra.cpp:(.text.startup+0x1604): undefined reference to `cv::String::deallocate()'
mask_ultra.cpp:(.text.startup+0x1614): undefined reference to `cv::String::allocate(unsigned long)'
mask_ultra.cpp:(.text.startup+0x1658): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
mask_ultra.cpp:(.text.startup+0x1660): undefined reference to `cv::String::deallocate()'
mask_ultra.cpp:(.text.startup+0x1668): undefined reference to `cv::waitKey(int)'
mask_ultra.cpp:(.text.startup+0x16cc): undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Rect_<int> const&)'
mask_ultra.cpp:(.text.startup+0x1714): undefined reference to `cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)'
mask_ultra.cpp:(.text.startup+0x1744): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
mask_ultra.cpp:(.text.startup+0x1800): undefined reference to `cv::rectangle(cv::Mat&, cv::Rect_<int>, cv::Scalar_<double> const&, int, int, int)'
mask_ultra.cpp:(.text.startup+0x1874): undefined reference to `cv::fastFree(void*)'
mask_ultra.cpp:(.text.startup+0x18e8): undefined reference to `cv::fastFree(void*)'
mask_ultra.cpp:(.text.startup+0x1904): undefined reference to `cv::Mat::deallocate()'
mask_ultra.cpp:(.text.startup+0x1910): undefined reference to `cv::Mat::deallocate()'
mask_ultra.cpp:(.text.startup+0x1998): undefined reference to `cv::Mat::deallocate()'
mask_ultra.cpp:(.text.startup+0x19f4): undefined reference to `cv::String::deallocate()'
mask_ultra.cpp:(.text.startup+0x1a10): undefined reference to `cv::VideoCapture::~VideoCapture()'
mask_ultra.cpp:(.text.startup+0x1a98): undefined reference to `cv::String::deallocate()'
mask_ultra.cpp:(.text.startup+0x1ac0): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 11 second(s))
31 error(s), 2 warning(s) (0 minute(s), 11 second(s))
Somehow, during linking, OpenCV isn't called. That gives you all these errors, all started with cv::.
In Code::Blocks menu Project->Build Options, select the tab Linker settings. When the project is selected (not Debug or Release, but the top one called 'MaskUltra') on the left, you will see two fields. The most right must have the line pkg-config --libs --cflags opencv4
.
If so, check next if your OpenCV installation on your Jetson Nano has a OpenCV package installed by the next command:
$ pkg-config --cflags opencv4
If this command gives a blank, install OpenCV properly by using our guide https://qengineering.eu/install-opencv-4.5-on-jetson-nano.html.
Compare our building line with yours, and you will see the difference right away. Many references to OpenCV which are missing in your build.
g++ -L/usr/local/lib/ -L/usr/lib/ -o bin/Release/MaskUltra obj/Release/mask_ultra.o obj/Release/UltraFace.o -I/usr/include/opencv4/opencv -I/usr/include/opencv4 -lopencv_dnn -lopencv_gapi -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -pthread -fopenmp -s /usr/local/lib/paddle-lite/libpaddle_api_light_bundled.a /usr/local/lib/ncnn/libncnn.a /usr/lib/aarch64-linux-gnu/libvulkan.so /usr/local/lib/ncnn/libglslang.a /usr/local/lib/ncnn/libOGLCompiler.a /usr/local/lib/ncnn/libOSDependent.a /usr/local/lib/ncnn/libSPIRV.a
Solved after reinstalling opencv. The accuracy is somewhat low on webcam though. My opencv version is 3.3.1, is it hampering the accuracy ? Also Im getting around 12 fps on my Jetson Nano.
Also what are the benefits of compiling opencv with cuda support ? Does it speed up processing or what ?
Accuracy is a known problem for face-mask detection. Think of people with black beards, wearing masks with a print etc. The original network was trained with Chinese people wearing (mostly) simple white/blue masks.
Your OpenCV version does not influence the detection accuracy. This is only determined by the Paddle network.
Detection rate depends on the number of people in the picture. I've an average of 1.0/(0.03 + 0.01 x #Faces) on a Nano @ 1450 MHz.
OpenCV uses Cuda in several ways. In addition to the 'normal' CPU declaration, many routines also have a Cuda declaration that starts with cv::cuda::. For instance cv::cuda::HoughCirclesDetection. See OpenCV cuda for a overview. Once code properly it accelerates the application. Cuda support is also widely used in the OpenCV deep learning framework.