cu-ecen-aeld / final-project-abbottwhitley

final-project-abbottwhitley created by GitHub Classroom
0 stars 0 forks source link

(Client) Incorporate OpenCV Face detection with BuildRoot Build #8

Closed abbottwhitley closed 3 years ago

abbottwhitley commented 3 years ago

Incorporate OpenCV Facedetection into BuildRoot Build. OpenCV provides sample C++ Face detection source code. https://github.com/opencv/opencv/blob/master/samples/cpp/facedetect.cpp

Update Buildroot config, add package, and configure *.mk files to build facedetect.cpp and load the application into the final build.

DoD: Ability to run Facedetection application on RPI that successfully captures an image from a video stream and identifies the face within the image.

abbottwhitley commented 3 years ago

Having trouble pointing Buildroot at the appropriate source files and libraries for linking. facedetection.cpp requires the following C++ header files. Buildroot can't seem to find objdetect.hpp. Confirmed this was included in menuconfig

#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>

image image

From the output of the build the build fails because the first header (opencv2/objdetect.hpp) can't be found. I'm including the pkg-config --cflags opencv call as a compiler flag in my make file but that doesn't seem to work (or I don't have Buildroot environment variables setup properly to allow this to work as needed). Searching for this header file within the Buildroot build directory, I can see that Buildroot downloaded and installed the required file (see screen shot).

image

I've also gone as far as adding the following lines to the make file to explicitly direct Buildroot to the various header files. I don't love this because it feels like I'm not using the tools as they're intended to be used, but as a trouble shooting step it resulted in moderate success....

VPATH = -I../../opencv3-3.4.13
VPATH += -I../../opencv3-3.4.13/buildroot-build/unix-install
VPATH += -I../../opencv3-3.4.13/modules/objdetect/include/
VPATH += -I../../opencv3-3.4.13/modules/core/include/
VPATH += -I../../opencv3-3.4.13/buildroot-build/
VPATH += -I../../opencv3-3.4.13/modules/highgui/include/
VPATH += -I../../opencv3-3.4.13/modules/imgcodecs/include/                                     
VPATH += -I../../opencv3-3.4.13/modules/videoio/include/
VPATH += -I../../opencv3-3.4.13/modules/imgproc/include/
abbottwhitley commented 3 years ago

Possible solution: Use CMake

http://lists.busybox.net/pipermail/buildroot/2016-June/163039.html This thread recommends building using CMAKE.

abbottwhitley commented 3 years ago

Unsure what exactly fixed the issue other than a clean / rebuild. Buildroot now succesfully compiles and loads the openCV face detect application. Reference this commit if future issues come up: https://github.com/cu-ecen-5013/final-project-abbottwhitley/commit/dcd29c9d68c565227afc2d06e304b9c037ae1802

abbottwhitley commented 3 years ago

Additional errors:

abbottwhitley commented 3 years ago

Enabled libgtk2 by adding the BR2_PACKAGE_XORG7 dependency in menuconfig. All other dependencies were already set.

Target packages → Graphic libraries and applications → X.org

Verified dependencies from from libgtk2/Config.in

config BR2_PACKAGE_LIBGTK2 |  
-- | --
  | bool "libgtk2"
  | depends on BR2_PACKAGE_XORG7 
  | depends on BR2_USE_WCHAR # glib2
  | depends on BR2_TOOLCHAIN_HAS_THREADS # glib2
  | depends on BR2_USE_MMU # glib2
  | depends on BR2_INSTALL_LIBSTDCPP # pango
  | depends on BR2_TOOLCHAIN_HAS_SYNC_4 # pango ->   harfbuzz
  | depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # pango ->   harfbuzz
  | select BR2_PACKAGE_ATK
  | select BR2_PACKAGE_CAIRO
  | select BR2_PACKAGE_CAIRO_PS
  | select BR2_PACKAGE_CAIRO_PDF
  | select BR2_PACKAGE_CAIRO_SVG
  | select BR2_PACKAGE_LIBGLIB2
  | select BR2_PACKAGE_PANGO
  | select BR2_PACKAGE_GDK_PIXBUF
  | select BR2_PACKAGE_FONTCONFIG
  | select BR2_PACKAGE_XLIB_LIBX11
  | select BR2_PACKAGE_XLIB_LIBXEXT
  | select BR2_PACKAGE_XLIB_LIBXRENDER
abbottwhitley commented 3 years ago

Current issue when building.... cairo-xlib >= 1.6 requirement not met

checking for BASE_DEPENDENCIES... yes
checking for BASE_DEPENDENCIES... yes
checking for CAIRO_BACKEND... no
configure: error: Package requirements (cairo-xlib >= 1.6) were not met:

Package 'cairo-xlib', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CAIRO_BACKEND_CFLAGS
and CAIRO_BACKEND_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
package/pkg-generic.mk:231: recipe for target '/home/abbottjc/CU_Boulder/FINAL/final-project-abbottwhitley/buildroot/output/build/libgtk2-2.24.33/.stamp_configured' failed
make[1]: *** [/home/abbottjc/CU_Boulder/FINAL/final-project-abbottwhitley/buildroot/output/build/libgtk2-2.24.33/.stamp_configured] Error 1
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2
make: Leaving directory '/home/abbottjc/CU_Boulder/FINAL/final-project-abbottwhitley/buildroot'
abbottwhitley commented 3 years ago

Fixed with make distclean

Reference this Git Commit