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 = generateCheckerboardPoints(boardSize,squareSize);
カメラのキャリブレーションを行います。
I = readimage(images,10); imageSize = [size(I, 1), size(I, 2)]; params = estimateCameraParameters(imagePoints,worldPoints, ... 'ImageSize',imageSize);
イメージを読み込み、チェッカーボード点を検出します。
points = detectCheckerboardPoints(I);
点を歪み補正します。
undistortedPoints = undistortPoints(points,params);
イメージの歪みを補正します。
[J, newOrigin] = undistortImage(I,params,'OutputView','full');
歪み補正後の点を平行移動します。
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; imshow(J); hold on; plot(undistortedPoints(:,1),undistortedPoints(:,2),'g*-'); title('Undistorted Points'); hold off;
入力引数
points
— 入力点
M 行 2 列の行列
入力点。M 個の [x y] 座標からなる M 行 2 列の行列を指定します。
cameraParams
— カメラ パラメーターを格納するオブジェクト
cameraParameters
オブジェクト | cameraIntrinsics
オブジェクト
カメラ パラメーター。cameraParameters
または cameraIntrinsics
オブジェクトとして指定します。関数 estimateCameraParameters
を使用して、cameraParameters
オブジェクトを返すことができます。cameraParameters
オブジェクトには、カメラの内部パラメーター、外部パラメーターおよびレンズ歪みパラメーターが含まれます。
出力引数
undistortedPoints
— 歪み補正後の点
M 行 2 列の行列
歪み補正後の点。M 行 2 列の行列として返されます。出力 undistortedPoints
には、レンズ歪みを修正した M 個の点座標 [x,y] が含まれます。点を double
として入力すると、関数は undistortedPoints
を double
として出力します。それ以外の場合は、undistortedPoints
を single として出力します。
データ型: single
| double
reprojectionErrors
— 再投影誤差
M 行 1 列のベクトル
再投影誤差。M 行 1 列のベクトルとして返されます。この誤差を使用して、歪み補正後の点の精度を評価できます。この関数は、歪み補正後の点に歪みを適用し、その結果と対応する入力点の間の距離を取得することによって誤差を計算します。出力 reprojectionErrors
はピクセル単位です。
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2014b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)