使用定义的宽度、长度和像素位置裁剪视频文件
我试图创建一个程序来检测视频中的脸部。在我接受“面子”之前,必须满足一些要求。满足所有要求后,我想要拍摄容纳该“脸部”的框架并裁剪它们以使脸部成为焦点区域。该程序将遍历每一帧并执行此操作,然后获取新视频并将其制作成视频文件。
我从未使用过视频文件或图像文件,因此这对我来说是全新的。我目前正在编写用于确定是否接受面部以及面部定位的所有算法。 我还有一个为该项目提供的视频处理器。视频处理器用于检测人脸。如果检测到面部,视频将在红色矩形中标记面部,并给出面部的 x 和 y 坐标以及面部的长度和宽度。
该程序中我完全不知道该怎么做的唯一区域是实际裁剪脸部,以及将新框架(聚焦于脸部)放置在原始框架上。
我也不知道如何制作视频文件。我假设它与创建文本文件的思路相同,只是使用了不同的方法和类。这是正确的吗?如果不是,我应该如何处理这个问题?
我仍处于设计阶段(我有视频处理器和程序其余部分的设计,但我想确保在我告诉那个人我可以做到这一点之前我能够裁剪并放置脸部)。我有视频处理器的代码(它很长,但如果需要,我可以发布一些方法)。
有什么好的资源我可以看一下或建议吗?
(我不知道最好的标签。请随意添加/删除任何标签)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有几个选择。如果您想在运行应用程序之前对视频进行预处理(以防它采用某种不寻常的格式),我建议使用 VirtualDub 为此。据我所知,您可以使用控制台运行它。如果您的视频采用某种标准格式,您可以忽略此段落。
对于应用程序本身,我建议使用 OpenCV(因为它是执行此类操作时常用的工具)。我建议阅读这个很棒的教程。然后,OpenCV 允许您“逐帧”浏览视频。
然后通过所谓的 ROI 完成裁剪本身。如果我理解正确的话,那么您想要制作一个由图片组合而成的新视频。稍后,当您尝试 OpenCV 时,您可能不再需要此提示,但请查看函数 cvCreateVideoWriter 和 cvWriteFrame
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