简体   繁体   中英

OpenCV: src.depth() == dst.depth() && src.size == dst.size exception

I have a code that calculate the rotation and translation matrix as following:

matrix Matrix<double> rt = new Matrix<double>(3, 4);  
if (positiveCount[0] > positiveCount[1])  
{  
    rt = R[0].ConcateHorizontal(T[0].GetCol(2));  
}  
else  
{  
    rt = R[1].ConcateVertical(T[1].GetCol(2));  
}  

I get the error as shown in the image , 在此处输入图片说明

I checked all the matrices and elements, the size of all is match.

Has anybody experienced same error?

The problem refers to the matter of adaptability of matrix dimensions.

In the else-part:

rt = R[1].ConcateVertical(T[1].GetCol(2));  

is wrong, rt is a 3*4 matrix , R[1] is 3*3 and second column of T[1] is 3*1

so If we want to add T[1].GetCol(2) to R[1] horizontally we stick it to the matrix R to get a 3*4 matrix. There should be a size match when we are appending the rows/cols to another matrix.

so it should be replaced with :

 rt = R[1].ConcateHorizontal(T[1].GetCol(2));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM