Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flipping an image to get mirror effect

I am working on a video processing project which needs some flipping of frame. I tried using cvFlip but doesnt seem to flip along y axis (x axis working...) and results in segmentation fault. Is there any other option??

cv::Mat dst=src;      //src= source image from cam
cv::flip(dst, dst, 1);     //segmentation fault shown

imshow("flipped",dst);
like image 322
ranger Avatar asked Feb 17 '13 10:02

ranger


People also ask

How do I mirror flip an image?

Tap the Tools option at the bottom of the screen, then select Rotate from the menu that appears. At the bottom of the display you'll see an icon the has two arrows pointing at each other, with a dotted vertical line between them. Tap this and you should see your image flip back to a normal orientation.


2 Answers

cv::Mat src=imload("bla.png");
cv::Mat dst;               // dst must be a different Mat
cv::flip(src, dst, 1);     // because you can't flip in-place (leads to segfault)
like image 72
berak Avatar answered Oct 29 '22 12:10

berak


Use cv::flip and pass 1 as flipcode.

Looking at your edit with the sample code, you cannot flip in place. You need a separate destination cv::Mat:

cv::Mat dst;
cv::flip(src, dst, 1);
imshow("flipped",dst);
like image 40
juanchopanza Avatar answered Oct 29 '22 14:10

juanchopanza