Weird numbers with cv::Mat
I have this struct:
struct Result{
Result(const cv::Mat1f &descriptor, const Keypoint &keypoint) :
descriptor(descriptor), keypoint(keypoint){
std::cout<<"constructor="<<std::endl<<descriptor<<std::endl;
}
const cv::Mat1f descriptor;
const Keypoint keypoint;
};
Where Keypoint
I think is irrelevant for this question (but I'll post it if you ask about it).
I have this function:
void foo(...,vector<Result> &res){
...
std::vector<float> vec;
//fill vec
cv::Mat1f desc(1,128,vec.data());
std::cout<<"desc="<<std::endl<<desc<<std::endl;
res.push_back(Result(desc, Keypoint(...)));
}
Which is called like this:
std::vector<Result> res;
for(int i=0; i<N; i++){
foo(..., res);
std::cout<<"res="<<std::endl<<res.back().descriptor<<std::endl;
}
Sometimes, the three std::cout
print the same value. But in some cases, the last print (the one inside after calling foo
) gives different results:
desc=
[2, 10, 54, 3, 2, 2, 5, 6, 7, 27, 111, 5, 3, 17, 11, 12, 8, 31, 113, 6, 3, 6, 10, 27, 2, 8, 63, 9, 13, 17, 2, 1, 54, 10, 16, 5, 13, 22, 18, 85, 37, 18, 17, 3, 99, 113, 29, 41, 113, 7, 21, 5, 28, 40, 34, 113, 12, 6, 14, 10, 93, 113, 8, 23, 54, 21, 50, 31, 20, 20, 7, 78, 18, 69, 82, 29, 86, 108, 9, 20, 77, 44, 98, 54, 17, 20, 15, 113, 27, 44, 29, 14, 53, 74, 10, 31, 8, 16, 36, 45, 39, 8, 4, 1, 35, 105, 45, 16, 11, 5, 4, 3, 6, 28, 53, 92, 32, 5, 5, 2, 27, 61, 23, 14, 9, 4, 6, 4]
constrcutor=
[2, 10, 54, 3, 2, 2, 5, 6, 7, 27, 111, 5, 3, 17, 11, 12, 8, 31, 113, 6, 3, 6, 10, 27, 2, 8, 63, 9, 13, 17, 2, 1, 54, 10, 16, 5, 13, 22, 18, 85, 37, 18, 17, 3, 99, 113, 29, 41, 113, 7, 21, 5, 28, 40, 34, 113, 12, 6, 14, 10, 93, 113, 8, 23, 54, 21, 50, 31, 20, 20, 7, 78, 18, 69, 82, 29, 86, 108, 9, 20, 77, 44, 98, 54, 17, 20, 15, 113, 27, 44, 29, 14, 53, 74, 10, 31, 8, 16, 36, 45, 39, 8, 4, 1, 35, 105, 45, 16, 11, 5, 4, 3, 6, 28, 53, 92, 32, 5, 5, 2, 27, 61, 23, 14, 9, 4, 6, 4]
res=
[1.1986551e+10, 0, 8.6976665e+23, 0, 0.00012219016, 1.0372148e-08, 6.3080874e-10, 0, 7, 27, 111, 5, 127.62504, 0, 0, 0, 8.6650199e-38, 0, 8.6650199e-38, 0, 8.6653068e-38, 0, 8.6653068e-38, 0, 0, 0, 0, 0, 8.6650512e-38, 0, 8.6650916e-38, 0, 0, 0, 0, 0, 0, 22.000002, 0, 0, 0, 0, 8.6651656e-38, 0, 0, 0, 8.6652015e-38, 0, 0, 0, 0, 5, 1.6213893e+09, 0, 0, 0, 12, 6, 0, 0, 144173.88, 0, 8.6651544e-38, 0, 0, 21.000174, 50, 31, 20, 20, 7, 78, 18, 69, 0, 0, 144173.88, 0 ...