Tracking a clay target using foreground detection using Gaussian mixture models inconsistently identifying the target.
1 次查看(过去 30 天)
显示 更早的评论
I am working on a project to use stereo vision to track a shooters aim and a clay target in flight and try and calculate the distance the shooter misses by. I have colored markers on the gun to assist with the aim but I am having trouble tracking the clay target.
I am using some code i have adapted from one of the online examples, which so far identifies the target in only a few out of the 10 frames in my video. Any help that you can give is greatly appreciated.
The code that i am currently using is:
% defines min/max blob sizes
minsize = 8;
maxsize = 100;
videoSource = vision.VideoFileReader('L_Trial2.avi','VideoOutputDataType','uint8');
detector = vision.ForegroundDetector('NumTrainingFrames', 5,...
'InitialVariance', 200, 'NumGaussians', 8, 'MinimumBackgroundRatio', 0.1);
blobbbox = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', minsize,...
'MaximumBlobAreaSource', 'Property', 'MaximumBlobArea',maxsize);
shapeInserter = vision.ShapeInserter('BorderColor','White');
videoPlayer = vision.VideoPlayer();
for i = 1:10
frame = step(videoSource);
fgMask = step(detector, frame);
bbox = step(blobbbox, fgMask);
out = step(shapeInserter, frame, bbox);
step(videoPlayer, out);
pause(0.5)
end
release(videoPlayer);
release(videoSource);
Links to this .m file, and the video i am using are:
https://www.dropbox.com/s/w3ysdsgjuj9sqa9/GetTargetLocCutdown.m?dl=0
https://www.dropbox.com/s/0vshthqtha5i6by/L_Trial2.avi?dl=0
2 个评论
采纳的回答
更多回答(1 个)
Dima Lisin
2015-9-2
编辑:Dima Lisin
2015-9-2
Hi Josh,
There are several issues here. One is that the target is very small. I had to watch the video a few times before I even noticed it. It would help if you could make the target look bigger in the video. You could move the camera closer, use a zoom lens, or a use higher resolution camera.
The other issue is that you only have 10 frames. vision.ForegroundDetector learns the background over time. If you start recording some time before the first target is launched, it will give the foreground detector time to learn what the background pixel values are, and it will be better able to distinguish the target from noise.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!