Quick way to share information: no copying required. Although, if you change one matrix, the other will change (obviously!)
int inputData[600][400]; cv::Mat videoFrame(600, 400, CV_32UC1, inputData);
Please note that any further call to OpenCV on the video frame that changes its type / size will allocate a new part of the memory in which the result will be saved.
If you want to have separate data matrices, you can use memcpy - the fastest way to duplicate data:
memcpy((char*)inputData, (char*)videoFrame.data, 600*400*sizeof(int) );
The problem with this approach is that it is not safe at all. What if videoFrame does not have int type? (Most likely, this is char). What if it is not permanently stored in memory (can happen)? ...
source share