Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

returning a Mat from a function

Hi. I am new to OpenCV. I have the following code that outputs garbage (some random numbers). Can you please help me understand the problem?

#include <opencv2/core/core.hpp>           
#include <opencv2/highgui/highgui.hpp>     
#include <opencv2/imgproc/imgproc.hpp>     

#include <iostream>                        

using namespace std;                       

cv::Mat transformToCVMatrix()              
{                                          
    double matrix[2][2] = { { 1.0, 0.0 },  
                            { 0.0, 1.0 }   
                          };                                     

    return cv::Mat(2, 2, CV_64FC1, matrix);
}                                          


int main()                                 
{                                          
    cv::Mat mat = transformToCVMatrix();   
    cout << mat << endl;                   
    cv::Mat imat = mat.inv();              
    cout << imat << endl;                   
    return 0;                              
}
click to hide/show revision 2
retagged

returning a Mat from a function

Hi. I am new to OpenCV. I have the following code that outputs garbage (some random numbers). Can you please help me understand the problem?

#include <opencv2/core/core.hpp>           
#include <opencv2/highgui/highgui.hpp>     
#include <opencv2/imgproc/imgproc.hpp>     

#include <iostream>                        

using namespace std;                       

cv::Mat transformToCVMatrix()              
{                                          
    double matrix[2][2] = { { 1.0, 0.0 },  
                            { 0.0, 1.0 }   
                          };                                     

    return cv::Mat(2, 2, CV_64FC1, matrix);
}                                          


int main()                                 
{                                          
    cv::Mat mat = transformToCVMatrix();   
    cout << mat << endl;                   
    cv::Mat imat = mat.inv();              
    cout << imat << endl;                   
    return 0;                              
}

returning a Mat from a function

Hi. I am new to OpenCV. I have the following code that outputs garbage (some random numbers). Can you please help me understand the problem?

#include <opencv2/core/core.hpp>           
#include <opencv2/highgui/highgui.hpp>     
#include <opencv2/imgproc/imgproc.hpp>     

#include <iostream>                        

using namespace std;                       

cv::Mat transformToCVMatrix()              
{                                          
    double matrix[2][2] = { { 1.0, 0.0 },  
                            { 0.0, 1.0 }   
                          };                                     

    return cv::Mat(2, 2, CV_64FC1, matrix);
}                                          


int main()                                 
{                                          
    cv::Mat mat = transformToCVMatrix();   
    cout << mat << endl;                   
    cv::Mat imat = mat.inv();              
    cout << imat << endl;                   
    return 0;                              
}