Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

please avoid copying single pixels, and manual memory management in general. rather:

// get pointer from Mat:
CV_Assert(original.isContinuous()); // e.g. not a ROI
CV_Assert(original.type() == CV_32F); // make sure, the type fits !
float * ptr = original.ptr<float>();
// process ptr

// set pointer:
float *image_data = ... // something from c
Mat res(original.size(), original.type(), image_data); //this will copy the *pointer*,not the data!
return res.clone(); // deep copy