DetectCheckerboardPoints problem - finds wrong corner positions

5 次查看(过去 30 天)
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

采纳的回答

Vidya Viswanathan
Vidya Viswanathan 2016-7-12
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 个评论
Image Analyst
Image Analyst 2016-7-12
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by