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.
MATLAB®提供工具和算法,使您可以查看,分析,阅读和编写视频。视频处理在以下应用程序中很有用:
视频处理以4个简单的步骤
MATLAB中的视频处理涉及以下步骤:
- 阅读视频
- 显示视频
- Processing the video
- 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:
Deployable VideOplayer
: Efficiently view a series of video framesimplay
:启动用于查看视频的视频查看器应用程序
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 |
从视频中读取图像框架 |
---|---|
|
|
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_w
can 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点云处理,立体声视觉,对象检测,跟踪和识别以及其他应用程序的算法。