Giter Site home page Giter Site logo

vietanhdev / facecam Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 6.0 168.96 MB

Funny camera app with face decorators like Snapchat. This project uses face detection and alignment algorithms from OpenCV.

License: MIT License

CMake 3.41% C++ 96.59%
machine-learning camera snapchat computer-vision face-decorator camera-app cpp snap-chat

facecam's Introduction

FaceCam - Funny Camera

A camera desktop application with funny face decorations and filters.

This application is built to try face detection and alignment algorithms in an interesting way.

Supported Operating Systems: Currently, we only support Windows and Ubuntu operation system. However, you can also try to build it for other linux distribution and macOS.

Screenshot:

Screenshot

I. DEVELOPMENT ENVIRONMENT AND BUILD

Requirements:

  • CMake >= 3.10
  • Qt 5
  • OpenCV >= 4.0.1
  • C++ 17 compiler

Setup for Linux - Ubuntu 18.04

Setup

  • Install QT:
sudo apt-get install build-essential
sudo apt-get install qtcreator
sudo apt-get install qt5-default
sudo apt-get install qt5-doc
sudo apt-get install qt5-doc-html qtbase5-doc-html
sudo apt-get install qtbase5-examples
sudo /sbin/ldconfig -v
  • Install OpenCV
https://linuxize.com/post/how-to-install-opencv-on-ubuntu-18-04/
  • Install SDL2 lib
sudo apt-get install libsdl2-dev

Compile and Run

  • Compile
cd <project directory>
mkdir build
cd build
cmake ..
make
  • Run
./FaceCam

Setup for Windows 10

Setup

