DetectCheckerboardPoints problem - finds wrong corner positions
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brian
le 28 Juin 2016
Commenté : Image Analyst
le 12 Juil 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 commentaires
Réponse acceptée
Vidya Viswanathan
le 12 Juil 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 commentaire
Image Analyst
le 12 Juil 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Support Package for USB Webcams dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!