AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

Crop detected object in video #5077

Open xinyee1997 opened 4 years ago

xinyee1997 commented 4 years ago

anyone know how to crop detected object (bounding box) in video or in webcam??

stephanecharette commented 4 years ago

Yes. But you'll have to provide a bit more details.

Typically darknet gives you back the midpoint X, Y, as well as the width and height. So you'd use OpenCV to set a RoI, and then do whatever you want with it. Save it as a new image, pass it to a function, ... What exactly are you having trouble with?

You mention video and webcam, so I assume you're already doing something like:

cv::VideoCapture cap("sample.mp4");
while (true)
{
    cv::Mat frame;
    cap >> frame;
    ...do something here with the frame, such as detection and then crop all the bounding boxes....

?

xinyee1997 commented 4 years ago

@stephanecharette I have tried the method of #2319. But it only works when i detect image but not video.

Can you teach me how to do that in details? My detection is done in real time with webcam. I hope the detected object can be cropped and saved to a folder

stephanecharette commented 4 years ago

I suggest you hire someone with the necessary skills, @xinyee1997. Or maybe search online for some tutorials and spend some time learning it? Trying to teach people OpenCV using comments on github issue tickets is unlikely to be very successful.

My suggestion is you start with the code I posted 2 comments above. Take a look at OpenCV's cv::VideoCapture class, and see what it does and how it works. There are tutorials available that show people how to get still frames from videos, and you can then pass those frames into darknet.

lsd1994 commented 4 years ago

Do you use darknet as dll? Or just change darknet itself?