DetectCheckerboardPoints problem - finds wrong corner positions
5 views (last 30 days)
Show older comments
Brian
on 28 Jun 2016
Commented: Image Analyst
on 12 Jul 2016
Hi
I am trying to calibrate a camera. I have used the approach described in this example: openExample('vision/CorrectAnImageForLensDistortionExample')
In order to evaluate how good it is for finding the points I have drawn some images where I have defined the different kinds of distortion (e.g. radial, rotation and tangental) myself such that I can test how good it is. My problem is that it does not recognize the corner points in the checkerboard pattern when I do simple examples such as the following.
%%Reference geometry (chess pattern)
I = (checkerboard(100,4,3)<0.5);
I = I(1:700,:);
image = ones(2000)*0.3;
image(300:999,300:899) = I;
figure;
imshow(image)
set(gca,'color','blue')
axis off
axis image
F = getframe(gcf);
[specimen,~] = frame2im(F);
saveas(gcf,'dataImage.png')
%%Detect the calibration pattern.
[imagePoints, boardSize] = detectCheckerboardPoints('dataImage.png');
figure,imshow(image); hold on; plot(imagePoints(:,1), imagePoints(:,2), 'ro');
Does anyone know what cause the problem?
Best regards Brian
0 Comments
Accepted Answer
Vidya Viswanathan
on 12 Jul 2016
Hi Brian,
I went over the code that you posted in your question. I notice that you are first saving the current figure as an image ("dataImage.png"). This captures the gray background of the figure window also as a part of the image. This is different from the variable "image". You can see the difference between the two from the figures shown below. The one on the left is the variable "image" and the one on the right is "imshow(imread("dataImage.png")). You can see that there is an additional white portion in the image on the right. Additionally, the sizes of both "image" and imread("dataImage.png") are different.
In the code that you shared, you are basically finding the corners of imread("dataImage.png") but plotting it on the image represented by the variable "image". To get the right output, modify the code to one of the following:
[imagePoints, boardSize] = detectCheckerboardPoints('dataImage.png');
I1=imread('dataImage.png');
figure,imshow(I1); hold on; plot(imagePoints(:,1), imagePoints(:,2), 'ro');
OR
[imagePoints, boardSize] = detectCheckerboardPoints(image);
figure,imshow(image); hold on; plot(imagePoints(:,1), imagePoints(:,2), 'ro');
I hope this helps.
Regards,
Vidya Viswanathan
1 Comment
Image Analyst
on 12 Jul 2016
And of course even using the word "image" as the name of your variable is a bad idea because image is already a built-in function. Call it something else, like myImage, to avoid confusion.
More Answers (0)
See Also
Categories
Find more on MATLAB Support Package for USB Webcams 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!