[英]Convert boost array to open cv mat
I try to convert a boost::array rightCamInfo.K to an opencv Mat cv::Mat K . 我尝试将boost :: array rightCamInfo.K转换为opencv Mat cv :: Mat K。 I didn't found any functions for this setting so I wrote an iterative approach:
我没有为此设置找到任何函数,所以我写了一个迭代方法:
float tempK[9];
cv::Mat K;
for (int i = 0; i < 9; i++) {
tempK[i] = rightCamInfo.K[i];
}
K = cv::Mat(3, 3, CV_64F, &tempK);
But this is giving me strange results. 但这给了我奇怪的结果。 The range of the given data is between 400 and 0 and the result matrix is around 5 * 10^(-315).
给定数据的范围在400到0之间,结果矩阵约为5 * 10 ^(-315)。 So obviously there are some conversion errors.
因此,显然存在一些转换错误。 What is wrong?
怎么了? Did I chose the wrong type for the matrix or does this array type is not fitting?
我为矩阵选择了错误的类型还是此数组类型不合适?
You should use CV_32F
not CV_64F
and point the first element of tempK
您应该使用
CV_32F
不CV_64F
和点的第一要素tempK
K = cv::Mat(3, 3, CV_32F, &tempK[0]);
or 要么
Mat K(3, 3, CV_32F, &tempK[0]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.