OpenCV에서 Mat2 이미지에 Point2f imagePoints를 쓰려고했습니다. 나는 아래의 링크를 따라 가고 있었다.벡터에서 매트 만들기 <point2f> 어설 션 오류 오류
Create Mat from vector<point2f>
는하지만 점점 오전 오류 '어설 션 실패'. 도와주세요.
코드 :
std::vector<cv::Point3d> objectPoints;
std::vector<cv::Point2d> imagePoints;
cv::Mat intrisicMat(3, 3, cv::DataType<double>::type);
intrisicMat.at<double>(0, 0) = param.focalLength.first;
intrisicMat.at<double>(0, 1) = 0;
intrisicMat.at<double>(0, 2) = param.principalPoint.first;
intrisicMat.at<double>(1, 0) = 0;
intrisicMat.at<double>(1, 1) = param.focalLength.second;
intrisicMat.at<double>(1, 2) = param.principalPoint.second;
intrisicMat.at<double>(2, 0) = 0;
intrisicMat.at<double>(2, 1) = 0;
intrisicMat.at<double>(2, 2) = 1;
cv::Mat rVec(3, 1, cv::DataType<double>::type); // Rotation vector
rVec.at<double>(0) = 0;
rVec.at<double>(1) = 0;
rVec.at<double>(2) = 0;
cv::Mat tVec(3, 1, cv::DataType<double>::type); // Translation vector
tVec.at<double>(0) = 0;
tVec.at<double>(1) = 0;
tVec.at<double>(2) = 0;
cv::Mat distCoeffs(5, 1, cv::DataType<double>::type); // Distortion vector
distCoeffs.at<double>(0) = param.distortionRadial.at(0);
distCoeffs.at<double>(1) = param.distortionRadial.at(1);
distCoeffs.at<double>(2) = param.distortionTangential.first;
distCoeffs.at<double>(3) = param.distortionTangential.second;
distCoeffs.at<double>(4) = param.distortionRadial.at(2);
projectPoints(objectPoints, rVec, tVec, intrisicMat, distCoeffs, imagePoints);
Mat depthImage = Mat(imagePoints);
imwrite("E:/softwares/1.8.0.71/bin/depthImage.jpg", depthImage);
cout << "depthImage.channels()=" << depthImage.channels() << endl;
오류 :
OpenCV Error: Assertion failed (image.channels() == 1 || image.channels() == 3 || image.channels() == 4) in cv::imwrite_, file E:\softwares\opencv-3.1.0\opencv-3.1.0\modules\imgcodecs\src\loadsave.cpp, line 455
내 이미지가이 개 채널을 가지고 있습니다. 그래서 ImWrite()가 어설 션 오류를 던지고 있습니다. 이렇게하지 않으면 이미지 포인트를 사용하여 매트 이미지를 어떻게 만들 수 있습니까?
코드 및 전체 오류 로그를 보여주십시오. –
OpenCV 오류 : 어설 션이 실패했습니다 (image.channels() == 1 || image.channels() == 3 || image.channels() == 4) cv :: imwrite_ 파일 E : \ softwares \ opencv- 3.1.0 \ opencv-3.1.0 \ modules \ imgcodecs \ src \ loadsave.cpp, 줄 455 – MThomas
이것은 내 코드입니다 .. projectPoints (objectPoints, rVec, tVec, intrisicMat, distCoeffs, imagePoints); 매트 포인트 매트 = 매트 (imagePoints); imwrite ("E : /softwares/1.8.0.71/bin/depthImage.png", pointsMat); – MThomas