enazoe / yolo-tensorrt

TensorRT8.Support Yolov5n,s,m,l,x .darknet -> tensorrt. Yolov4 Yolov3 use raw darknet *.weights and *.cfg fils. If the wrapper is useful to you,please Star it.
MIT License
1.19k stars 316 forks source link

How to get the count of no.of objects detected in a frame? #102

Closed Justin-king-de closed 3 years ago

Justin-king-de commented 3 years ago

Hey @enazoe I have used your repo to convert yolov4 darknet weights into tensorrt engine files. Now I want to get the count of no.of objects detected in a frame.How can I get that? Is there any way in the repo to count number of objects detected in a frame? Your help will be appreciated.

enazoe commented 3 years ago

@Justin-king-de https://github.com/enazoe/yolo-tensorrt/blob/master/modules/class_detector.h#L15 the size of this vector

Justin-king-de commented 3 years ago

@Justin-king-de Thanks for reply.I got the value of number of detections from the line pointed by you. But I want to actually display that value on the detected image . How can I achieve that in sample_detector.cpp script. In that script, detect function is taking vector of type BatchResultas input but not of type Result. So how can I access that value from sample_detector.cpp and write it on my image with detections. Please help me in this thing.

IsraelLencina commented 3 years ago

BatchResult is a vector of Result, so making a size should work. If you want to display it, should write text in the image with opencv support with:

cv::putText(img, // target image
            **number_of_detections.to_string()**, // text
            cv::Point(10, img.rows / 2), // top-left position
            cv::FONT_HERSHEY_DUPLEX,
            1.0,
            CV_RGB(118, 185, 0), //f ont color
            2);
Justin-king-de commented 3 years ago

@IsraelLencina Okay. Thanks.