OpenCVの行列

致命的なバグを発見.

mat = cvCreateMat(3, 3, CV_32F);
mat =
|0.0 1.0 2.0|
|3.0 4.0 5.0|
|6.0 7.0 8.0|
とすると,行ベクトル,列ベクトルを取り出す関数はcvGetRowとcvGetCol
vec = cvCreateMat(1,3,CV_32F);
として,実行すると,
cvGetRow(mat, vec, 0) -> |0.0 1.0 2.0|
cvGetRow(mat, vec, 1) -> |3.0 4.0 5.0|
cvGetRow(mat, vec, 2) -> |6.0 7.0 8.0|
となるが,
cvGetCol(mat, vec, 0) -> |0.0 1.0 2.0|
cvGetCol(mat, vec, 1) -> |1.0 2.0 3.0|
cvGetCol(mat, vec, 2) -> |2.0 3.0 4.0|
と変態的なベクトルが返ってくる.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s