C++ 翻转图像以获得镜像效果
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14920264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 18:49:44 来源:igfitidea点击:
Flipping an image to get mirror effect
提问by ranger
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??
我正在处理一个需要翻转帧的视频处理项目。我尝试使用 cvFlip 但似乎没有沿 y 轴翻转(x 轴工作...)并导致分段错误。还有其他选择吗??
cv::Mat dst=src; //src= source image from cam
cv::flip(dst, dst, 1); //segmentation fault shown
imshow("flipped",dst);
回答by berak
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)
回答by juanchopanza
回答by Eric
The key is to create the dst
exactly like the src
:
关键是创建dst
完全类似于src
:
cv::Mat dst = cv::Mat(src.rows, src.cols, CV_8UC3);
cv::flip(src, dst, 1);
imshow("flipped", dst);