posprocesamiento propio de c++ tensorRT

        float* data_image_0 = new float[3196944];
        float* data_image_1 = new float[3196944];
        float* data_image_2 = new float[3196944];
        //将数据copy至开辟内存的数组
        copy(output, output + 3196944, data_image_0);
        copy(output + 3196944, output + 6393888, data_image_1);
        copy(output + 6393888, output + 9590832, data_image_2);
        //将数组转化为矩阵
        MatrixXf eigMat1_back = Map<Matrix<float, 1788, 1788, RowMajor> >(data_image_0);
        MatrixXf eigMat1_pre_weld = Map<Matrix<float, 1788, 1788, RowMajor> >(data_image_1);
        MatrixXf eigMat1_weld = Map<Matrix<float, 1788, 1788, RowMajor> >(data_image_2);

        //计算preweld 且值为1
        MatrixXf eigMat1_max_1b0 = (eigMat1_back.array() < eigMat1_pre_weld.array()).cast<float>();
        MatrixXf eigMat1_max_1b2 = (eigMat1_weld.array() < eigMat1_pre_weld.array()).cast<float>();
        MatrixXf eigMat_preweld_result = eigMat1_max_1b0.array() * eigMat1_max_1b2.array();

        //计算weld  且值为2
        MatrixXf eigMat1_max_2b0 = (eigMat1_back.array() < eigMat1_weld.array()).cast<float>();
        MatrixXf eigMat1_max_2b1 = (eigMat1_pre_weld.array() < eigMat1_weld.array()).cast<float>();
        MatrixXf eigMat_result_ewld = eigMat1_max_2b0.array() * eigMat1_max_2b1.array();
        MatrixXf eigMat_weld_resuld = eigMat_result_ewld ;
        //cout << eigMat_weld_resuld;
        //中和结果
        MatrixXf eigMat_result = eigMat_weld_resuld.array() + eigMat_preweld_result.array();
        //矩阵转Mat
        //cout << eigMat_result;
        Mat  mat_23f;
        cv::eigen2cv(eigMat_result, mat_23f);
        //区域提取
        Rect roi_rect_1 = Rect(0, 447, 1788, 376);
        Mat image_rec_1 = mat_23f(roi_rect_1);
        //将数据类型转化为 CV_8UC1
        image_rec_1.convertTo(image_rec_1, CV_8UC1);
        //将图像变化到[1900,400]
        Mat resized_1;
        resize(image_rec_1, resized_1, Size(1900, 400), 0, 0, INTER_NEAREST);

Supongo que te gusta

Origin blog.csdn.net/weixin_67615387/article/details/129225998
Recomendado
Clasificación