void vpTemplateTrackerWarpHomography::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const { vpHomography H1 = getHomography(p1); vpHomography H2 = getHomography(p2); vpHomography H = H1*H2; getParam(H,pres); }
int main() { clock_t begin = clock(); // CODE int u = 1125; cv::Mat thetaMatrix, output; cv::Mat H = getHomography(image0Points, image1Points); double theta = atan2(-H.at<double>(2, 1), -H.at<double>(2, 0)); double thetaMatrixTmp[2][2] = { {cos(theta), -sin(theta)}, {sin(theta), cos(theta)} }; cv::Mat(2, 2, CV_64F, &thetaMatrixTmp).copyTo(thetaMatrix); std::cout << "H\n" << H << "\n"; changeHomographyCoords(H, thetaMatrix); std::cout << "H'\n" << H << "\n"; output = halfProjectiveWarp(H, image1, u, thetaMatrix, true); // CODE clock_t end = clock(); double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; std::cout << "It took " << elapsed_secs << " seconds\n"; cv::namedWindow("Gray image", CV_WINDOW_AUTOSIZE); cv::imshow("Gray image", output); cv::waitKey(0); imwrite("output.jpg", output); return 0; }
void PerspectiveTransform::transform(float t, const cv::Mat& source, cv::Mat& result) const { cv::warpPerspective(source, result, getHomography(t, source), source.size(), cv::INTER_CUBIC); }
int main(int argc,char** argv) { const int image_count=10; cv::Mat Thermal_image[image_count]; cv::Mat RGB_image[image_count]; cv::Mat Homography[image_count]; cv::SparseMat A[image_count];//degrading matrix int mfactor=2;//magnification factor std::string Thermal[]= {"43","44","45","46","47","48","49","50","51","52"}; std::string RGB[]= {"T00043VB","T00044VB","T00045VB","T00046VB","T00047VB","T00048VB","T00049VB","T00050VB","T00051VB","T00052VB"}; std::ostringstream Thermal_input[image_count]; std::ostringstream RGB_input[image_count]; for(int n=0; n<image_count; n++) { Thermal_input[n]<<"./input/"<<Thermal[n]<<".bmp"; } for(int n=0; n<image_count; n++) { Thermal_image[n]=cv::imread(Thermal_input[n].str()); } for(int n=0; n<image_count; n++) { RGB_input[n]<<"./input/"<<RGB[n]<<".jpg"; } for(int n=0; n<image_count; n++) { RGB_image[n]=cv::imread(RGB_input[n].str()); } cv::Mat ideal=cv::imread("./input/ideal.bmp"); cv::Mat dst(ideal.rows,ideal.cols,CV_8UC3); int range=20; for(int n=0; n<image_count; n++) { std::cout<<"image_count="<<n<<std::endl; //Homography[n]=getHomography(degimage[n],degimage[image_count-1]); //Homography[n]=getHomography(RGB_image[0],RGB_image[n]); Homography[n]=getHomography(Thermal_image[0],Thermal_image[n]); std::cout<<Homography[n]<<std::endl; if(!n) { Homography[n]=(cv::Mat_<float>(3,3)<<1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f); } A[n]=CreateDegradingMatrix(ideal,mfactor,Homography[n]); } int iteration=100; float beta=1.3f;//convergence speed //BTV cv::Size BTVkernel(7,7); float alpha=0.7f; float lambda=0.03f; SuperResolution(Thermal_image,dst,A,image_count,iteration,beta,range,ideal,BTVkernel,alpha,lambda); }
void vpTemplateTrackerWarpHomography::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const { vpHomography H = getHomography(ParamM); vpHomography Hinv = H.inverse(); getParam(Hinv, ParamMinv); }