> ## Content Index
> Fetch the complete content index at: https://yinguobing.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# OpenCV视频处理模板代码
- URL: https://yinguobing.com/blog/template-code-for-opencv-video-processing/
- Published: 2021-03-10T09:01:46.000Z
- Updated: 2022-05-29T08:52:27.000Z
- Description: 图像相关项目中经常用到的基础功能。
- Author: 尹国冰
- Tags: 图像处理, OpenCV

在项目进展到一定阶段后经常会遇到成果展示的需求。大部分时候少不了在一段视频或者摄像头上演示算法的实际效果。这里我把自己在多个项目中用到的OpenCV视频处理代码的共同部分精简并开源出来。如果你也有类似的需求可以关注下。

功能：

- 用户指定读取视频文件或者摄像头。
- 如果没有指定视频文件，自动读取默认摄像头。
- 如果从摄像头读取，自动左右翻转，形成镜像。
- 内置FPS计数器。
- 自动构建同等规格视频写入器，记录处理后的视频。

这段代码以Gist的形式放在GitHub。地址是

[Template module for video frame processing.Template module for video frame processing. GitHub Gist: instantly share code, notes, and snippets.![](https://github.githubassets.com/favicons/favicon.svg)Gist262588213843476![](https://github.githubassets.com/images/modules/gists/gist-og-image.png)](https://gist.github.com/yinguobing/cfb6d7ddff0dc8ae25b1bb3bf701b563?ref=yinguobing.com)