0

こんにちは、インスタント OpenCV スターター ブックの最初のデモである lena.jpg を表示しようとしています。

「hello world」を簡単に構築してプレイできます。

問題のコード

    // opencv header files
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/core/core.hpp"
    // namespaces declaration
    using namespace cv;
    using namespace std;
    // create a variable to store the image
    Mat image;
    int main( int argc, char** argv )
    {
    // open the image and store it in the 'image' variable
    // Replace the path with where you have downloaded the image
    // image=imread("<path to image">/lena.jpg");
    image=imread("/home/nigel/Documents/ffmpeg/tests/lena.jpg");
    // create a window to display the image
    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
    // display the image in the window created
    imshow( "Display window", image );
    // wait for a keystroke
    waitKey(0);
    return 0;
    }

エラー

    g++ -Wall -fexceptions 'pkg-config --cflags opencv' -g "pkg-config --cflags
    opencv' -c/home/nigel/Drone/Test2/main.cpp -o obj/Debug/Drone/Test2/main.o
    g++:fatal error:no input files
    compilation terminated
    process terminated with status 1 (0 minutes, 0 seconds)

lena.jpg のさまざまなパスを試しました。lena.jpg を lena.pnm から変更しました。パスが正しいかどうかわかりません。

OpenCvを初めて使用する場合は、助けていただければ幸いです

4

1 に答える 1

0

このエラーは、ソース コード ファイルが g++ に渡されない場合に発生します。これにより、コマンドライン引数にエラーがあると思われます。

注目すべきいくつかのスポット:

  • 行の 2 番目の pkg-config の前に引用符があるようです

     'pkg-config --cflags opencv' -g "pkg-config --cflags opencv' 
    

  • -c と /home/.../main.cpp の間にスペースがないようです

  • 于 2013-07-11T04:15:23.743 に答える