HELP...How to detect corners using Harris corner detection Algorithm?

Hi, I am having trouble with getting this corner detection code to work properly. It works fine but points are scattered all over the place, i want the corner points to be detected within the bounding box. is there anything i need to add or edit?
This is the code i have so far:-
faceDetector = vision.CascadeObjectDetector('FrontalFaceCART');
cornerDetector = vision.CornerDetector('Method','Harris corner detection (Harris & Stephens)');
Irgb2gray=rgb2gray(Iface);
bboxes = step(faceDetector, Irgb2gray);
corners = detectHarrisFeatures(Irgb2gray);
Irgb2gray = insertObjectAnnotation(Iface, 'rectangle', bboxes, 'Face');
figure, imshow(Irgb2gray), title('Detected faces'); hold on;
plot(points.selectStrongest(50));
Thank you in advance.

2 Comments

Is there anyone that can help me on this problem?
Any suggestions on how to approach this problem? as you can see from the image below the 50 strongest points are not detected inside the bounding box.

Sign in to comment.

 Accepted Answer

Try the syntax with the 'ROI' parameter, something like this:
corners = detectHarrisFeatures(Irgb2gray,'ROI',bboxes(1,:));
This will detect Harris corners within the first bounding box in bboxes.

9 Comments

There's probably something missing/incorrect in your code snippet.
Take a look at this code snippet below and see if it helps. First run this and make sure all the detected Harris corners are within the faces displayed. Then replace 'visionteam.jpg' with your image.
% Create a detector object
faceDetector = vision.CascadeObjectDetector;
% Read input image
I = imread('visionteam.jpg');
% Detect faces
faces = step(faceDetector,I);
% Annotate detected faces
Iannotated = insertObjectAnnotation(I,'rectangle',faces,'Face');
figure; imshow(Iannotated);
% Detect corners on faces
for i = 1 : size(faces,1)
corners = detectHarrisFeatures(rgb2gray(I),'ROI',faces(i,:));
hold on;
plot(corners.selectStrongest(20))
end
hold off;
Hope that helps!
Thank you for the code snipped, i have modified a few things and it worked perfectly. I have 2 more questions if you can help me please. basically i want the corner detection to detect the 2 corner point of the mouth but cant get it to work. this is the code for it:-
%Detect objects using Viola-Jones Algorithm
%Create a detector object.
mouthDetector = vision.CascadeObjectDetector('Mouth','MergeThreshold',120);
%Read input image.
I = imread('tester.jpg');
%Detect faces.
bboxes = step(mouthDetector, I);
%Annotate detected faces.
IFaces = insertObjectAnnotation(I, 'rectangle', bboxes, 'mouth');
figure, imshow(IFaces), title('Detected mouth');
% Detect corners on mouth
for i = 1 : size(mouth,1)
corners = detectHarrisFeatures(rgb2gray(I),'ROI',mouth(i,:));
hold on;
plot(corners.selectStrongest(10))
end
hold off;
the second question is that i want to do face tracking to but my webcam i recently bought isnt being detected in matlab. The camera is Logitech C525 ans i read up that logitech is compatible with the image processing toolbox.
imaqhwinfo('winvideo')
ans =
AdaptorDllName: [1x81 char]
AdaptorDllVersion: '4.5 (R2013a)'
AdaptorName: 'winvideo'
DeviceIDs: {1x0 cell}
DeviceInfo: [1x0 struct]
do you know what the problem is?
Thank you
I can speak to the first question, but don't know much about the second.
You should be able to use the Harris detector as you are using it and select the left and right most corner points in the mouth ROI.
Is the image you showed me the result of running the code snippet? If so, it may mean there aren't strong enough corners detected. In this case, you should try adjusting parameters - maybe increase the MinQuality.
yes this is the result of the code snippet, what do you mean when so say select the left and right most corner points in the mouth ROI?? and how do i increase the minquality?
To increase the MinQuality parameter, do something like this.
corners = detectHarrisFeatures(rgb2gray(I),'ROI',faces(i,:),'MinQuality',0.05);
Once you get corner points, use the Location property of corner points to find the left-most and right-most corners.
so this is the code for it:-
the points are not detected inside the bounding box and they are not covering the corners of the mouth. is there anything that is wrong?
this is the result
so this is the code for it:-
for i = 1 : size(mouth,1)
corners = detectHarrisFeatures(rgb2gray(I),'ROI',faces(i,:),'MinQuality',0.05);
hold on;
plot(corners.selectStrongest(10))
end
hold off;

Sign in to comment.

More Answers (0)

Asked:

on 17 Nov 2013

Commented:

on 21 Nov 2013

Community Treasure Hunt

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

Start Hunting!