Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling face recognition until a condition is met #14

Open
rsingh2083 opened this issue Jun 22, 2021 · 1 comment
Open

Disabling face recognition until a condition is met #14

rsingh2083 opened this issue Jun 22, 2021 · 1 comment

Comments

@rsingh2083
Copy link

Sir,
Let's say I want to disable face detection and recognition until a certain condition is true( decided by another external code).
How can I achieve this.
At exactly what line do I need to put a boolean condition :
if true : execute Face detection and recognition ,else: do nothing.

@Qengineering
Copy link
Owner

I would place my if(){ at line 324 at main.cpp. Just before ScaleX = ((float) frame.cols) / RetinaWidth;. This way your camera is still piping images. The end bracket } goes at line 500, still showing the images.

    while(1){
        cap >> frame;
        if (frame.empty()) {
            cerr << "End of movie" << endl;
            break;
        }
        if( my_condition ) {
             ScaleX = ((float) frame.cols) / RetinaWidth;
             ScaleY = ((float) frame.rows) / RetinaHeight;

             // copy/resize image to result_cnn as input tensor
             cv::resize(frame, result_cnn, Size(RetinaWidth,RetinaHeight),INTER_LINEAR);
             .........................................................
             DrawObjects(frame, Faces);

              //calculate frame rate
              f = chrono::duration_cast <chrono::milliseconds> (Tend - Tbegin).count();
              if(f>0.0) FPS[((Fcnt++)&0x0F)]=1000.0/f;
              for(f=0.0, i=0;i<16;i++){ f+=FPS[i]; }
              cv::putText(frame, cv::format("FPS %0.2f", f/16),cv::Point(10,20),cv::FONT_HERSHEY_SIMPLEX,0.6, cv::Scalar(180, 180, 0));
         } //end my_condition

        //show output
        cv::imshow("Jetson Nano - 2014.5 MHz", frame);
        char esc = cv::waitKey(5);
        if(esc == 27) break;
    }

To let another program start/stop the recognition, you have to signal from that program to this main.cpp.
By far the easiest way is using a little file. Main.cpp reads the file and sees if the my_condition flag is set/reset.
The other program can write to the same file.
Tip: locate the file at /dev/shm directory. This directory is redirected to RAM instead of the SD-card. This way the wear out of your SD-card will reduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants