【发布时间】:2017-04-02 06:34:03
【问题描述】:
在 OpenCV 2.4.10 中,我想将行矩阵转换为 12x12 矩阵:
//Extraction SIFT
SiftDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute( img_1, keypoints_1, descriptors_1);
extractor.compute( img_2, keypoints_2, descriptors_2);
Mat matrix(12,12, CV_8UC3, Scalar(0));
int j = 0;
for (int x = 0; x<12; x++)
{
for (int y = 0; y<12; y++)
{
matrix [x][y] = descriptors_2[x][j];
j++
}
}
第 67 行的错误 no match for ‘operator[]’ (operand types are ‘cv::Mat’ and ‘int’)。
谁能帮我?谢谢。
【问题讨论】:
-
你需要使用
matrix.at<unsigned char>(y,x) = descriptors.at< unsigned char>(j,x)注意访问每个元素时应该是行列顺序见docs.opencv.org/2.4.10/modules/core/doc/… -
你为什么不直接
reshape垫子? (同样的功能在 2.4.x 中也可用)
标签: c++ opencv compiler-errors sift operation