Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV matrix multiplication with unknown number type
    primarykey
    data
    text
    <p>I'm having some processing i.e. some matrix operations using Mat in OpenCV and the following line gives error:</p> <pre><code>matC = matA*matB; </code></pre> <p>This time, the error is not that difficult to identify since I've already known that the matrix dimensions are correct and their number types are either CV_64FC1 or CV_32FC1. </p> <p>So, I can fix this error by identifying each matrix's number type (perhaps with some if-else) and replace with a temporary matrix (Mat) that is type compatible</p> <p>However, in terms of the implementation of OpenCV Mat multiplication, is it a good one? Do we really have to check the operands' number type (and even number of channel e.g. CV_64FC3, CV_64FC2) every time a matrix operation is performed?</p> <p>is this type of checking barely avoided? since matA or matB are probably returned from a function call such as solvePnP(..., matA, matB,...) and number type of matA, matB are undefined</p> <p>Thanks, </p> <p>PS: I've stuck with OpenCV matrix operation several times, problems with number type, number of channels...</p> <p>Edit 01:</p> <p>I'm sorry for not being clear in my question! but I'm doing my best to make myself clear</p> <p>my questions are:</p> <p>1) should I and how would I do to ensure matC = matA*matB is a error-free operation?</p> <p>2) in case there should be some checking before the operation, then, should I do that every time such matrix operation is performed? is there a better choice to not replicate such checking?</p> <p>Edit 02: </p> <p>here is what I currently do to perform the checking:</p> <pre><code>tmp1 = Vect32Homo(Mat(objPoints.at&lt;Vec3f&gt;(i))); if (s1To.depth() != tmp1.depth()) { printf("Different Number Type!"); s1To.convertTo(s1To, CV_64FC1); tmp1.convertTo(tmp1, CV_64FC1); } else { printf("Same Number Type!"); } tmp = s1To*tmp1; // error prone operation </code></pre> <p>As you may see that this attempt will not work if the two matrices have different number of channel</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload