【问题标题】:opencv tutorial problem with samples::findFile()示例::findFile()的opencv教程问题
【发布时间】:2021-10-29 23:11:07
【问题描述】:

当我尝试运行 this 教程时
我在 samples::findFile()
上遇到了这个问题 我试过#include <opencv2/core/utility.hpp>
但同样的问题,有什么想法吗?
我收到此错误:

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using namespace cv;
// we're NOT "using namespace std;" here, to avoid collisions between the beta variable and std::beta in c++17
using std::cin;
using std::cout;
using std::endl;
int main(void)
{
    double alpha = 0.5; double beta; double input;
    Mat src1, src2, dst;
    cout << " Simple Linear Blender " << endl;
    cout << "-----------------------" << endl;
    cout << "* Enter alpha [0.0-1.0]: ";
    cin >> input;
    // We use the alpha provided by the user if it is between 0 and 1
    if (input >= 0 && input <= 1)
    {
        alpha = input;
    }
    src1 = imread(samples::findFile("LinuxLogo.jpg"));
    src2 = imread(samples::findFile("WindowsLogo.jpg"));
    if (src1.empty()) { cout << "Error loading src1" << endl; return EXIT_FAILURE; }
    if (src2.empty()) { cout << "Error loading src2" << endl; return EXIT_FAILURE; }
    beta = (1.0 - alpha);
    addWeighted(src1, alpha, src2, beta, 0.0, dst);
    imshow("Linear Blend", dst);
    waitKey(0);
    return 0;
}

【问题讨论】:

  • 请不要发布代码图片。您应该在问题中包含您的代码。

标签: c++ opencv3.3


【解决方案1】:

我使用this 教程(预构建版)安装了 OpenCV
当我试图回顾介绍时,我在“混合两个图像”教程中遇到了错误,特别是 samples::findFile()
该问题已通过将版本从 3.5.3 更改为 4.5.3 得到解决。也别忘了修改属性部分,按照this的步骤

【讨论】:

  • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-18
  • 2013-06-18
  • 2012-02-01
  • 2017-01-07
  • 1970-01-01
  • 1970-01-01
  • 2020-01-17
相关资源
最近更新 更多