Discontinuous Mat (Using Mat.data = address instead of copyTo)
Hello, I receive image sections frame-by-frame from moving images on a conveyor belt.
Using ROIs I piece the frame-by-frame images together to make one image. This works fine.
Except I have to use copyTo instead of just moving pointers. This makes sense as the original Mat would become discontinuous. Except Mat supports discontinuous, so I'm wondering if there is a better way.
Here's what I do now:
In constructor:
m_InData = Mat(m_h, m_w, CV_8UC4);
m_ScrollingBuffer = Mat(m_h*m_NumBufPerScrollingBuf, m_w, CV_8UC4);
for (int i=0; i<m_NumBufPerScrollingBuf;i++)
m_ScrollingBufferROI.push_back(Mat(m_ScrollingBuffer, Range(i*m_h, (i+1)*m_h), Range(0,m_w)));
And at Run-Time, after I get a frame:
GetImageAddress(&address);
m_InData.data = address;
for (int i=1; i<=m_NumBufPerScrollingBuf-1; i++)
m_ScrollingBufferROI[i].copyTo(m_ScrollingBufferROI[i-1]);
m_InData.copyTo(m_ScrollingBufferROI[m_NumBufPerScrollingBuf-1]);
But I'd like to something more elegant like:
for (int i=1; i<=m_NumBufPerScrollingBuf-1; i++)
m_ScrollingBufferROI[i-1].data = m_ScrollingBufferROI[i].data;
m_ScrollingBufferROI[m_NumBufPerScrollingBuf-1].data = address;
But the above doesn't work (I suspect because of the non-continuous nature.)
Suggestions?
Thanks and sorry if a similar/duplicate question shows up.
Gunter