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 日間)
Wesley
Wesley 2021 年 4 月 23 日
コメント済み: Wesley 2021 年 4 月 25 日
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 Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by