从C到C++的投影点转换
我尝试将CVjPojtPosits 2中的简单代码转换成C++,因此我使用CV::PosikPosits。我使用cv名称空间来避免在所有内容前面加上cv:: 这根本无法编译。projectPoints的参数有什么问题?我找到的参数为projectPoints提供了以下声明: 然后,您需要找到要传递给distcoefs参数的内容—可能是一个空的Mat对象?因为0不是常数矩阵& 希望有帮助从C到C++的投影点转换,c++,opencv,C++,Opencv,我尝试将CVjPojtPosits 2中的简单代码转换成C++,因此我使用CV::PosikPosits。我使用cv名称空间来避免在所有内容前面加上cv:: 这根本无法编译。projectPoints的参数有什么问题?我找到的参数为projectPoints提供了以下声明: 然后,您需要找到要传递给distcoefs参数的内容—可能是一个空的Mat对象?因为0不是常数矩阵& 希望有帮助 Mat_<double>* object_points = new Mat_<
Mat_<double>* object_points = new Mat_<double>(10, 3, CV_64FC1);
Mat_<double>* rotation_vector = new Mat_<double>(3,3, CV_64FC1);
Mat_<double>* translation_vector = new Mat_<double>(Size(3,1), CV_64FC1);
Mat_<double>* intrinsic_matrix = new Mat_<double>(Size(3, 3), CV_64FC1);
vector<Point2f>* image_points = new vector<Point2f>;
double t[] = {
70, 95, 120
};
double object[] = {
150, 200, 400,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0,
0,0,0
};
double rotation[] = {
0, 1, 0,
-1, 0, 0,
0, 0, 1
};
double intrinsic[] = {
-500, 0, 320,
0, -500, 240,
0, 0, 1
};
int main() {
for (int i = 0; i < 30; i++) {
(*object_points)[i/3][i%3] = object[i];
}
for (int i = 0; i < 9; i++) {
(*rotation_vector)[i/3][i%3] = rotation[i];
(*intrinsic_matrix)[i/3][i%3] = intrinsic[i];
}
for (int i = 0; i < 3; i++) {
(*translation_vector)[0][i] = t[i];
}
projectPoints(
object_points,
rotation_vector,
translation_vector,
intrinsic_matrix,
0,
image_points
);
}
void projectPoints(const Mat& objectPoints, const Mat& rvec, const Mat& tvec, const Mat& cameraMatrix, const Mat& distCoeffs, vector<Point2f>& imagePoints);
void projectPoints(const Mat& objectPoints, const Mat& rvec, const Mat& tvec, const Mat& cameraMatrix, const Mat& distCoeffs, vector<Point2f>& imagePoints, Mat& dpdrot, Mat& dpdt, Mat& dpdf, Mat& dpdc, Mat& dpddist, double aspectRatio=0);
projectPoints(
*object_points,
*rotation_vector,
*translation_vector,
*intrinsic_matrix,
0,
*image_points
);