使用MATLAB的视频处理

应用,示例和技术

常见应用

Video applications present common but difficult challenges that require flexible analysis and processing functionality. Using MATLAB®和Sim万博1manbetxulink®products, you can develop solutions to common video processing challenges such as video stabilization, video mosaicking, target detection, and tracking.

对象跟踪

Object tracking is an essential part of many applications including pedestrian avoidance, security and surveillance, and augmented reality. This examples shows motion-based tracking of moving people in a video from a stationary camera.

对象检测和计数

Video processing can be used to detect and count objects that move in video sequences. In this case study, scientists in Australia are using video footage to estimate the wildlife population of waterbirds.

视频处理in MATLAB

MATLAB®提供工具和算法,使您可以查看,分析,阅读和编​​写视频。视频处理在以下应用程序中很有用:

视频处理对于深度学习,运动估计和自动驾驶等领域至关重要。通过查看MATLAB中的详细示例,了解如何进行互动,处理和分析视频。

视频处理以4个简单的步骤

MATLAB中的视频处理涉及以下步骤:

  1. 阅读视频
  2. 显示视频
  3. Processing the video
  4. Writing the video

Step 1。Reading the Video

You can read video from files or directly from cameras.

单个MATLAB命令使您可以从文件中阅读视频:

>> vid = videoreader('filename.avi'

MATLAB支万博1manbetx持网络摄像头用于视频处理图像采集工具箱™可以从许多工业和科学摄像机中实时获取。

MATLABlets you使用各种编解码器读取视频文件包括Microsoft的OS特定编解码器®Windows®, Mac, and Linux®

Step 2。显示视频

There are two methods for displaying video in MATLAB:

视频查看器应用

播放Matlab电影,视频或图像序列的视频查看器应用程序。该应用程序可让您以不同的速度启动,停止和播放视频,然后跳到视频的一部分。

Step 3。处理视频

A video is a sequence of individual video frames, or images. This means an algorithm designed to perform edge detection on an image can be quickly converted to perform edge detection on a video.

Read single image

从视频中读取图像框架

current_image = imread('flowers.png');
edge(current_image);

current_image = readFrame(vid);
edge(current_image);

Video processing can be very simple, as in the example using edge detection, or significantly more complex, such as tracking algorithms that must account for an object’s location in previous frames.

有关高级视频处理的更多信息,请参见以下示例:

第4步。Writing the Video

处理后,您可以将视频的每个帧写回文件。您可以使用该函数创建视频文件:

>> vid_w = VideoWriter('newfile.avi'); >> open(vid_w)

The variablevid_wcan accumulate new frames to create a video.

一个完整的MATLAB示例

将所有组件放在一起,让我们浏览一个完整的示例,以显示阅读,显示,处理和写作视频的步骤:

%% Read and process a video into MATLAB % Setup: create Video Reader and Writervideofilereader = videoreader('tilted_face.avi'); myVideo = VideoWriter('myfile.avi');%设置:创建可部署的视频播放器和面部检测器depVideoPlayer = vision.DeployableVideoPlayer; faceDetector = vision.CascadeObjectDetector(); open(myVideo);%% Detect faces in each framewhileHasframe(videofilereader)% read video framevideoframe = readframe(videofilereader);流程框架%bbox = facedetector(videoframe);videoframe = insertshape(videoframe,'Rectangle', bbox);%显示视频框架到屏幕DepVideOplayer(videoframe);% Write frame to final video filewriteVideo(myvideo,videoframe);暂停(1/videofilereader.framerate);结尾close(myVideo)

You can下载此代码在Matlab Central上。

高级技术

用于计算机视觉的视频处理算法

MATLABalgorithms that use temporal correlation for video processing are based on the concept of “state,” the idea that the algorithm is working on a current video frame but also uses previous frames to determine its output. This is crucial for object tracking algorithms, which rely on prior information to inform future action. A common example of tracking is theKLT algorithm,它跟踪对象中的各个点以跟踪对象的位置。

视频处理算法的开发人员还可以使用视觉特定算法Computer Vision System Toolbox™。该算法让您以快速和记忆的方式阅读和查看高分辨率视频。该工具箱还包括用于3D点云处理,立体声视觉,对象检测,跟踪和识别以及其他应用程序的算法。

了解有关视频处理的更多信息

使用GPU编码器从MATLAB编写的FOG Rectification算法中生成CUDA代码。
Learn the considerations, workflow, and techniques for targeting a vision processing algorithm to FPGA hardware
了解MATLAB如何解决在开发对象识别系统时遇到的共同挑战,并看到深度学习,机器学习和计算机视觉的新功能。