How to merge 3 matrices into 1 in opencv?

后端 未结 3 2101
离开以前
离开以前 2021-01-06 18:33

I have three matrices, each of size 4x1. I want to copy all of these matrices to another matrix of size 4x3 and call it R. Is there a

3条回答
  •  -上瘾入骨i
    2021-01-06 19:05

    You can use

    Mat R(3, 4, CV_32F); // [3 rows x 4 cols] with float values
    mat1.copyTo(R.row(0));
    mat2.copyTo(R.row(1));
    mat3.copyTo(R.row(2));
    

    or

    Mat R(4, 3, CV_32F); // [4 rows x 3 cols] with float values
    mat1.copyTo(R.col(0));
    mat2.copyTo(R.col(1));
    mat3.copyTo(R.col(2));
    

    Alternatively, as @sub_o suggested, you can also use hconcat()/vconcat() to concatenate matrices.

提交回复
热议问题