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 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by