vdenotaris vdenotaris - 29 days ago 21
C++ Question

Shift image content with OpenCV

Starting from an image, I would like to shift its content to the top of 10 pixels, without change the size and filling the sub image

width x 10
on bottom with black.

For instance, the original:

Original

And the shifted:

Shifted

Is there a function to perform directly this operation with OpenCV?

Answer

Is there a function to perform directly this operation with OpenCV?

http://code.opencv.org/issues/2299

or you would do this

    cv::Mat out = cv::Mat::zeros(frame.size(), frame.type());
    frame(cv::Rect(0,10, frame.cols,frame.rows-10)).copyTo(out(cv::Rect(0,0,frame.cols,frame.rows-10)));