2022-05-16 在HackFun OpenCV开发板上验证代码之求最值

2022-05-16 在HackFun OpenCV开发板上验证代码之求最值,第1张

void MainWindow::Test_FindMinAndMax_P63_C3_9()
{
    float a[12] = {1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10, 0};

    Mat img = Mat(3, 4, CV_32FC1, a);
    Mat imgs = Mat(2, 3, CV_32FC2, a);

    double minVal, maxVal;
    Point minIdx, maxIdx;

    minMaxLoc(img, &minVal, &maxVal, &minIdx, &maxIdx);
    cout << "max val in img: " << maxVal << " " << " at " << maxIdx << endl;
    cout << "min val in img: " << minVal << " " << " at " << minIdx << endl;

    Mat imgs_re = imgs.reshape(1, 4);
    minMaxLoc(imgs_re, &minVal, &maxVal, &minIdx, &maxIdx);
    cout << "max val in imgs: " << maxVal << " " << " at " << maxIdx << endl;
    cout << "min val in imgs: " << minVal << " " << " at " << minIdx << endl;

    return;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1295662.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存