Ask Your Question

How to crop human detected frame from live video.

asked 2020-03-25 16:06:33 -0500

salmaUCP gravatar image

updated 2020-11-30 03:25:00 -0500

I have already done human detection but don't know how to crop detected frames of video and save it in video format... here is the code link which i followed

Plz suggest me !!! Thanks

edit retag flag offensive close merge delete



Surprisily, when you google "opencv write video", you'll find lots of information

mvuori gravatar imagemvuori ( 2020-03-26 02:15:14 -0500 )edit

Thanks for your reply & I will be definitely search your suggestion on google but i want to crop human detected frames as i already mention above and provide link also( which i followed) On different websites(like stack overflow , git hub, pyImageSearch) they all are talking about the images not video & they all crop image not video frames... I am beginner in Computer vision and i don't have any idea about it... Please help me!!! Thanks!

salmaUCP gravatar imagesalmaUCP ( 2020-03-26 04:21:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-03-26 05:03:26 -0500

berak gravatar image

the main problem here is, that a writing video file needs a constant frame size, while size of your crops will vary due to person size & distance. so try following approach:

Size dstSize(64,128); // dst video size
VideoWriter vid("my.avi", VideoWriter::fourcc('M','J','P','G'), 10, dstSize); 

// later, in a loop, detect humans
Rect rec = ...
Mat cropped = frame(rec);
Mat dst;
resize(cropped, dst, dstSize);
edit flag offensive delete link more


thank you so much @berak

salmaUCP gravatar imagesalmaUCP ( 2020-03-26 05:20:20 -0500 )edit

Question Tools

1 follower


Asked: 2020-03-25 16:06:33 -0500

Seen: 634 times

Last updated: Mar 26 '20