ช่วยอธิบายโค้ดที่ขีดเส้นใต้ให้หน่อยค่ะ ไม่เข้า ร่วมถึงวิธีการคิดว่าเพราะอะไรถึงออกมาได้ค่านี้ [1 1 1]*1e5, [25, 10, 10], 25);
ถ้าสามารถบอกเว็บที่สอนได้เข้าใจจะขอบคุณมาก
videoReader = vision.VideoFileReader('singleball.avi');
videoPlayer = vision.VideoPlayer('Position',[100,100,500,400]);
foregroundDetector = vision.ForegroundDetector('NumTrainingFrames',10,'InitialVariance',0.05);
blobAnalyzer = vision.BlobAnalysis('AreaOutputPort',false,'MinimumBlobArea',70);
kalmanFilter = []; isTrackInitialized = false;
while ~isDone(videoReader)
colorImage = step(videoReader);
foregroundMask = step(foregroundDetector, rgb2gray(colorImage));
detectedLocation = step(blobAnalyzer,foregroundMask);
isObjectDetected = size(detectedLocation, 1) > 0;
if ~isTrackInitialized
if isObjectDetected
kalmanFilter = configureKalmanFilter('ConstantAcceleration',detectedLocation(1,, [1 1 1]*1e5, [25, 10, 10], 25);
isTrackInitialized = true;
end
label = ''; circle = [];
else
if isObjectDetected
predict(kalmanFilter);
trackedLocation = correct(kalmanFilter, detectedLocation(1,
);
label = 'Corrected';
else
trackedLocation = predict(kalmanFilter);
label = 'Predicted';
end
circle = [trackedLocation, 5];
end
colorImage = insertObjectAnnotation(colorImage,'circle',circle,label,'Color','red');
step(videoPlayer,colorImage);
end
ช่วยอธิบายโค้ดตัวนี้ให้หน่อยไม่เข้าใจ
ถ้าสามารถบอกเว็บที่สอนได้เข้าใจจะขอบคุณมาก
videoReader = vision.VideoFileReader('singleball.avi');
videoPlayer = vision.VideoPlayer('Position',[100,100,500,400]);
foregroundDetector = vision.ForegroundDetector('NumTrainingFrames',10,'InitialVariance',0.05);
blobAnalyzer = vision.BlobAnalysis('AreaOutputPort',false,'MinimumBlobArea',70);
kalmanFilter = []; isTrackInitialized = false;
while ~isDone(videoReader)
colorImage = step(videoReader);
foregroundMask = step(foregroundDetector, rgb2gray(colorImage));
detectedLocation = step(blobAnalyzer,foregroundMask);
isObjectDetected = size(detectedLocation, 1) > 0;
if ~isTrackInitialized
if isObjectDetected
kalmanFilter = configureKalmanFilter('ConstantAcceleration',detectedLocation(1,, [1 1 1]*1e5, [25, 10, 10], 25);
isTrackInitialized = true;
end
label = ''; circle = [];
else
if isObjectDetected
predict(kalmanFilter);
trackedLocation = correct(kalmanFilter, detectedLocation(1,);
label = 'Corrected';
else
trackedLocation = predict(kalmanFilter);
label = 'Predicted';
end
circle = [trackedLocation, 5];
end
colorImage = insertObjectAnnotation(colorImage,'circle',circle,label,'Color','red');
step(videoPlayer,colorImage);
end