gpt4 book ai didi

c++ - 在 OpenCV 中逐行减去矩阵

转载 作者:太空宇宙 更新时间:2023-11-04 14:18:02 25 4
gpt4 key购买 nike

OpenCV(C++ API)中是否有任何内置方法逐行减去两个矩阵

我有以下矩阵:

Mat A(10,2, CV_64F);
Mat B(1,2, CV_64F);
Mat C(10,2, CV_64F);

C = A - B;

// B is a 1 x 2 matrix, A is a 10 x 2 matrix, and C is a 10 x 2 matrix.

A 中的每一行都必须从 B 中减去并作为一行存储在 C 中

最佳答案

我是这样解决的:

Mat A(10,2, CV_64F);
Mat B(1,2, CV_64F);
Mat C(0,2, CV_64F);
Mat D(0,2, CV_64F);

for(int i=0;i<A.rows;i++)
{
C=(A.row(i)-B.row(0));
D.push_back(C.row(0));
}

cout<<"A\n"<<A<<endl;
cout<<"B\n"<<B<<endl;
cout<<"C\n"<<C<<endl;
cout<<"D\n"<<D<<endl;

关于c++ - 在 OpenCV 中逐行减去矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9712144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com