Home > Net >  C # emgucv two mat multiplication problem (a 3 * 3 a 3 * 1) (cgi)
C # emgucv two mat multiplication problem (a 3 * 3 a 3 * 1) (cgi)

Time:11-27

I am now doing a project with mosaics of images is emgucv 3.2, the most basic of two images stitching has basically completed, but continue to do optimization stitching need to calculate the four registration figure vertex coordinates of the following is a c + + code
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//get the projection mapping matrix image of 2 to 1 3 * 3
Mat homo=findHomography (imagePoints2 imagePoints1, CV_RANSAC);
CalCorners (homo, mat2);//calculate the four registration figure vertex coordinates
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
the next part is calCorners function code:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//positioning image transformation after the four corners of the
Void calCorners (const Mat & amp; H, const Mat & amp; SRC)
{
/SRC/H to transform matrix for the need to transform the image

//calculate the angular point registration figure (homogeneous coordinate system to describe)
Double v2 []={0, 1};//the top left corner
Double v1 [3].//after the transformation of coordinate values
//a column vector ` this way of form the vector associated with Mat, Mat also modify accordingly modify vector
Mat V2= Mat (3, 1, CV_64FC1, v2);
Mat V1= Mat (3, 1, CV_64FC1, v1);
V1 V2=H *; *//element
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
, find the related information for mat as there is no similar to c + + c # can directly assign initial values (like the lines of code mat V2=mat (3, 1, CV_64FC1, V2); ) the v2 array directly to plug into the mat
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Below is I modify the code (don't know right)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Double [] v2=new double [] {0, 1};//the top left corner
Double [] v1=new double [3].//after the transformation of coordinate values
//a column vector ` this way of form the vector associated with Mat, Mat also modify accordingly modify vector
Mat V2=new Mat (3, 1, DepthType Cv64F, 1);
Mat V1=new Mat (3, 1, DepthType Cv64F, 1);

Matrix MatrixV2=new Matrix (v2).
Matrix MatrixV1=new Matrix (v1);

V2=matrixV2. Mat;//use matrix first in an array, and then converted into a mat
V1=matrixV1. Mat;

CvInvoke. Multiply (V1 V2, H, 1);


Because emgucv for surf lookup feature points on image mosaicing based information online is really too small, find the feature points and the joining together just can't find a case, csdn100 integral under the two cases, one is a fake, a s long, or (2) written several versions of the emgucv,
There is no way, to the opencv c + + code change one by one, but two mat do multiplication when scarlet letter (above), c # an error here,
Emgu. CV. Util. CvException: "OpenCV: The operation is neither 'array op array' (where The arrays have The same size and The same number of channels), nor 'array op scalar', nor 'scalar op array'" , has examined The data, Multiply this function as a support is multiplied by The same size of mat? For H is 3 * 3 V1 V2 is 3 * 1, project in it is stuck, checked emgucv mat, as if is that a few methods, can not find a solution, can only come for years,,


CodePudding user response:

Or I think if I can do your own matrix multiplication, is to get the mat in the location of the value, then according to the rules of matrix multiplication, himself, position calculated the value of the
Just now I find a class that is access to the inside of the mat value
V1. [0]=MatExtension GetValue (H, 0, 0) * v2 [0] + MatExtension GetValue (H, 0, 1) * v2. [1] + MatExtension GetValue (H, 0, 2) * v2 [2].
V1. [1]=MatExtension GetValue (H, 1, 0) * v2 [0] + MatExtension GetValue (H, 1, 1) * v2. [1] + MatExtension GetValue (H, 1, 2) * v2 [2].
V1. [2]=MatExtension GetValue (H, 2, 0) * v2 [0] + MatExtension GetValue (H, 2, 1) * v2. [1] + MatExtension GetValue (H, 2, 2) * v2 [2].

Console. WriteLine (" v1 0: "+ v1 [0]).
Console. WriteLine (" v1 1: "+ v1 [1]).
Console. WriteLine (" v1 2: "+ v1 [2]).

H is 3 * 3 matrix v2 mat type: double v2 []={0, 1};//the top left corner
But I test if value is wrong, the location of the synthetic figure or
  •  Tags:  
  • C#
  • Related