When running the program, an error like "The function or variable'getLoc' cannot be recognized" is displayed.Everyone, please help to see if there is any problem, thank you very much!
2 views (last 30 days)
Show older comments
CODE:
close all
clear
clc
%%set up video reader and player
videoFReader=vision.VideoFileReader('Dune.MP4',...
'VideoOutputDataType','double');
vidPlayer=vision.DeployableVideoPlayer;
%%create tracker object
tracker=vision.HistogramBasedTracker;
%%Initialize tracker
img=step(videoFReader);
figure
imshow(img)
h=drawrectangle;%imrect
wait(h);
[~,centLoc]=getLoc(h);%boxLoc=getLoc(h)
MotonModel='ConstantVelocity';
InitialLocation=centLoc;
InitialEstimateError=[10,10];
MotionNoise=[20 20];
MeasurementNoise=2000;
kf=configureKalmanFilter(...
MotionModel,...
InitialLocation,...
InitialEstimateError,...
MotionNoise,...
MeasurementNoise);
%%%loop algorithm
while (~isDone(videoFReader))
videoFrame=step(videoFReader);
trackedLocation=predict(kf);
out=insertShape(videoFrame,'circle',[trackedLocation 20],...
'Color','green','LineWidth',5);
%detect ball
[~,detectedLocation]=segmentBall(videoFrame,5000);
if(~isempty(detectedLocation))
%if ball is found,correct or update the Kalman filter
trackedLocation=correct(kf,detectedLocation);
out=insertShape(videoFrame,'circle',[trackedLocation 5],...
'Color','blue','LineWidth',5);
end
step(vidPlayer,out);
pause(0.1)
end
2 Comments
Walter Roberson
on 23 Apr 2021
getLoc appears to be part of https://www.mathworks.com/matlabcentral/fileexchange/57936-computer-vision-for-student-competitions-object-tracking
Answers (0)
See Also
Categories
Find more on Tracking and Motion Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!