FC2カウンター FPGAの部屋 Ultra96 のDebianにインストールしたOpenCVのC++サンプルデザインをコンパイル
fc2ブログ

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

Ultra96 のDebianにインストールしたOpenCVのC++サンプルデザインをコンパイル

Ultra96-V2 に ikwzm/ZynqMP-FPGA-Linux をインストール4(OpenCV 4.1.0 のインストール)”の続き。

OpenCV 4.1.0 のC++ のサンプルデザインをコンパイルしてみようとしたが、結局うまく行かなかった。よって、以前、”Ultra96 のDebianにインストールしたOpenCV-3.4.3のC++サンプルデザインをコンパイル”でやったように、OpenCV 3.4.3 をインストールして、OpenCV 3.4.3 のC++ のサンプルデザインをコンパイルした。

、”Ultra96 のDebianにインストールしたOpenCV-3.4.3のC++サンプルデザインをコンパイル”を参考にして、ホーム・ディレクトリの直下に bin ディレクトリを作成した。
Ultra96V2_80_190810.png

bin ディレクトリの下に、g++_opencv ファイルを作成した。
Ultra96V2_81_190810.png

#!/bin/sh

if [ $# -eq 1 ] ; then
    g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `pkg-config --libs opencv`;
else
    echo "g++_opencv < C++ file name >"
fi


Ultra96V2_82_190810.png

g++_opencv ファイルのプロバティを Allow executing file as program に変更した。
Ultra96V2_83_190810.png

.bashrc に export PATH=$PATH:~/bin を追加した。
Ultra96V2_84_190810.png

opencv-4.1.0/samples/cpp に行って、
g++_opencv facedetect.cpp
を実行した。
Ultra96V2_85_190810.png

そうするとエラーが発生した。
Ultra96V2_86_190810.png

いろいろと検索してみて、試したのだが、どうしてもコンパイルできなかった。
仕方ないので、以前インストールした、OpenCV 3.4.3 をインストールした。インストール方法は、OpenCV 4.1.0 と同じだ。ただ、3.4.3.zip をダウンロードするところが違うだけだ。
Ultra96V2_91_190811.png

今度は、opencv-3.4.3/samples/cpp/ ディレクトリに行って、
g++_opencv facedetect.cpp
を行うと、成功した。
./facedetect ../data/lena.jpg
Ultra96V2_89_190811.png

Ultra96V2_90_190811.png

ちなみに 、OpenCV 3.4.3 をインストールした状態で、いろいろとOpenCV 4.1.0 の facedetect サンプル・デザインのコンパイルを試してみた。
OpenCV4.0をソースコードからインストールする”を参考に
g++ facedetect.cpp -o facedetect -I/usr/local/include/opencv4/ -L/usr/local/lib64/ -lopencv_core
をやってみたがエラーだった。エラー内容を示す。

fpga@debian-fpga:~/opencv-4.1.0/samples/cpp$ g++ facedetect.cpp -o facedetect -I/usr/local/include/opencv4/ -L/usr/local/lib64/ -lopencv_core
/usr/bin/ld: /tmp/ccZJ8MHe.o: in function `main':
facedetect.cpp:(.text+0xc8): undefined reference to `cv::VideoCapture::VideoCapture()'
/usr/bin/ld: facedetect.cpp:(.text+0xe8): undefined reference to `cv::CascadeClassifier::CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0xf0): undefined reference to `cv::CascadeClassifier::CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0x12c): undefined reference to `cv::CommandLineParser::CommandLineParser(int, char const* const*, std::__cxx11::basic_string, std::allocator > const&)'
/usr/bin/ld: facedetect.cpp:(.text+0x16c): undefined reference to `cv::CommandLineParser::has(std::__cxx11::basic_string, std::allocator > const&) const'
/usr/bin/ld: facedetect.cpp:(.text+0x2f4): undefined reference to `cv::CommandLineParser::has(std::__cxx11::basic_string, std::allocator > const&) const'
/usr/bin/ld: facedetect.cpp:(.text+0x3bc): undefined reference to `cv::CascadeClassifier::load(std::__cxx11::basic_string, std::allocator > const&)'
/usr/bin/ld: facedetect.cpp:(.text+0x41c): undefined reference to `cv::samples::findFile(std::__cxx11::basic_string, std::allocator > const&, bool, bool)'
/usr/bin/ld: facedetect.cpp:(.text+0x428): undefined reference to `cv::CascadeClassifier::load(std::__cxx11::basic_string, std::allocator > const&)'
/usr/bin/ld: facedetect.cpp:(.text+0x510): undefined reference to `cv::VideoCapture::open(int, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x5b4): undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x608): undefined reference to `cv::VideoCapture::open(std::__cxx11::basic_string, std::allocator > const&, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x6a4): undefined reference to `cv::samples::findFile(std::__cxx11::basic_string, std::allocator > const&, bool, bool)'
/usr/bin/ld: facedetect.cpp:(.text+0x6b8): undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x730): undefined reference to `cv::VideoCapture::isOpened() const'
/usr/bin/ld: facedetect.cpp:(.text+0x768): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
/usr/bin/ld: facedetect.cpp:(.text+0x76c): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
/usr/bin/ld: facedetect.cpp:(.text+0x7bc): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: facedetect.cpp:(.text+0x88c): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: facedetect.cpp:(.text+0x9b8): undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
/usr/bin/ld: facedetect.cpp:(.text+0xa18): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: facedetect.cpp:(.text+0xaa8): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0xab0): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0xad0): undefined reference to `cv::VideoCapture::~VideoCapture()'
/usr/bin/ld: facedetect.cpp:(.text+0xc9c): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0xcac): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()'
/usr/bin/ld: facedetect.cpp:(.text+0xcd4): undefined reference to `cv::VideoCapture::~VideoCapture()'
/usr/bin/ld: /tmp/ccZJ8MHe.o: in function `detectAndDraw(cv::Mat&, cv::CascadeClassifier&, cv::CascadeClassifier&, double, bool)':
facedetect.cpp:(.text+0xf00): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/usr/bin/ld: facedetect.cpp:(.text+0xf5c): undefined reference to `cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_, double, double, int)'
/usr/bin/ld: facedetect.cpp:(.text+0xf90): undefined reference to `cv::equalizeHist(cv::_InputArray const&, cv::_OutputArray const&)'
/usr/bin/ld: facedetect.cpp:(.text+0x1008): undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector, std::allocator > >&, double, int, int, cv::Size_, cv::Size_)'
/usr/bin/ld: facedetect.cpp:(.text+0x10b0): undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector, std::allocator > >&, double, int, int, cv::Size_, cv::Size_)'
/usr/bin/ld: facedetect.cpp:(.text+0x1318): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_, int, cv::Scalar_ const&, int, int, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x13e8): undefined reference to `cv::rectangle(cv::_InputOutputArray const&, cv::Point_, cv::Point_, cv::Scalar_ const&, int, int, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x13f8): undefined reference to `cv::CascadeClassifier::empty() const'
/usr/bin/ld: facedetect.cpp:(.text+0x1490): undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector, std::allocator > >&, double, int, int, cv::Size_, cv::Size_)'
/usr/bin/ld: facedetect.cpp:(.text+0x15a4): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_, int, cv::Scalar_ const&, int, int, int)'
/usr/bin/ld: facedetect.cpp:(.text+0x1634): undefined reference to `cv::imshow(std::__cxx11::basic_string, std::allocator > const&, cv::_InputArray const&)'
/usr/bin/ld: /tmp/ccZJ8MHe.o: in function `cv::samples::findFileOrKeep(std::__cxx11::basic_string, std::allocator > const&, bool)':
facedetect.cpp:(.text._ZN2cv7samples14findFileOrKeepERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZN2cv7samples14findFileOrKeepERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x2c): undefined reference to `cv::samples::findFile(std::__cxx11::basic_string, std::allocator > const&, bool, bool)'
/usr/bin/ld: /tmp/ccZJ8MHe.o: in function `std::__cxx11::basic_string, std::allocator > cv::CommandLineParser::get, std::allocator > >(std::__cxx11::basic_string, std::allocator > const&, bool) const':
facedetect.cpp:(.text._ZNK2cv17CommandLineParser3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEET_RKS7_b[_ZNK2cv17CommandLineParser3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEET_RKS7_b]+0x38): undefined reference to `cv::CommandLineParser::getByName(std::__cxx11::basic_string, std::allocator > const&, bool, cv::Param, void*) const'
/usr/bin/ld: /tmp/ccZJ8MHe.o: in function `double cv::CommandLineParser::get(std::__cxx11::basic_string, std::allocator > const&, bool) const':
facedetect.cpp:(.text._ZNK2cv17CommandLineParser3getIdEET_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZNK2cv17CommandLineParser3getIdEET_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x30): undefined reference to `cv::CommandLineParser::getByName(std::__cxx11::basic_string, std::allocator > const&, bool, cv::Param, void*) const'
collect2: error: ld returned 1 exit status


