3路视频大于屏幕问题

#ifndef _DEBUG
#pragma comment(lib,"opencv_core246")
#pragma comment(lib,"opencv_highgui246")
#pragma comment(lib,"opencv_imgproc246")
#else
#pragma comment(lib,"opencv_core246d")
#pragma comment(lib,"opencv_highgui246d")
#pragma comment(lib,"opencv_imgproc246d")
#endif

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace cv;
using namespace std;


// 图像翻转(镜像)  
void ImageReversal(IplImage* imgsrc)  
{  
	Mat img = imgsrc;
	int tempb,tempg,tempr;
	int height = img.rows;
	int width = img.cols;

	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;

		}
	}

	//cout << (getTickCount()-t)*1.0/getTickFrequency() << endl;

	waitKey(33);
}  

//逆时针旋转图像degree角度(原尺寸)
void rotateImage(Mat img, Mat img_rotate,int degree)
{
	//旋转中心为图像中心
	CvPoint2D32f center;  
	center.x=float (img.cols/2.0+0.5);
	center.y=float (img.rows/2.0+0.5);
	//计算二维旋转的仿射变换矩阵
	float m[6];            
	Mat M( 2, 3, CV_32F, m );
	//Mat getRotationMatrix2D(Point2f center, double angle, double scale)
	M = getRotationMatrix2D(center, degree,1);
	//cv2DRotationMatrix( center, degree,1, &M);
	//void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
	//变换图像,并用黑色填充其余值
	warpAffine(img,img_rotate,M,img.size());
	//cvWarpAffine(img,img_rotate, &M,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,cvScalarAll(0) );
}

int main(int ac, char** av)
{

	CvCapture* capture0 = cvCreateCameraCapture( 1 ); 
	CvCapture* capture1 = cvCreateCameraCapture( 0 ); 
	//CvCapture* capture2 = cvCreateCameraCapture( 2 ); 

	IplImage *frame0,*frame1,*frame2;
	int64 t=0;

	Mat frame0_Mat,frame1_Mat;
	Mat panorama_Mat(480*1.2,640*4.1,CV_8UC3);

	while (1)
	{
		t = getTickCount();
		frame0 = cvQueryFrame( capture0 );
		frame1 = cvQueryFrame( capture1 );
		//frame2 = cvQueryFrame( capture2 );

		frame0_Mat = frame0;
		frame1_Mat = frame1;

		//两个图像融合为一个
		cv::Mat panorama_0(panorama_Mat,cv::Rect(0,15,frame0->width,frame0->height));
		frame0_Mat.copyTo(panorama_0);
		
		cv::Mat panorama_1(panorama_Mat,cv::Rect(frame1_Mat.cols-25,0,frame1_Mat.cols,frame1_Mat.rows));
		frame1_Mat.copyTo(panorama_1);

		cv::Mat panorama_2(panorama_Mat,cv::Rect(frame1_Mat.cols*2-25,0,frame1_Mat.cols,frame1_Mat.rows));
		frame1_Mat.copyTo(panorama_2);



		//rotateImage(frame1, frame1, 180);  
		//ImageReversal(frame1);

		//cvShowImage("frame0",frame0);
		//cvShowImage("frame1",frame1);
		//cvShowImage("frame2",frame2);

		imshow("panorama_Mat",panorama_Mat);

		int key = cvWaitKey(33);
		if( key == 27 ) break;

		cout << (getTickCount()-t)*1.0/getTickFrequency() << endl;

	}

	cout << "EORROR" << endl;
	cvWaitKey(0);
	cvDestroyWindow("left");
	cvDestroyWindow("mid");
	cvDestroyWindow("right");

	return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值