Qengineering / Face-Recognition-with-Mask-Jetson-Nano

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

Video is slow on some cameras #11

Closed rsingh2083 closed 3 years ago

rsingh2083 commented 3 years ago

Hi, I tested it on two cameras :-

QHM495B supports 480P high-definition images and true colour images. Anti-flicker 50Hz, 60Hz or outdoor : 480P
&
Lapcam web camera HD 720P High resolution Video LWC-042  : 720P

On the first one which is 480p, the accuracy is low as the default exposure is low and video is coming dark. Hence its saying 'fake' most of the time. While on the second one which is 720p, accuracy is really good, video is well lit but the video is slow compared to first camera.

Any reasons as to why this is happening ? And how to solve it. Id definitely like to use second camera, but how to solve the slow video issue ? Is the video slow because the camera is 720p ?

Qengineering commented 3 years ago

Dear @rsingh2083,

That's more an advanced subject. Many Jetson Nano applications use GStreamer to get camera images in OpenCV. With the use of GStreamer, you can define the proper size, frame rate and compression. I think that Google and NVIVIA forum are the place to find your solution in the first place. Let me know if you need further support.

rsingh2083 commented 3 years ago

Let me know if you need further support.

Sure sir, please help if you can. Been struggling to solve this. I even tried gstreamer but maybe Im getting some parameters wrong or not optimized. For instance I changed cv::VideoCapture line to use nvargus as follows :- cv::VideoCapture cap('nvarguscamerasrc sensor_id=ID ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)NV12 ! nvvidconv flip-method=M ! video/x-raw, format=I420, appsink max-buffers=1 drop=true', CAP_GSTREAMER);

Qengineering commented 3 years ago

Please see Q-engineering and GitHub for Raspberry Pi 64-bit OpenCV examples. Your problem is to find the right parameters in the pipeline. That's not easy, specially with the wide variety of cameras. Best to start with a simple program and try to get an image on your screen with $ gst-launch-1.0 ....... This way, you don't have to compile the code every time. Start for instance with a testscreen.

rsingh2083 commented 3 years ago

Ok sir. Another thing which probably might help you figure out is : The fps over the video is showing 25, but the video is choppy as if its between 3 to 5 fps. How come the FPS from your code is showing 25+ if the video is very choppy, have you seen such issue before ?

Qengineering commented 3 years ago

I measure the time it takes to process the images. Not the whole procedure of grabbing a picture, transferring it to OpenCV, showing results etc. The FPS in this case reflects an ideal situation, without external dependencies. I've done this because some wear out SD-cards can be really slow.