Data type changed after .clone or copyTo


The original Mat is of double which we can see with .type() and elemSize1().
Another Mat object was declared in the same time as the original one. However, the data type of the other one is not the same after
original.clone() or original.copyTo(another, …).
Is there a way to keep the type while making a copy or clone of the original one.

that shouldn’t happen because copyTo implicitly calls

m.create(this->size(), this->type());

as specified here: OpenCV: cv::Mat Class Reference

please provide minimal but complete source code that reproduces the issue.

1 Like

@crackwitz Thanks for reply. Sorry, I found a bit problem.
The original Mat was involved in a matrix multiplication and result in a float type. I have been thinking that the multiplication should give me one double. Now, the question changed. How can I get a Mat of double from a multiplication like
T1*F*T2, wher T1 and T2 are of float and F is of double.

again code, please. :wink:

	F = T1*Fn*T2 ;  // Fn   6,8 type and elemSize1   T1 and T2 5,4

	Snow = something(F);

	if (Snow > pf)
		cout << F.type() << " \\ " << F.elemSize1();
		oMRet = F.clone();
		pf = Snow;
		cout << oMRet.type() << " || " << oMRet.elemSize1(); // 5,4  
1 Like