現在地 >> メニュー >> サンプルコード::OpenCV >> OpenCV::F行列
関連:OpenCV::エピポーラ線


F行列


エピポーラ幾何は以下の式で表現される。



p1とp2は2枚の画像で対応する点。
F:F行列


F行列は、2つのカメラ間の
  • 並行移動要素
  • 回転移動要素
  • カメラの内部パラメータ要素
の3つを含んでいる。
また、F行列は(3×3)の行列で、ウィンドウ座標に依存する。


※E行列は「並行」、「回転」の2つを含む行列なので、ワールド座標に依存する。


[例]:F行列を計算する

「first」と「second」がそれぞれ対応点だと仮定。

#include <iostream>
#include <cv.h>

//------------ 各種外部変数 ----------//
double first[12][2] =
{
	{488.362, 169.911},
	{449.488, 174.44},
	{408.565, 179.669},
	{364.512, 184.56},
	{491.483, 122.366},
	{451.512, 126.56},
	{409.502, 130.342},
	{365.5, 134},
	{494.335, 74.544},
	{453.5, 76.5},
	{411.646, 79.5901},
	{366.498, 81.6577}
};

double second[12][2] = 
{
	{526.605, 213.332},
	{470.485, 207.632},
	{417.5, 201},
	{367.485, 195.632},
	{530.673, 156.417},
	{473.749, 151.39},
	{419.503, 146.656},
	{368.669, 142.565},
	{534.632, 97.5152},
	{475.84, 94.6777},
	{421.16, 90.3223},
	{368.5, 87.5}
};

//------------ メイン関数 ---------------//
int main(int argc,char *argv[])
{
	CvMat *firstM = cvCreateMat(12,2,CV_64FC1);
	cvSetData(firstM,first,firstM->step);
	
	CvMat *secondM = cvCreateMat(12,2,CV_64FC1);
	cvSetData(secondM,second,secondM->step);
	
	CvMat *FMat= cvCreateMat(3,3,CV_64FC1);

	if(cvFindFundamentalMat(firstM,secondM,FMat,CV_FM_RANSAC,1.00,0.99) == 0){
		std::cerr << "Can't Get F Mat\n";
		return -1;
	}

	for(int y = 0; y < 3;++y){
		for(int x = 0; x < 3;++x)
		{
			std::cout << CV_MAT_ELEM(*FMat,double,y,x) << " ";
		}
		std::cout << "\n";
	}


	cvReleaseMat(&firstM);
	cvReleaseMat(&secondM);
	cvReleaseMat(&FMat);

	return EXIT_SUCCESS;
}


リファレンス

目次

― その他 ―

Wiki内検索

計測中...(07.10.8〜)

Save The World






▲よろしければ広告のクリックもお願いします


▲ランキングに参加しました

管理人/副管理人のみ編集できます