Difference between revisions of "OpenCV/WishList/ConvertPointsHomogeneous"
From ProgrammingExamples
< OpenCV
Daviddoria (Talk | contribs) |
Daviddoria (Talk | contribs) m |
||
Line 1: | Line 1: | ||
− | |||
OpenCV Error: Assertion failed (_dst.fixedType()) in convertPointsHomogeneous | OpenCV Error: Assertion failed (_dst.fixedType()) in convertPointsHomogeneous | ||
Line 11: | Line 10: | ||
#include <iostream> | #include <iostream> | ||
#include <string> | #include <string> | ||
+ | |||
+ | void UseDoubles(); | ||
+ | void UseFloats(); | ||
int main( int argc, char* argv[]) | int main( int argc, char* argv[]) | ||
+ | { | ||
+ | //UseDoubles(); | ||
+ | UseFloats(); | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | void UseDoubles() | ||
{ | { | ||
// Create the known projection matrix | // Create the known projection matrix | ||
Line 22: | Line 31: | ||
std::cout << "Thomogeneous: " << Thomogeneous << std::endl; | std::cout << "Thomogeneous: " << Thomogeneous << std::endl; | ||
− | + | ||
//cv::Mat T(3,1,cv::DataType<double>::type); // translation vector | //cv::Mat T(3,1,cv::DataType<double>::type); // translation vector | ||
cv::Mat T; | cv::Mat T; | ||
− | cv::convertPointsHomogeneous(Thomogeneous, T); | + | //cv::convertPointsHomogeneous(Thomogeneous, T); |
+ | cv::convertPointsFromHomogeneous(Thomogeneous, T); | ||
std::cout << "T: " << T << std::endl; | std::cout << "T: " << T << std::endl; | ||
+ | } | ||
− | + | void UseFloats() | |
+ | { | ||
+ | // Create the known projection matrix | ||
+ | cv::Mat Thomogeneous(1,4,cv::DataType<float>::type);// This returns 1? | ||
+ | //cv::Mat Thomogeneous(4,1,cv::DataType<float>::type);// This returns -1? | ||
+ | //cv::Mat Thomogeneous(4,1,CV_32FC1);// This returns -1? | ||
+ | //cv::Mat Thomogeneous(1,4,CV_32FC1); // This returns 1? | ||
+ | |||
+ | std::cout << "Thomogeneous.depth() = " << Thomogeneous.depth() << std::endl; | ||
+ | std::cout << "Thomogeneous.checkVector(3) = " << Thomogeneous.checkVector(3) << std::endl; | ||
+ | std::cout << "Thomogeneous.checkVector(4) = " << Thomogeneous.checkVector(4) << std::endl; | ||
+ | |||
+ | std::cout << "Before setting values" << std::endl; | ||
+ | std::cout << "Thomogeneous.channels() = " << Thomogeneous.channels() << std::endl; | ||
+ | std::cout << "Thomogeneous.rows() = " << Thomogeneous.rows << std::endl; | ||
+ | std::cout << "Thomogeneous.cols() = " << Thomogeneous.cols << std::endl; | ||
+ | /* | ||
+ | Thomogeneous.at<float>(0,0) = -2.8058e-01; | ||
+ | Thomogeneous.at<float>(1,0) = -6.8326e-02; | ||
+ | Thomogeneous.at<float>(2,0) = 5.1458e-07; | ||
+ | Thomogeneous.at<float>(3,0) = 5.1458e-07; | ||
+ | */ | ||
+ | |||
+ | Thomogeneous.at<float>(0,0) = -2.8058e-01; | ||
+ | Thomogeneous.at<float>(0,1) = -6.8326e-02; | ||
+ | Thomogeneous.at<float>(0,2) = 5.1458e-07; | ||
+ | Thomogeneous.at<float>(0,3) = 5.1458e-07; | ||
+ | |||
+ | std::cout << "After setting values" << std::endl; | ||
+ | std::cout << "Thomogeneous.channels() = " << Thomogeneous.channels() << std::endl; | ||
+ | std::cout << "Thomogeneous.rows() = " << Thomogeneous.rows << std::endl; | ||
+ | std::cout << "Thomogeneous.cols() = " << Thomogeneous.cols << std::endl; | ||
+ | |||
+ | std::cout << "Thomogeneous: " << Thomogeneous << std::endl; | ||
+ | |||
+ | //cv::Mat T(3,1,cv::DataType<double>::type); // translation vector | ||
+ | cv::Mat T; | ||
+ | //cv::convertPointsHomogeneous(Thomogeneous, T); | ||
+ | cv::convertPointsFromHomogeneous(Thomogeneous, T); | ||
+ | |||
+ | std::cout << "T: " << T << std::endl; | ||
} | } | ||
Latest revision as of 11:17, 13 August 2011
OpenCV Error: Assertion failed (_dst.fixedType()) in convertPointsHomogeneous
ConvertPointsHomogeneous.cxx
#include "opencv2/core/core.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> #include <string> void UseDoubles(); void UseFloats(); int main( int argc, char* argv[]) { //UseDoubles(); UseFloats(); return 0; } void UseDoubles() { // Create the known projection matrix cv::Mat Thomogeneous(4,1,cv::DataType<double>::type); Thomogeneous.at<double>(0,0) = -2.8058e-01; Thomogeneous.at<double>(1,0) = -6.8326e-02; Thomogeneous.at<double>(2,0) = 5.1458e-07; Thomogeneous.at<double>(3,0) = 5.1458e-07; std::cout << "Thomogeneous: " << Thomogeneous << std::endl; //cv::Mat T(3,1,cv::DataType<double>::type); // translation vector cv::Mat T; //cv::convertPointsHomogeneous(Thomogeneous, T); cv::convertPointsFromHomogeneous(Thomogeneous, T); std::cout << "T: " << T << std::endl; } void UseFloats() { // Create the known projection matrix cv::Mat Thomogeneous(1,4,cv::DataType<float>::type);// This returns 1? //cv::Mat Thomogeneous(4,1,cv::DataType<float>::type);// This returns -1? //cv::Mat Thomogeneous(4,1,CV_32FC1);// This returns -1? //cv::Mat Thomogeneous(1,4,CV_32FC1); // This returns 1? std::cout << "Thomogeneous.depth() = " << Thomogeneous.depth() << std::endl; std::cout << "Thomogeneous.checkVector(3) = " << Thomogeneous.checkVector(3) << std::endl; std::cout << "Thomogeneous.checkVector(4) = " << Thomogeneous.checkVector(4) << std::endl; std::cout << "Before setting values" << std::endl; std::cout << "Thomogeneous.channels() = " << Thomogeneous.channels() << std::endl; std::cout << "Thomogeneous.rows() = " << Thomogeneous.rows << std::endl; std::cout << "Thomogeneous.cols() = " << Thomogeneous.cols << std::endl; /* Thomogeneous.at<float>(0,0) = -2.8058e-01; Thomogeneous.at<float>(1,0) = -6.8326e-02; Thomogeneous.at<float>(2,0) = 5.1458e-07; Thomogeneous.at<float>(3,0) = 5.1458e-07; */ Thomogeneous.at<float>(0,0) = -2.8058e-01; Thomogeneous.at<float>(0,1) = -6.8326e-02; Thomogeneous.at<float>(0,2) = 5.1458e-07; Thomogeneous.at<float>(0,3) = 5.1458e-07; std::cout << "After setting values" << std::endl; std::cout << "Thomogeneous.channels() = " << Thomogeneous.channels() << std::endl; std::cout << "Thomogeneous.rows() = " << Thomogeneous.rows << std::endl; std::cout << "Thomogeneous.cols() = " << Thomogeneous.cols << std::endl; std::cout << "Thomogeneous: " << Thomogeneous << std::endl; //cv::Mat T(3,1,cv::DataType<double>::type); // translation vector cv::Mat T; //cv::convertPointsHomogeneous(Thomogeneous, T); cv::convertPointsFromHomogeneous(Thomogeneous, T); std::cout << "T: " << T << std::endl; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(ConvertPointsHomogeneous) FIND_PACKAGE(OpenCV REQUIRED ) INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} ) ADD_EXECUTABLE(ConvertPointsHomogeneous ConvertPointsHomogeneous.cxx) TARGET_LINK_LIBRARIES(ConvertPointsHomogeneous opencv_core opencv_highgui opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_calib3d opencv_legacy opencv_contrib )