Clear Filters
Clear Filters

Counting objects in a "busy" image?

1 view (last 30 days)
Dan Comber
Dan Comber on 9 Aug 2018
I am trying to write a MATLAB script to count the number of bottles visible in a still image. They have a consistent size, shape, and colour; but variable orientation, and are in amongst other objects (occasionally overlapping).
I have attempted to train a Fast-RCNN detector and count the number of detections above a certain threshold, but the results have been inaccurate due to false positives, and due to individual bottles being detected by multiple bounding boxes.
Is there a different approach which is more appropriate, or a change to my current method which would work better? (Ideally one which would be able to be repurposed for a different object)
load('bottles\detector.mat')
inputs = dir('bottles\inputs');
threshold = 0.9;
outputs = zeros(length(inputs),1);
for i = 3:length(inputs)
img = imread(['bottles\inputs\',inputs(i).name]);
[boxes,score,labels] = detect(detector,img,'NumStrongestRegions',Inf,'SelectStrongest',true);
score(score<threshold) = [];
numBottles = length(score);
imwrite(img,['bottles\outputs\',num2str(numBottles),'_',num2str(i),'.png']);
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!