Ask Your Question
1

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

asked 2013-12-27 09:56:09 -0600

stereoMatching gravatar image

updated 2020-10-29 14:40:58 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-12-27 10:34:31 -0600

Vladislav Vinogradov gravatar image

Use convertTo method:

A.convertTo(B, B.type());
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-27 09:56:09 -0600

Seen: 284 times

Last updated: Dec 27 '13