필터 지우기
필터 지우기

How to save the output Video using Videowriter.

조회 수: 9 (최근 30일)
VENKATA NARESH MALLADI
VENKATA NARESH MALLADI 2017년 3월 31일
답변: Sharmila Raghu 2017년 4월 4일
I am tracking an object by mouse selection and want to save the video with tracking results. Here is my code.
videoReader = vision.VideoFileReader('1.mp4');
videoFrame = step(videoReader);
figure; imshow(videoFrame); title('Select the Object');
rect = getrect;
bboxPoints = bbox2points(rect(1, :));
pointTracker = vision.PointTracker('MaxBidirectionalError', 2);
points = bboxPoints;
initialize(pointTracker, points, videoFrame);
videoPlayer = vision.VideoPlayer('Position',...
[100 100 [size(videoFrame, 2), size(videoFrame, 1)]+30]);
oldPoints = points;
while ~isDone(videoReader)
videoFrame = step(videoReader);
[points, isFound] = step(pointTracker, videoFrame);
visiblePoints = points(isFound, :);
oldInliers = oldPoints(isFound, :);
if size(visiblePoints, 1) >= 1 % need at least 2 points
[xform, oldInliers, visiblePoints] = estimateGeometricTransform(...
oldInliers, visiblePoints, 'similarity', 'MaxDistance', 4);
bboxPolygon = reshape(bboxPoints', 1, []);
videoFrame = insertShape(videoFrame, 'Polygon', bboxPolygon, ...
'LineWidth', 2);
videoFrame = insertMarker(videoFrame, visiblePoints, '+', ...
'Color', 'white');
oldPoints = visiblePoints;
setPoints(pointTracker, oldPoints);
end
% Display the annotated video frame using the video player object
step(videoPlayer, videoFrame);
% stop(reader);
end
release(videoFileReader);
release(videoPlayer);
release(pointTracker);

답변 (1개)

Sharmila Raghu
Sharmila Raghu 2017년 4월 4일
To save the video with tracking results, you can use the "writeVideo" command. The following is the documentation link for the same:

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by