Cropping a video file with defined width, length,

2019-04-29 06:59发布

I an trying to create a program that will detect a face in a video. There are a few requirements that must be passed before I accept the "face". After all of the requirements are met I then want to take the frames that hold that "face" and crop them to make the face the area of focus. The program will go through every frame and do this, then take the new video and make that into a video file.

I have never worked with video files, or image file so this is all new to me. I am currently writing all of the algorithms used to determine if a face is accepted, and the positioning of the face. I also have a video processor that I was given for the project. The video processor is used to detect faces. If there is a detected face the video will mark the face in a red rectangle and give me the x and y coords of the face, and the length and width of the face.

The only area of the program that I have absolutely no idea how to do is the actual cropping of the face, and the placement of the new frame (focused on the face) over the original frame.

I also am not sure how to make a video file. I am assuming it is along the same lines as creating a text file, just with different methods and classes used. Is this correct? If not how should I approach this?

I am still in the designing phase (I have the video processor and the design for the rest of the program, but I wanted to make sure I was able to crop and place the face before I told the guy I could do it). I have the code for the video processor (its long but I can post some of the methods if needed).

Any good resources I could take a look at or suggestions?

(I don't know the best tags for this. Feel free to add/remove any)

1条回答
女痞
2楼-- · 2019-04-29 07:22

There is a couple of options you have. If you want to pre-process the video before running your application (in case it is in some unusual format) I would suggest to use VirtualDub for that. You can run it with console as far as I remember. If your video is in some standard format you can just ignore this paragraph.

For the application itself I would suggest OpenCV (as it is the usual tool when you do this sort of thing). I would suggest to read this great tutorial. OpenCV then allows you to go through video "frame by frame".

Cropping itself is then done via so called ROI. If I understood correctly you then want to put together a new video just assembled from pictures. Later on when you will try the OpenCV you will probably not need this hint anymore but look at functions cvCreateVideoWriter and cvWriteFrame

查看更多
登录 后发表回答