NOTE: You need to correct following paths correctly as your installation.

  • Visual Studio 2017

  • Install CMake for Windows: https://cmake.org/download/

  • Install Gitbash (Optional)

  • Install QT: Download and install from this link: https://www.qt.io/download

    • Add QT to PATH: C:\Qt\5.12.1\msvc2017_64\bin\

    • Add some environment variables: QT_DIR=C:\Qt\5.12.1\msvc2017_64 QT_QPA_PLATFORM_PLUGIN_PATH=C:\Qt\5.12.1\msvc2017_64\plugins\platforms\

  • Compile and install OpenCV 4

    • Add OPENCV_DIR=C:\OpenCV\x64\vc15\staticlib
  • Install SDL Lib and add it to PATH: https://trenki2.github.io/blog/2017/06/02/using-sdl2-with-cmake/

    • Download the development package SDL2-devel-2.0.5-VC.zip and extract it to some location on your hard disk
    • Set SDL2_DIR to the location where you extracted the SDL2 development package.
    • Create a file sdl2-config.cmake where you extracted the development libraries with following content:
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")
# Support both 32 and 64 bit builds
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
  set(SDL2_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2main.lib")
else ()
  set(SDL2_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2main.lib")
endif ()

string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
  • Restart the computer.

Compile and Run

  • Use PowerShell:
cd <project directory>
mkdir build-win
cd build-win
cmake -G "Visual Studio 15 2017 Win64" ..
  • Open build-win\FaceCam.sln with Visual Studio 2017.

  • Set FaceCam as StartUp project. (Right click FaceCam project > Set as StartUp project)

  • Right click FaceCam project > Properties > Configuration Properties > C/C++ > Code Generation > Set Runtime Library to Multi-threaded (/MT). You need to check this option again after changing the build mode (debug/release).

  • Set Working Directory in Debugging to TargetDir: Right click FaceCam project > Properties > Configuration Properties > Debugging > Set Working Directory to $(TargetDir).

  • Build project with Visual Studio 2017.

  • Deploy QT dlls:

    • For Release Build
    cd build-win\Release
    windeployqt.exe --release FaceCam.exe
    
    • For Debug Build
    cd build-win\Debug
    windeployqt.exe --debug FaceCam.exe
    
  • NOTE:

    • If you build with Release mode, cd build-win\Release.
    • Only after you run windeployqt.exe .\FaceCam.exe successfully, you can run the excutable file FaceCam.exe.

II. NOTE FOR DEVELOPERS

Bug of QString::fromStdString()

  • To convert std::string to QString, the following way causes an error on Windows:
QString::fromStdString(string_to_convert);

Instead, Use QString::fromUtf8 like this:

QString::fromUtf8(string_to_convert.c_str());

III. REFERENCES / CITE

facecam's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

facecam's Issues

Building on Arch Linux: fatal error: SDL.h: No such file or directory

This is what I am getting when trying to build on Arch Linux:

$ make
[  1%] Automatic MOC and UIC for target STATIC
[  1%] Built target STATIC_autogen
Consolidate compiler generated dependencies of target STATIC
[  2%] Built target STATIC
[  3%] Automatic MOC and UIC for target FaceCam
[  3%] Built target FaceCam_autogen
[  3%] Building CXX object CMakeFiles/FaceCam.dir/FaceCam_autogen/mocs_compilation.cpp.o
In file included from /home/jose/tmp/facecam/build/FaceCam_autogen/MXUWEOXILK/moc_mainwindow.cpp:10,
                 from /home/jose/tmp/facecam/build/FaceCam_autogen/mocs_compilation.cpp:5:
/home/jose/tmp/facecam/build/FaceCam_autogen/MXUWEOXILK/../../../src/gui/mainwindow.h:14:10: fatal error: SDL.h: No such file or directory
   14 | #include <SDL.h>
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/FaceCam.dir/build.make:127: CMakeFiles/FaceCam.dir/FaceCam_autogen/mocs_compilation.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: CMakeFiles/FaceCam.dir/all] Error 2

Undefined reference when linking on Ubuntu 20.04

Building facecam on Ubuntu 20.04:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal
$ make
Scanning dependencies of target STATIC_autogen
[  1%] Automatic MOC and UIC for target STATIC
[  1%] Built target STATIC_autogen
Scanning dependencies of target STATIC
[  1%] Building CXX object CMakeFiles/STATIC.dir/STATIC_autogen/mocs_compilation.cpp.o
[  2%] Linking CXX static library libSTATIC.a
[  2%] Built target STATIC
Scanning dependencies of target FaceCam_autogen
[  3%] Automatic MOC and UIC for target FaceCam
[  3%] Built target FaceCam_autogen
[  4%] Automatic RCC for src/gui/darkstyle.qrc
[  4%] Automatic RCC for resources.qrc
[  5%] Automatic RCC for src/gui/framelesswindow.qrc
Scanning dependencies of target FaceCam
[  5%] Building CXX object CMakeFiles/FaceCam.dir/FaceCam_autogen/mocs_compilation.cpp.o
[  6%] Building CXX object CMakeFiles/FaceCam.dir/src/main.cpp.o
..
..
[ 35%] Building CXX object CMakeFiles/FaceCam.dir/FaceCam_autogen/MXUWEOXILK/qrc_darkstyle.cpp.o
[ 36%] Linking CXX executable bin/FaceCam
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `ml_cam::FileStorage::initStorage()':
file_storage.cpp:(.text+0x637): undefined reference to `std::experimental::filesystem::v1::create_directories(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: file_storage.cpp:(.text+0x84b): undefined reference to `std::experimental::filesystem::v1::create_directories(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNSt12experimental10filesystem2v17__cxx114pathC5EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x50): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::clear()':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114path5clearEv[_ZNSt12experimental10filesystem2v17__cxx114path5clearEv]+0x24): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::_M_append(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114path9_M_appendERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNSt12experimental10filesystem2v17__cxx114path9_M_appendERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0xb6): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::exists(std::experimental::filesystem::v1::__cxx11::path const&)':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v16existsERKNS1_7__cxx114pathE[_ZNSt12experimental10filesystem2v16existsERKNS1_7__cxx114pathE]+0x18): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::is_directory(std::experimental::filesystem::v1::__cxx11::path const&)':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v112is_directoryERKNS1_7__cxx114pathE[_ZNSt12experimental10filesystem2v112is_directoryERKNS1_7__cxx114pathE]+0x18): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<char [8], std::experimental::filesystem::v1::__cxx11::path>(char const (&) [8])':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2IA8_cS3_EERKT_[_ZNSt12experimental10filesystem2v17__cxx114pathC5IA8_cS3_EERKT_]+0x6e): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/file_storage.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<char [7], std::experimental::filesystem::v1::__cxx11::path>(char const (&) [7])':
file_storage.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2IA7_cS3_EERKT_[_ZNSt12experimental10filesystem2v17__cxx114pathC5IA7_cS3_EERKT_]+0x6e): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_detector/face_detector_cascade.cpp.o: in function `FaceDetectorCascade::FaceDetectorCascade(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
face_detector_cascade.cpp:(.text+0xab): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_detector_cascade.cpp:(.text+0xe1): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_detector/face_detector_cascade.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
face_detector_cascade.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT_[_ZNSt12experimental10filesystem2v17__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT_]+0x74): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_detector/face_detector_ssd_resnet10.cpp.o: in function `FaceDetectorSSDResNet10::FaceDetectorSSDResNet10()':
face_detector_ssd_resnet10.cpp:(.text+0x163): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_detector_ssd_resnet10.cpp:(.text+0x19d): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: face_detector_ssd_resnet10.cpp:(.text+0x1c4): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_detector_ssd_resnet10.cpp:(.text+0x1fe): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_landmark_detector/face_landmark_detector_kazemi.cpp.o: in function `FaceLandmarkDetectorKazemi::FaceLandmarkDetectorKazemi()':
face_landmark_detector_kazemi.cpp:(.text+0x123): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_landmark_detector_kazemi.cpp:(.text+0x15d): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_landmark_detector/face_landmark_detector_lbf.cpp.o: in function `FaceLandmarkDetectorLBF::FaceLandmarkDetectorLBF()':
face_landmark_detector_lbf.cpp:(.text+0x12f): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_landmark_detector_lbf.cpp:(.text+0x16c): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_landmark_detector/face_landmark_detector_syan_cnn.cpp.o: in function `FaceLandmarkDetectorSyanCNN::FaceLandmarkDetectorSyanCNN()':
face_landmark_detector_syan_cnn.cpp:(.text+0x101): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_landmark_detector_syan_cnn.cpp:(.text+0x13b): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/face_landmark_detector/face_landmark_detector_syan_cnn_2.cpp.o: in function `FaceLandmarkDetectorSyanCNN2::FaceLandmarkDetectorSyanCNN2()':
face_landmark_detector_syan_cnn_2.cpp:(.text+0x1a7): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_landmark_detector_syan_cnn_2.cpp:(.text+0x1e1): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: face_landmark_detector_syan_cnn_2.cpp:(.text+0x208): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: face_landmark_detector_syan_cnn_2.cpp:(.text+0x242): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/FaceCam.dir/src/effects/animation.cpp.o: in function `Animation::addFrame(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
animation.cpp:(.text+0xc1): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: animation.cpp:(.text+0xf7): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/FaceCam.dir/build.make:846: bin/FaceCam] Error 1
make[1]: *** [CMakeFiles/Makefile2:128: CMakeFiles/FaceCam.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.