W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
本教程的目標(biāo)是學(xué)習(xí)如何校準(zhǔn)一個已經(jīng)給定一套棋盤圖像的相機。
測試數(shù)據(jù):使用數(shù)據(jù)/象棋文件夾中的圖像。
現(xiàn)在,讓我們編寫檢測圖像中棋盤的代碼,并找到與相機的距離。您可以將此方法應(yīng)用于具有已知3D幾何的任何對象; 您在圖像中檢測到。
測試數(shù)據(jù):使用您的數(shù)據(jù)文件夾中的chess_test * .jpg圖像。
Mat img = imread(argv [1],IMREAD_GRAYSCALE);
bool found = findChessboardCorners(img,boardSize,ptvec,CALIB_CB_ADAPTIVE_THRESH);
FileStorage fs( filename, FileStorage::READ );
Mat intrinsics, distortion;
fs["camera_matrix"] >> intrinsics;
fs["distortion_coefficients"] >> distortion;
vector<Point3f> boardPoints;
// fill the array
...
solvePnP(Mat(boardPoints), Mat(foundBoardCorners), cameraMatrix,
distCoeffs, rvec, tvec, false);
問題:你如何計算從相機原點到任何一個角落的距離?答:由于我們的形象在于3D空間,首先我們將計算出相對攝像機的姿勢。這將給我們3D到2D通信。接下來,我們可以應(yīng)用一個簡單的L2范數(shù)來計算任何點(拐點的終點)之間的距離。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: