Ask Your Question

Revision history [back]

Succinct way to assign values to Mat

I want to assign values to a 4x3 Mat. Right now, I'm doing it like this:

Mat P = Mat(Size(4, 3), CV_64F); //Create matrix with four corners of output image
P.at<double>(0,0)=0; P.at<double>(0,1)=inputImage.cols; P.at<double>(0,2)=inputImage.cols; P.at<double>(0,3)=0;
P.at<double>(1,0)=0; P.at<double>(1,1)=0; P.at<double>(1,2)=inputImage.rows; P.at<double>(1,3)=inputImage.rows;
P.at<double>(2,0)=1; P.at<double>(2,1)=1; P.at<double>(2,2)=1; P.at<double>(2,3)=1;

Is there a more succinct way like there is in other languages more like this?

P = [0, inputImage.cols, inputImage.cols, 0;
     0, 0, inputImage.rows, inputImage.rows;
     1, 1, 1, 1]

Succinct way to assign values to Mat

I want to assign values to a 4x3 Mat. Right now, I'm doing it like this:

Mat P = Mat(Size(4, 3), CV_64F); //Create matrix with four corners of output image
P.at<double>(0,0)=0; P.at<double>(0,1)=inputImage.cols; P.at<double>(0,2)=inputImage.cols; P.at<double>(0,3)=0;
P.at<double>(1,0)=0; P.at<double>(1,1)=0; P.at<double>(1,2)=inputImage.rows; P.at<double>(1,3)=inputImage.rows;
P.at<double>(2,0)=1; P.at<double>(2,1)=1; P.at<double>(2,2)=1; P.at<double>(2,3)=1;

Is there a more succinct way like there is in other languages more like this?

P = [0, inputImage.cols, inputImage.cols, 0;
     0, 0, inputImage.rows, inputImage.rows;
     1, 1, 1, 1]

Succinct way to assign values to Mat

I want to assign values to a 4x3 Mat. in C++. Right now, I'm doing it like this:

Mat P = Mat(Size(4, 3), CV_64F); //Create matrix with four corners of output image
P.at<double>(0,0)=0; P.at<double>(0,1)=inputImage.cols; P.at<double>(0,2)=inputImage.cols; P.at<double>(0,3)=0;
P.at<double>(1,0)=0; P.at<double>(1,1)=0; P.at<double>(1,2)=inputImage.rows; P.at<double>(1,3)=inputImage.rows;
P.at<double>(2,0)=1; P.at<double>(2,1)=1; P.at<double>(2,2)=1; P.at<double>(2,3)=1;

Is there a more succinct way like there is in other languages more like this?

P = [0, inputImage.cols, inputImage.cols, 0;
     0, 0, inputImage.rows, inputImage.rows;
     1, 1, 1, 1]