Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

copy data to cv::Mat with specific type assigned by the user

cv::Mat A(3, 3, CV_8UC1);
cv::Mat B;
B.create(A.size(), CV_32FC1);
std::cout<<A.type()<<", "<<B.type()<<std::endl;
A.copyTo(B);
std::cout<<A.type()<<", "<<B.type()<<std::endl;

I want to copy A to B without changing the type of B.

Any clean solution to do this without writing explicit loop?Thanks

ps : I don't want to convert B to CV_32FC1 after copied

copy data to cv::Mat with specific type assigned by the user

cv::Mat A(3, 3, CV_8UC1);
cv::Mat B;
B.create(A.size(), CV_32FC1);
std::cout<<A.type()<<", "<<B.type()<<std::endl;
A.copyTo(B);
std::cout<<A.type()<<", "<<B.type()<<std::endl;

I want to copy A to B without changing the type of B.

Any clean solution to do this without writing explicit loop?Thanks

ps : I don't want to convert B to CV_32FC1 after copied