MATLAB Answers

how to convert video inputed code to webcam inputed in matlab for tracking object

1 view (last 30 days)
Haris Elahi
Haris Elahi on 9 Feb 2018
Edited: Walter Roberson on 9 Feb 2018
I have a code named "Object Tracking Using Adaptive Object Color Modeling" that works perfectly for object tracking using given video (mp4.avi etc). But now I want to convert this code to webcam any idea how?
%%initialize
obj = VideoReader('lar.avi'); % Select Video File
tfn = get(obj,'numberOfFrames'); % Total Frame Numbers
sf = 1; % Start Frame For Tracking
ef = 400; % End Frame For Tracking
Bin = 8;
img = read(obj,sf); % Get First Frame
output = zeros(ef-sf+1,2); % Centroid Locations
% figure(); imshow(img) % Show First Frame & Wait Till Select The Object
% or = round(getrect(figure(1))); % Coded Rect [xmin(col),ymin(row),width,height]
or = [390,154,50,69];
CD = round([or(2)+or(4)/2 or(1)+or(3)/2]); % Object Centroid
% close Figure 1

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by