以下是将float数组转换为cv::Mat的C++代码示例:

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    // 定义float数组
    float arr[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };

    // 定义cv::Mat
    Mat mat(2, 3, CV_32FC1, arr);

    // 打印cv::Mat
    cout << mat << endl;

    return 0;
}

在上面的代码中,我们首先定义了一个float数组,并将其作为数据源来创建一个2x3的cv::Mat。CV_32FC1表示每个元素都是单精度浮点数。最后,我们将cv::Mat打印到控制台上。

用c++写出将float数组转成cvmat

原文地址: https://www.cveoy.top/t/topic/bTWI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录