YoloFastestV2-ncnn-Raspberry-Pi-4 icon indicating copy to clipboard operation
YoloFastestV2-ncnn-Raspberry-Pi-4 copied to clipboard

How to run the detection on rectangular ROIs

Open rsingh2083 opened this issue 3 years ago • 5 comments

Hi Sir,

I want to run this on only two rectangular ROI of the video. For example a rectangular ROI in top left and bottom right, that's it. Can you please help how to do it .

rsingh2083 avatar Jul 01 '22 15:07 rsingh2083

Dear @rsingh2083,

How do you want to prioritize the found objects? For instance, you found 8 objects. Which two do you want to show? The two with the highest probability? Or with the largest surface? Be aware, that the next frame can be slightly different compared to the previous, resulting in another outcome. Your two ROI will get bouncing around.

Qengineering avatar Jul 03 '22 09:07 Qengineering

Sir I just want to check if there is any person in 4 rectangular ROI. In these 4 rectangular regions if a person with highest probability is detected, that's it.

rsingh2083 avatar Jul 10 '22 03:07 rsingh2083

Start playing with cv::Rect. Your outcome has a rect around the person, and if you define the 4 regions as rect, you can find the overlap. See https://answers.opencv.org/question/67091/how-to-find-if-2-rectangles-are-overlapping-each-other/ for the math on rects

Qengineering avatar Jul 10 '22 08:07 Qengineering

Thanks sir. If the centroid of rect of person from YOLO lies between the 4 rectangular regions created by me, then I'll count that. Sir do you think this process will also decrease CPU load, because now instead of the entire video frame ,we will be processing only 4 rectangular regions. I'm asking because I want to have this benefit also.

rsingh2083 avatar Jul 10 '22 11:07 rsingh2083

The design of the deep learning model determines the dimensions of the input image. In the case of YoloFastestV2, it is 352x352. Regardless of the resolution offered, the first thing the algorithm does is resize to this 352x352 (line 186 of yolo-fastestv2.cpp). As a result, the inference time also remains the same, regardless of the image size.

Qengineering avatar Jul 10 '22 16:07 Qengineering