使用定义的宽度、长度和像素位置裁剪视频文件 [英] Cropping a video file with defined width, length, and pixel location

查看:18
本文介绍了使用定义的宽度、长度和像素位置裁剪视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个程序来检测视频中的人脸.在我接受面子"之前,必须通过一些要求.在满足所有要求后,我想拍摄包含该脸部"的框架并裁剪它们以使脸部成为焦点区域.该程序将遍历每一帧并执行此操作,然后获取新视频并将其制作为视频文件.

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.

我从未处理过视频文件或图像文件,所以这对我来说是全新的.我目前正在编写用于确定面部是否被接受以及面部定位的所有算法.我还有一个视频处理器,我是为该项目提供的.视频处理器用于检测人脸.如果检测到人脸,视频会将人脸标记为红色矩形,并给出人脸的 x 和 y 坐标,以及人脸的长度和宽度.

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)

推荐答案

您有几个选择.如果您想在运行应用程序之前对视频进行预处理(以防它采用某种不寻常的格式),我建议使用 VirtualDub.据我所知,您可以使用控制台运行它.如果您的视频采用某种标准格式,则可以忽略此段落.

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.

对于应用程序本身,我建议使用 OpenCV(因为它是您执行此类操作时常用的工具).我建议阅读这个很棒的教程.然后,OpenCV 允许您逐帧"浏览视频.

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".

然后通过所谓的 ROI 来完成裁剪本身.如果我理解正确,那么您想将一个刚刚从图片中组装的新视频放在一起.稍后当您尝试 OpenCV 时,您可能不再需要此提示,但请查看函数 cvCreateVideoWriter 和 cvWriteFrame

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

这篇关于使用定义的宽度、长度和像素位置裁剪视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