Foreground Detection of Mouse on Background Issues
1 view (last 30 days)
Show older comments
Hello,
I have been trying my best to get an object tracking feature of Matlab to work on some video of a mouse that I have. It works decently at the moment, but it is not as accurate as I would like. Often the mouse appears misshapen or has some other deformities when analyzing the foreground mask. Attached are gifs of an example mouse video I was using, as well as an example of what the foreground produced. Below is some of my code I am using to create the foreground:
videoReader = vision.VideoFileReader(filename);
videoPlayer = vision.VideoPlayer('Position',[200,200,500,400]);
foregroundDetector = vision.ForegroundDetector('NumTrainingFrames', 500, ...
'InitialVariance', 0.05);
blobAnalyzer = vision.BlobAnalysis('AreaOutputPort', false, ...
'MinimumBlobArea', 70);
while ~isDone(videoReader)
colorImage = step(videoReader);
bw_file = rgb2gray(colorImage);
% get background approximation of surface (lighting and stuff)
background = imopen(bw_file,strel('disk',35));
% Display the Background Approximation as a Surface
ax = gca;
ax.YDir = 'reverse';
% Remove Background Approximation
bw2 = bw_file - background;
foregroundMask = foregroundDetector(bw2);
foregroundMask = bwareaopen(foregroundMask, 15);
foregroundMask = imfill(foregroundMask, 'holes');
Does anyone have any idea of how I can get the foreground to be more accurate?
0 Comments
Answers (0)
See Also
Categories
Find more on Tracking and Motion Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!