Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I would recommend:

MasterFrame=Mat(Height,Width,CV_UC3,[pointer to data buffer],[you MAY need to specify stride implicitly]).clone();

It is much faster than cycling through the elements.

If you can arrange for the data to not be overwritten (or go out of scope) until you are done with it, for example by saving consecutive images to different buffers, you can omit the .clone() and then it would be even faster as the data is never actually copied.

pay attention that the order of channels may not be what you expect if the camera returns RGB, as OpenCV expects BGR by default.

guy

I would recommend:

MasterFrame=Mat(Height,Width,CV_UC3,[pointer MasterFrame=Mat(Height,Width,CV_8UC3,[pointer to data buffer],[you MAY need to specify stride implicitly]).clone();

It is much faster than cycling through the elements.

If you can arrange for the data to not be overwritten (or go out of scope) until you are done with it, for example by saving consecutive images to different buffers, you can omit the .clone() and then it would be even faster as the data is never actually copied.

pay attention that the order of channels may not be what you expect if the camera returns RGB, as OpenCV expects BGR by default.

guy