Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if you use a Mat constructor with a data pointer, like you do here:

cv::Mat1f desc(1,128,vec.data());

this will copy only the pointer ,NOT the pixels (or whatever it holds).

once you leave that function, your local vector goes out of scope, and your Mat has a "dangling pointer", pointing to nowwhere.

remedy: make sure to copy the actual data (deep copy), like:

res.push_back(Result(desc.clone(), Keypoint(...)));

if you use a Mat constructor with a data pointer, like you do here:

cv::Mat1f desc(1,128,vec.data());

this will copy only the pointer ,NOT the pixels (or whatever it holds).

once you leave that function, your local vector goes out of scope, and your Mat has a "dangling pointer", pointing to nowwhere.

remedy: make sure to copy the actual data (deep copy), like:

res.push_back(Result(desc.clone(), Keypoint(...)));

or:

cv::Mat1f desc(vec, true); // also a deep copy