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
108 stars 31 forks source link

Segmentation fault (core dumped) #6

Closed lbtanh closed 2 years ago

lbtanh commented 3 years ago

I have built successfully with #5 , but when i run the error appear: image. log: Checking for existence: /home/anhlbt/Face-Recognition-Jetson-Nano-main/bin/Release/FaceRecognition Executing: xterm -T FaceRecognition -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.:/usr/local/lib/:/usr/lib/:/usr/local/lib /home/anhlbt/Face-Recognition-Jetson-Nano-main/bin/Release/FaceRecognition (in /home/anhlbt/Face-Recognition-Jetson-Nano-main/.) do you have any suggestion for this error? thanks

Qengineering commented 3 years ago

Mostly the error indicates some writing to an forbidden area in memory. For instance, when you having an index to an array running from 0 up till 10, and you want to get position -2, or +25. Because your screen comes with the error right at the beginning, even before main.cpp starts printing your OpenCV version, I presume some initialization (main.cpp lines 140 - 166) goes wrong. Please put some diagnostic printing lines in your code to see where it went wrong. Example

int main(int argc, char **argv)
{
    float f;
    float FPS[16];
    int   n,Fcnt=0;
    size_t i;
    cv::Mat frame;
    cv::Mat result_cnn;
    cv::Mat faces;
    std::vector<FaceObject> Faces;
cout << "Init Faces list"  << endl;
    vector<cv::Mat> fc1;
    string pattern_jpg = "./img/*.jpg";
    cv::String NewItemName;
    size_t FaceCnt;
    //the networks
    TLive Live;
cout << "Init Live"  << endl;
    TWarp Warp;
cout << "Init Warp"  << endl;
    TMtCNN MtCNN;
cout << "Init MtCNN"  << endl;
    TArcFace ArcFace;
cout << "Init ArcFace"  << endl;
    TRetina Rtn(RetinaWidth, RetinaHeight, false);     //no Vulkan support on a RPi
cout << "Init Rtn"  << endl;
    TBlur Blur;
cout << "Init Blur"  << endl;
lbtanh commented 3 years ago

Mostly the error indicates some writing to an forbidden area in memory. For instance, when you having an index to an array running from 0 up till 10, and you want to get position -2, or +25. Because your screen comes with the error right at the beginning, even before main.cpp starts printing your OpenCV version, I presume some initialization (main.cpp lines 140 - 166) goes wrong. Please put some diagnostic printing lines in your code to see where it went wrong. Example

int main(int argc, char **argv)
{
    float f;
    float FPS[16];
    int   n,Fcnt=0;
    size_t i;
    cv::Mat frame;
    cv::Mat result_cnn;
    cv::Mat faces;
    std::vector<FaceObject> Faces;
cout << "Init Faces list"  << endl;
    vector<cv::Mat> fc1;
    string pattern_jpg = "./img/*.jpg";
    cv::String NewItemName;
    size_t FaceCnt;
    //the networks
    TLive Live;
cout << "Init Live"  << endl;
    TWarp Warp;
cout << "Init Warp"  << endl;
    TMtCNN MtCNN;
cout << "Init MtCNN"  << endl;
    TArcFace ArcFace;
cout << "Init ArcFace"  << endl;
    TRetina Rtn(RetinaWidth, RetinaHeight, false);     //no Vulkan support on a RPi
cout << "Init Rtn"  << endl;
    TBlur Blur;
cout << "Init Blur"  << endl;

thanks @Qengineering, i add breakpoint at the beggining, and debug. There somethings wrong in TMtCNN.cpp (from line 18) image

Qengineering commented 3 years ago

Here the models are loaded into the networks. If it crashes on line 18, it might indicate a missing or corrupt det1.param file. Please check by temporary not loading any model and see what's happening. Of course you get errors when running the app, but if you see your OpenCV version printed on screen, you know for sure where the crash happens.

//----------------------------------------------------------------------------------------
TMtCNN::TMtCNN(void)
{
/*
    Pnet.load_param("./models/mtcnn/det1.param");
    Pnet.load_model("./models/mtcnn/det1.bin");
    Rnet.load_param("./models/mtcnn/det2.param");
    Rnet.load_model("./models/mtcnn/det2.bin");
    Onet.load_param("./models/mtcnn/det3.param");
    Onet.load_model("./models/mtcnn/det3.bin");
*/
}
//----------------------------------------------------------------------------------------
lbtanh commented 3 years ago

Here the models are loaded into the networks. If it crashes on line 18, it might indicate a missing or corrupt det1.param file. Please check by temporary not loading any model and see what's happening. Of course you get errors when running the app, but if you see your OpenCV version printed on screen, you know for sure where the crash happens.

//----------------------------------------------------------------------------------------
TMtCNN::TMtCNN(void)
{
/*
    Pnet.load_param("./models/mtcnn/det1.param");
    Pnet.load_model("./models/mtcnn/det1.bin");
    Rnet.load_param("./models/mtcnn/det2.param");
    Rnet.load_model("./models/mtcnn/det2.bin");
    Onet.load_param("./models/mtcnn/det3.param");
    Onet.load_model("./models/mtcnn/det3.bin");
*/
}
//----------------------------------------------------------------------------------------

Thanks, i think somethings went wrong with prebuild lib (det1.bin, ...), maybe the environments not the same (i dont install Paddle-Lite, cause not enough storage)

TsvetkovEvan commented 3 years ago

did you find a solution to the error? I have the same.

Qengineering commented 3 years ago

Dear @TsvetkovEvan, sorry to hear about your problems. Did you follow the above discussion? It may sound arrogant, but the software is almost certainly flawless. Lots of downloads without any problem per week. Usually there is something wrong in the environment. A software package, such as Paddle-Lite or ncnn, that is not properly installed. Working with virtual environments also aims to be a source of misunderstandings. Please try to pin-point your error to one line of code with debug cout statements.

lbtanh commented 3 years ago

did you find a solution to the error? I have the same.

Hello @TsvetkovEvan, i changed to repo Face-Recognition-with-Mask-Jetson-Nano, it works normally, i don't know the root cause.

Qengineering commented 3 years ago

@lbtanh, @TsvetkovEvan , Adapted project file for ncnn version 20210322. No problems any more.

Qengineering commented 2 years ago

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.