OpenCV4.0 簡易マニュアル パターン認識演習”を参考に
g++ -std=c++11 `pkg-config opencv4 --cflags --libs` facedetect.cpp -o facedetect
をやってみたが、エラーだった。エラー内容を示す。

fpga@debian-fpga:~/opencv-4.1.0/samples/cpp$ g++ -std=c++11 `pkg-config opencv4 --cflags --libs` facedetect.cpp -o facedetect
Package opencv4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv4' found
facedetect.cpp: In function 'int main(int, const char**)':
facedetect.cpp:65:29: error: 'samples' has not been declared
     if (!nestedCascade.load(samples::findFileOrKeep(nestedCascadeName)))
                             ^~~~~~~
facedetect.cpp:67:23: error: 'samples' has not been declared
     if (!cascade.load(samples::findFile(cascadeName)))
                       ^~~~~~~
facedetect.cpp:84:24: error: 'samples' has not been declared
         image = imread(samples::findFileOrKeep(inputName), IMREAD_COLOR);
                        ^~~~~~~
facedetect.cpp:87:31: error: 'samples' has not been declared
             if (!capture.open(samples::findFileOrKeep(inputName)))
                               ^~~~~~~
facedetect.cpp:96:24: error: 'samples' has not been declared
         image = imread(samples::findFile("lena.jpg"), IMREAD_COLOR);
                        ^~~~~~~

  1. 2019年08月11日 14:40 |
  2. Ultra96
  3. | トラックバック:0
  4. | コメント:0

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック URL
https://marsee101.blog.fc2.com/tb.php/4610-d80955f3
この記事にトラックバックする(FC2ブログユーザー)