【问题标题】:cv.h: file not found opencvcv.h:找不到文件 opencv
【发布时间】:2018-06-15 01:07:06
【问题描述】:

我正在运行这段代码:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv; 
using namespace std;

int main( int argc, char** argv ) {
    if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0; }

但这对我不起作用,因为当我编写 cmake 时它会在我的屏幕上显示此错误。在终端:

cv.h:找不到文件。

谁能帮帮我?一个月前它还在工作。

【问题讨论】:

    标签: opencv computer-vision


    【解决方案1】:

    你有链接问题,试试这个;

    g++ `pkg-config --cflags --libs opencv` filename.cpp -o filename
    

    【讨论】:

    • 非常感谢!!!它现在正在工作。 :D 你知道如何修复以使用 Makelist 运行吗?
    • cmake_minimum_required(2.8 版) 项目(rubicSolver) find_package(OpenCV REQUIRED) add_executable(main main.cpp) target_link_libraries(main ${OpenCV_LIBS})
    • @eiki 这正是我在 CMakeLists 文件中的内容,但它不起作用。知道为什么吗?
    • 啊,好吧,我发现了我的问题:我已经安装了 3.0 版,并且正在学习 2 版的教程...
    【解决方案2】:

    如果是 Visual Studio,您可以更改链接器属性。 对于 Makefile,您需要确保 opencv_dir 设置正确。

    【讨论】:

      猜你喜欢
      • 2022-09-28
      • 2021-04-14
      • 1970-01-01
      • 2013-05-07
      • 1970-01-01
      • 2015-12-09
      • 2016-10-11
      • 2012-03-28
      • 2018-06-26
      相关资源
      最近更新 更多