Qengineering / Face-Recognition-Jetson-Nano

Recognize 2000+ faces on your Jetson Nano with database auto-fill and anti-spoofing
https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html
BSD 3-Clause "New" or "Revised" License
110 stars 31 forks source link

Unable to combine mask detection with face recognition #1

Closed rsingh2083 closed 3 years ago

rsingh2083 commented 3 years ago

I tried copying mask-detection code into the face recognition to check whether or not it even starts but Im getting this error :-

[ 26%] Building CXX object CMakeFiles/mtcnn_facenet_cpp_tensorRT.dir/src/faceNet.cpp.o
/home/ns/mtcnn_facenet_cpp_tensorRT/src/faceNet.cpp:52:5: error: ‘Mconfig’ does not name a type
     Mconfig.set_model_from_file("mask_detector_opt2.nb");
     ^~~~~~~
/home/ns/mtcnn_facenet_cpp_tensorRT/src/faceNet.cpp:53:5: error: ‘Mpredictor’ does not name a type
     Mpredictor = CreatePaddlePredictor<MobileConfig>(Mconfig);
     ^~~~~~~~~~
/home/ns/mtcnn_facenet_cpp_tensorRT/src/faceNet.cpp:54:10: error: ‘cout’ in namespace ‘std’ does not name a type
     std::cout << "Load classification model succeed." << std::endl;
          ^~~~

Relevant snippet :-

#include "faceNet.h"
#include "time.h"
#include <sys/stat.h>
#include <iomanip>
#include<stdio.h> 
#include<stdlib.h> 
#include<unistd.h>
#include "/usr/local/include/ncnn/gpu.h"
//#include <iostring>
#include <string>
#include <vector>
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include <opencv2/highgui.hpp>
#include "paddle-lite/paddle_api.h"             // NOLINT
#include "/usr/local/include/paddle-lite/paddle_use_kernels.h"     // NOLINT
#include "/usr/local/include/paddle-lite/paddle_use_ops.h"         // NOLINT
#include "UltraFace.hpp"

//FOR MASK DET
using namespace std;
using namespace paddle::lite_api;
    float f;
    float FPS[16];
    int i, Fcnt=0;
    cv::Mat frame;
    int classify_w = 128;
    int classify_h = 128;
    float scale_factor = 1.f / 256;
    int FaceImgSz  = classify_w * classify_h;
    // Mask detection (second phase, when the faces are located)
    MobileConfig Mconfig;
    std::shared_ptr<PaddlePredictor> Mpredictor;

    //load SSD face detection model and get predictor
//    UltraFace ultraface("slim_320.bin","slim_320.param", 320, 240, 2, 0.7); // config model input
    UltraFace ultraface("RFB-320.bin","RFB-320.param", 320, 240, 2, 0.7); // config model input

    //load mask detection model
    Mconfig.set_model_from_file("mask_detector_opt2.nb");
    Mpredictor = CreatePaddlePredictor<MobileConfig>(Mconfig);
    std::cout << "Load classification model succeed." << std::endl;

Then the entire face-recognition code comes
Qengineering commented 3 years ago

Hard to say without all the code. Mconfig and Mpredictor are both Paddle-Lite routines. My first guess is that you forgot to link the Paddle-Lite API in the project. Please see MaskUltra.cbp with a text editor. At line 43 <Add library="/usr/local/lib/paddle-lite/libpaddle_api_light_bundled.a" />