简体   繁体   中英

Merge every member of cv::Mat A with cv::Mat B in order to create a cv::Mat C with [a(x,y),b(x,y)] as a result

I am trying to generate a cv::Mat C from two other matrices in order to get a third matrix that is made by 2-D points generated by combining 1-D points of matrices A and B.

My problem is that everything I tried only concatenates the matrices, and does not really merge each point with another, which would result in a 3-D matrix of 2-D points.

Does anyone can help me with this issue?

Thank you so much.

Just to be more clear:

What I have is A = [(0, 1, 2),(3, 4, 5)] and B=[(5, 4, 3),(2, 1, 0)] and I would like to create

 C = {[(0,5), (1,4), (2,3)],
      [(3,2), (4,1), (5,0)]}.

Thank you

You can do this by creating a custom type matrix. See here

Basically, you need to create a specialization of DataType class that handles points (pairs of data).

Or you can use the given matrices of std::complex<double> instead of integers as an ugly shortcut. Example code in the documentation:

Mat B = Mat_<std::complex<double> >(3, 3);

However, this solution might not be the real solution to your general problem. Google XY problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM