OpenCV 【六】————youtu(图像)——旋转保存图片
生活随笔
收集整理的這篇文章主要介紹了
OpenCV 【六】————youtu(图像)——旋转保存图片
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
OpenCV Mat結(jié)構(gòu)的圖片 旋轉(zhuǎn)順時(shí)針90度 180度 270度 逆時(shí)針90度?
Mat matRotateClockWise90(Mat src)
{if (src.empty()){qDebug()<<"RorateMat src is empty!";}// 矩陣轉(zhuǎn)置transpose(src, src);//0: 沿X軸翻轉(zhuǎn); >0: 沿Y軸翻轉(zhuǎn); <0: 沿X軸和Y軸翻轉(zhuǎn)flip(src, src, 1);// 翻轉(zhuǎn)模式,flipCode == 0垂直翻轉(zhuǎn)(沿X軸翻轉(zhuǎn)),flipCode>0水平翻轉(zhuǎn)(沿Y軸翻轉(zhuǎn)),flipCode<0水平垂直翻轉(zhuǎn)(先沿X軸翻轉(zhuǎn),再沿Y軸翻轉(zhuǎn),等價(jià)于旋轉(zhuǎn)180°)return src;
}Mat matRotateClockWise180(Mat src)//順時(shí)針180
{if (src.empty()){qDebug() << "RorateMat src is empty!";}//0: 沿X軸翻轉(zhuǎn); >0: 沿Y軸翻轉(zhuǎn); <0: 沿X軸和Y軸翻轉(zhuǎn)flip(src, src, 0);// 翻轉(zhuǎn)模式,flipCode == 0垂直翻轉(zhuǎn)(沿X軸翻轉(zhuǎn)),flipCode>0水平翻轉(zhuǎn)(沿Y軸翻轉(zhuǎn)),flipCode<0水平垂直翻轉(zhuǎn)(先沿X軸翻轉(zhuǎn),再沿Y軸翻轉(zhuǎn),等價(jià)于旋轉(zhuǎn)180°)flip(src, src, 1);return src;//transpose(src, src);// 矩陣轉(zhuǎn)置
}Mat matRotateClockWise270(Mat src)//順時(shí)針270
{if (src.empty()){qDebug() << "RorateMat src is empty!";}// 矩陣轉(zhuǎn)置//transpose(src, src);//0: 沿X軸翻轉(zhuǎn); >0: 沿Y軸翻轉(zhuǎn); <0: 沿X軸和Y軸翻轉(zhuǎn)transpose(src, src);// 翻轉(zhuǎn)模式,flipCode == 0垂直翻轉(zhuǎn)(沿X軸翻轉(zhuǎn)),flipCode>0水平翻轉(zhuǎn)(沿Y軸翻轉(zhuǎn)),flipCode<0水平垂直翻轉(zhuǎn)(先沿X軸翻轉(zhuǎn),再沿Y軸翻轉(zhuǎn),等價(jià)于旋轉(zhuǎn)180°)flip(src, src, 0);return src;
}Mat myRotateAntiClockWise90(Mat src)//逆時(shí)針90°
{if (src.empty()){qDebug()<<"mat is empty!";}transpose(src, src);flip(src, src, 0);
?
cv::Mat depth_image_(FLAGS_deptrum_output_height,FLAGS_deptrum_output_width,CV_16UC1,&depth_image[0]);std::string depth_filename = FLAGS_deptrum_prefix + "depth.png";cv::imwrite(depth_filename.c_str(), depth_image_);std::string depth_filename = FLAGS_deptrum_prefix + "depth.txt";SaveDepth(depth_filename, depth_image, FLAGS_deptrum_output_height, FLAGS_deptrum_output_width);// Save obj_image_bg png 旋轉(zhuǎn)圖片std::string depth_filename_ir = FLAGS_deptrum_prefix + "ir.png";cv::Mat srcCopy = cv::Mat(obj_image_bg.rows, obj_image_bg.cols, obj_image_bg.depth());cv::transpose(obj_image_bg, srcCopy);cv::flip(srcCopy, srcCopy, -1);cv::imwrite(depth_filename_ir.c_str(), srcCopy);// Save obj_image_rgb bmpobj_image_rgb = image_rgb.clone();std::string depth_filename_rgb = FLAGS_deptrum_prefix + "rbg.bmp";cv::imwrite(depth_filename_rgb.c_str(), obj_image_rgb);cv::Mat roi_on_depth_image_(rgb_height, rgb_width, CV_16UC1, &roi_on_depth_image[0]);std::string rgb_depth_image_name = FLAGS_deptrum_prefix + "depth.png";cv::imwrite(rgb_depth_image_name.c_str(), roi_on_depth_image_);// The order of edge imageint edge_image_num_ = 0;
?
總結(jié)
以上是生活随笔為你收集整理的OpenCV 【六】————youtu(图像)——旋转保存图片的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 茫茫的天涯茫茫的路是什么歌呢
- 下一篇: python-opencv 定位识别读表