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.


1 Answer 1


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

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

%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
for i=1:size(x1,1)

Saving the data in a .mat format:


Accessing the data:


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.

  • $\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.