주요 콘텐츠

undistortPoints

렌즈 왜곡을 보정한 점 좌표

설명

undistortedPoints = undistortPoints(points,cameraParams)는 렌즈 왜곡이 보정된 점 좌표를 반환합니다. 이 함수는 수치적 비선형 최소제곱 최적화를 사용합니다.

[undistortedPoints,reprojectionErrors] = undistortPoints(points,cameraParams)는 왜곡이 보정된 점의 정확도를 평가하는 데 사용되는 오차도 반환합니다.

예제

예제

모두 축소

보정 영상이 포함된 imageDatastore 객체를 생성합니다.

images = imageDatastore(fullfile(toolboxdir("vision"),"visiondata", ...
   "calibration","mono"));
imageFileNames = images.Files;

보정 패턴을 검출합니다.

[imagePoints,boardSize] = detectCheckerboardPoints(imageFileNames);

사각형 코너의 세계 좌표를 생성합니다. 사각형 크기의 단위는 밀리미터입니다.

squareSize = 29; 
worldPoints = patternWorldPoints("checkerboard",boardSize,squareSize);

카메라를 보정합니다.

I = readimage(images,10); 
imageSize = [size(I, 1), size(I, 2)];
params = estimateCameraParameters(imagePoints,worldPoints,ImageSize=imageSize);
intrinsics = params.Intrinsics;

영상을 볼러오고 체커보드 점을 검출합니다.

points = detectCheckerboardPoints(I);

점의 왜곡을 보정합니다.

undistortedPoints = undistortPoints(points,intrinsics);

영상의 왜곡을 보정합니다.

[J, newIntrinsics] = undistortImage(I,intrinsics,OutputView="full");

왜곡이 보정된 점을 평행 이동합니다.

newOrigin = intrinsics.PrincipalPoint - newIntrinsics.PrincipalPoint;
undistortedPoints = [undistortedPoints(:,1) - newOrigin(1), ...
                     undistortedPoints(:,2) - newOrigin(2)];

결과를 표시합니다.

figure; 
imshow(I); 
hold on;
plot(points(:,1),points(:,2),"r*-");
title("Detected Points"); 
hold off;

Figure contains an axes object. The hidden axes object with title Detected Points contains 2 objects of type image, line.

figure; 
imshow(J); 
hold on;
plot(undistortedPoints(:,1),undistortedPoints(:,2),"g*-");
title("Undistorted Points"); 
hold off;

Figure contains an axes object. The hidden axes object with title Undistorted Points contains 2 objects of type image, line.

입력 인수

모두 축소

입력 점으로, M개의 [x y] 좌표로 구성된 M×2 행렬로 지정됩니다.

카메라 파라미터로, cameraParameters, cameraIntrinsics 또는 cameraIntrinsicsKB 객체로 지정됩니다. estimateCameraParameters 함수를 사용하여 cameraParameters 객체를 반환할 수 있습니다. cameraParameters 객체는 카메라의 내부 파라미터, 외부 파라미터, 렌즈 왜곡 파라미터를 포함합니다.

출력 인수

모두 축소

왜곡이 보정된 점으로, M×2 행렬로 반환됩니다. undistortedPoints 출력값은 렌즈 왜곡이 보정된 M개의 [x,y] 점 좌표를 포함합니다. 점을 double형으로 입력하면 함수는 undistortedPointsdouble형으로 출력합니다. 그렇지 않으면 undistortedPoints를 single형으로 출력합니다.

데이터형: single | double

재투영 오차로, M×1 벡터로 반환됩니다. 이 오차를 사용하여 왜곡이 보정된 점의 정확도를 평가할 수 있습니다. 이 함수는 보정된 점에 왜곡을 적용한 후, 그 결과와 해당 입력 점 간 거리를 구하여 오차를 계산합니다. reprojectionErrors 출력값의 단위는 픽셀입니다.

확장 기능

모두 확장

버전 내역

R2014b에 개발됨

모두 확장