OpenCV provides a function to flip an image.
void flip(const Mat& src, Mat& dst, int flipCode)
Flips a 2D array around vertical, horizontal or both axes.
src – The source array
dst – The destination array; will have the same size and same type as src
flipCode – Specifies how to flip the array: 0 means flipping around the x-axis, positive (e.g., 1) means flipping around y-axis, and negative (e.g., -1) means flipping around both axes. See also the discussion below for the formulas.
The function flip flips the array in one of three different ways (row and column indices are 0-based):