Ejemplo n.º 1
0
// 重置OpenGL窗口大小
void CglWnd::ReSizeGLScene( GLsizei width, GLsizei height )
{
	if (height==0)										// 防止被零除
	{
		height=1;										// 将Height设为1
	}
	float mat_p[16];
	float mat_t[16];
	float mvp[16];
	float aspect = (float)width/height;

	glViewport(0,0,width,height);						// 重置当前的视口

	matIdentity(mvp);
	matIdentity(mat_p);
	matIdentity(mat_t);
	viewHeight = 720/2;
	viewWidth = viewHeight*aspect;
	// 设置视口的大小
	matPerspective((float*)mat_p, 90,  aspect, 200.0f, 500.0f);
	//设置镜头
	matLookAt((float*)mat_t, 0,0,viewHeight, 0,0,0, 0,1,0);

	matMult((float*)mvp, (float*)mat_p, (float*)mat_t);
	
	//z=0 平面的投影大小
	// set the transformation
	glUniformMatrix4fv(viewprojLoc, 1, GL_FALSE, (float*)mvp);
	resetMainTexVertex();
}
Ejemplo n.º 2
0
//!Estimate transform from a set of points
void AffineTransform::estimateFromPoints(const CvMat * points1, const CvMat * points2)
{
    cv::Mat matPerspective(3, 3, CV_64FC1);
    //cvFindHomography(points1, points2, &matPerspective);
    cv::findHomography(matFromOldMat(points1), matFromOldMat(points2), matPerspective);

//Todo: adapt cvGetAffineTransform--it's in Warp.cpp
    matPerspective *= 1. / matPerspective.at<double>(2, 2);
    for(int x=0; x < ROWS; x++)
        for(int y=0; y < COLS; y++)
        {
            cvmSet(*this, x, y, matPerspective.at<double>(x, y));
        }
}