0
$\begingroup$

I have some crowd images having more than 300 people in each image. I want to label each person(i.e. head) with dot annotation such that coordinate of each dot(x,y) is saved in a .mat file. I hope there is something in Matlab for this task.

$\endgroup$

1 Answer 1

2
$\begingroup$

The Viola Jones algorithm does the face detection for you using the Cascade Object Detector.

%Read the image
x= imread('C:\~\crowd.jpeg');
x=rgb2gray(x);

%Face detection
faceDetector = vision.CascadeObjectDetector;
bboxes = step(faceDetector,x);

The first two columns of bboxes gives the (x,y) coordinates of the faces detected

If you want to label the people in the picture:

x1 = bboxes(:,1) %x co-ordinates
x2 = bboxes(:,2) %y co-ordinates
figure;
imshow(x);
for i=1:size(x1,1)
    plot(x1(i),x2(i),'*');
end

Saving the data in a .mat format:

save('dot.mat','x1','x2');

Accessing the data:

load('dot.mat');

To save data points from a given image, you can use ginput method. First read the image and then use [x,y] = ginput(n) where n is the number of points you need to save.

$\endgroup$
2
  • $\begingroup$ An algorithmic approach for face detection will contain errors in it's (x,y) co-ordinates. Basically, I want a ground truth labeller, a gui based software where I can annotate each person's head by a dot. In Matlab's existing Ground truth Labeller app and Image Labeller app I didn't found any functionality for dot annotation. $\endgroup$ Commented Mar 22, 2020 at 13:30
  • $\begingroup$ So, you want to save mouse-click co-ordinates of the faces? If that is the case, I have added a small comment at the end of my answer. $\endgroup$
    – DSP Novice
    Commented Mar 22, 2020 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.