图像镜像
来源:互联网 发布:百度云 for mac 编辑:程序博客网 时间:2024/05/01 04:55
/************************************************************************
* 对图像做镜像
* 2013/12/11
/************************************************************************/
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <stdio.h>
#include <iostream>
using namespace cv;
using namespace std;
#define CAPTURE
int main()
{
#ifdef CAPTURE
IplImage* left_frame;//左边图像
//IplImage* right_frame;//右边图像
CvCapture* capture0 = cvCreateCameraCapture( 0 );
//CvCapture* capture1 = cvCreateCameraCapture( 1 );
for (int i=0;i<30;i++)
{
left_frame = cvQueryFrame( capture0 );
}
int width = left_frame->width;
int height = left_frame->height;
#else
Mat img = imread("m1.jpg");
int width = img.cols;
int height = img.rows;
#endif
Mat img;
int64 t;
while (1)
{
t = getTickCount();
left_frame = cvQueryFrame( capture0 );
img = left_frame;
imshow("init",img);
//src = src*1.3;
//right_frame = cvQueryFrame(capture1);
//Mat src2(right_frame);
//两个图像融合为一个
//Mat sss(MAX(left_frame->height,right_frame->height),right_frame->width+left_frame->width,CV_8UC3);
//cv::Mat half(sss,cv::Rect(0,0,left_frame->width,left_frame->height));
//src.copyTo(half);
//cv::Mat right_half(sss,cv::Rect(src.cols,0,src2.cols,src2.rows));
//src2.copyTo(right_half);
//int centerX=width>>1;
//int centerY=heigh>>1;
int tempb,tempg,tempr;
for (int y=1;y<height-1;y++)
{
uchar* imgP=img.ptr<uchar>(y);
for (int x=0;x<width/2;x++)
{
tempb=imgP[3*x];
tempg=imgP[3*x+1];
tempr=imgP[3*x+2];
imgP[3*x] = imgP[3*(width-x)];
imgP[3*x+1] = imgP[3*(width-x)+1];
imgP[3*x+2] = imgP[3*(width-x)+2];
imgP[3*(width-x)] = (uchar)tempb;
imgP[3*(width-x)+1] = (uchar)tempg;
imgP[3*(width-x)+2] = (uchar)tempr;
}
}
imshow("result",img);
cout << (getTickCount()-t)*1.0/getTickFrequency() << endl;
waitKey(33);
}
}
* 对图像做镜像
* 2013/12/11
/************************************************************************/
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <stdio.h>
#include <iostream>
using namespace cv;
using namespace std;
#define CAPTURE
int main()
{
#ifdef CAPTURE
IplImage* left_frame;//左边图像
//IplImage* right_frame;//右边图像
CvCapture* capture0 = cvCreateCameraCapture( 0 );
//CvCapture* capture1 = cvCreateCameraCapture( 1 );
for (int i=0;i<30;i++)
{
left_frame = cvQueryFrame( capture0 );
}
int width = left_frame->width;
int height = left_frame->height;
#else
Mat img = imread("m1.jpg");
int width = img.cols;
int height = img.rows;
#endif
Mat img;
int64 t;
while (1)
{
t = getTickCount();
left_frame = cvQueryFrame( capture0 );
img = left_frame;
imshow("init",img);
//src = src*1.3;
//right_frame = cvQueryFrame(capture1);
//Mat src2(right_frame);
//两个图像融合为一个
//Mat sss(MAX(left_frame->height,right_frame->height),right_frame->width+left_frame->width,CV_8UC3);
//cv::Mat half(sss,cv::Rect(0,0,left_frame->width,left_frame->height));
//src.copyTo(half);
//cv::Mat right_half(sss,cv::Rect(src.cols,0,src2.cols,src2.rows));
//src2.copyTo(right_half);
//int centerX=width>>1;
//int centerY=heigh>>1;
int tempb,tempg,tempr;
for (int y=1;y<height-1;y++)
{
uchar* imgP=img.ptr<uchar>(y);
for (int x=0;x<width/2;x++)
{
tempb=imgP[3*x];
tempg=imgP[3*x+1];
tempr=imgP[3*x+2];
imgP[3*x] = imgP[3*(width-x)];
imgP[3*x+1] = imgP[3*(width-x)+1];
imgP[3*x+2] = imgP[3*(width-x)+2];
imgP[3*(width-x)] = (uchar)tempb;
imgP[3*(width-x)+1] = (uchar)tempg;
imgP[3*(width-x)+2] = (uchar)tempr;
}
}
imshow("result",img);
cout << (getTickCount()-t)*1.0/getTickFrequency() << endl;
waitKey(33);
}
}
0 0
- 图像镜像翻转
- 图像镜像翻转
- 图像镜像
- C++ 图像镜像
- 图像镜像
- 图像镜像
- RGB图像镜像
- 图像镜像
- 图像镜像变换
- matlab图像镜像
- 图像镜像_matlab
- C#图像镜像
- 图像镜像之水平镜像
- 图像镜像之竖直镜像
- 图像镜像与图像转置
- 图像镜像变换
- 图像处理之镜像
- 图像的镜像变换
- SL - ToolTip的试用
- VS调试总结
- 判断android app或者service是否存在
- 虚拟机
- Oracle 之 注释的添加和查看
- 图像镜像
- SL - 整理 - 给组件绑定资源文件值
- SL - 整理 - Loading状态的实现
- SL - SetBinding的用法
- SL - 摘录 - 输入验证
- SL - 摘录 - 解决PasswordBox的Password无法正常绑定的问题
- SL - 整理 - 输入更变事件(使即时输入内容能被更新到vm)
- SL - 整理 - WPF实现MDI窗体
- SL - 摘录 - 在MVVM模式下的VM层里使用线程的方法