0

当我尝试运行教程时
,我在 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;
}
4

1 回答 1

0

我使用本教程(预构建版本)安装了 OpenCV
,当我尝试阅读介绍时,我在“混合两个图像”教程中遇到错误,具体samples::findFile()
是通过将版本从 3.5.3 更改为 4.5 来解决问题.3. 不要忘记根据步骤更改属性部分

于 2021-09-01T05:30:46.350 回答