Reputation: 29
I have a trouble now with opencv Mat.
Here's a function
void getMat(Mat a){
double b[3]={1,2,3};
a=Mat(3,1,CV_64FC1,b);
}
When I use the function in main
Mat mat(3,1,CV_64FC1);
getMat(mat);
but the result of mat is
[-9.255963134931783e+61;
-9.255963134931783e+61;
-9.255963134931783e+61]
so could someone help me out of the problem?
Thanks very much
Best
Jing
Upvotes: 1
Views: 1373
Reputation: 18341
Use reference parameter, and copyTo
the object;
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
void getMat(Mat &mat){
double b[3]={1,2,3};
Mat _mat(3,1,CV_64FC1,b);
_mat.copyTo(mat);
}
int main(){
Mat a;
getMat(a);
cout << a <<endl;
return 0;
}
/*
[1;
2;
3]
*/
Upvotes: 2