Ask Your Question
0

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

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

stereoMatching gravatar image
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
2

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

Vladislav Vinogradov gravatar image

Use convertTo method:

A.convertTo(B, B.type());
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

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

Seen: 91 times

Last updated: Dec 27 '13