フィルターのクリア

After converting video into frame, and appling frame differencing method to subtract two image, now i want to draw boundary in foreground of video, how?

7 ビュー (過去 30 日間)
%%Extracting & Saving of frames from a Video file through Matlab Code%%
clc;
close all;
clear all;
% assigning the name of sample mp4 file to a variable
filename = 'C:\Users\Hp\Desktop\xyz.mp4';
%reading a video file
mov = VideoReader(filename);
%getting no of frames
numFrames = mov.NumberOfFrames;
%setting current status of number of frames written to zero
numFramesWritten = 0;
%for loop to traverse & process from frame '1' to 'last' frames
for t = 1 : numFrames
currFrame = read(mov, t); %reading individual frames
opBaseFileName = sprintf('%3.3d.png', t);
opFullFileName = fullfile('C:\Users\Hp\Desktop\col1', opBaseFileName);
imwrite(currFrame, opFullFileName, 'png'); %saving as 'png' file
progIndication = sprintf('Wrote frame %4d of %d.', t, numFrames);
disp(progIndication);
numFramesWritten = numFramesWritten + 1;
end %end of 'for' loop
progIndication = sprintf('Wrote %d frames to folder "%s"',numFramesWritten, 'C:\Users\Hp\Desktop\col1');
disp(progIndication);
%End of the code
%frame differncing code
I=imread('C:\Users\Hp\Desktop\col\001.png');
I1=rgb2gray(I);
imshow(I1);
J=imread('C:\Users\Hp\Desktop\col1\001.png');
I1=rgb2gray(I);
J1=rgb2gray(J);
imshow(I1);
imshow(J1);
K=I1-J1;
figure;
imshow(K);
title('SUBTRACTED IMAGE ');
  2 件のコメント
komal
komal 2019 年 6 月 11 日
thank you for the above code. I need to subtract frames from each other like frame1- frame 2 and frame2-frame3 and so on till videos end. Then want to display the each result of differences on the graph

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2017 年 5 月 4 日
Use rectangle() or plot() to put lines into the overlay. Use text() to put words/strings into the overlay. You might have to put "hold on" first though.
  3 件のコメント
Mohammedashraf Shaikh
Mohammedashraf Shaikh 2017 年 5 月 5 日
編集済み: Image Analyst 2017 年 5 月 5 日
The above two images are subtracted and I obtained this subtracted image. Now I want to draw a rectangle on the video containing the boy. How do I get the coordinates or anything else?
Image Analyst
Image Analyst 2017 年 5 月 5 日
Threshold it. Call bwareafilt() to extract the largest blob. Call bwlabel(), then call regionprops() and ask for the bounding box. Then call "hold on" and call rectangle() to place the bounding box on the video. See if you can do those steps. Here's a start
binaryImage = subtractedImage > 30;
binaryImage = bwareafilt(binaryImage, 1);
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'BoundingBox');
hold on;
hRect = rectangle('Position', props.BoundingBox);

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by