###前提・実現したいこと
Raspberry pi 2でOpenCV(2.4.0)を利用できるように設定を行っているのですが、コンパイルでエラーが発生しました。
全くの初心者で解決方法がわからないため、ご教授お願いいたします。
###発生している問題・エラーメッセージ
g++ sample.cpp /tmp/ccnPKNgp.o: 関数 `main' 内: sample.cpp:(.text+0x9c): `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x110): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x124): `cv::_OutputArray::_OutputArray(cv::Mat&)' に対する定義されていない参照です sample.cpp:(.text+0x13c): `cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x150): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x164): `cv::_OutputArray::_OutputArray(cv::Mat&)' に対する定義されていない参照です sample.cpp:(.text+0x17c): `cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x190): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x1a4): `cv::_OutputArray::_OutputArray(cv::Mat&)' に対する定義されていない参照です sample.cpp:(.text+0x1bc): `cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x1f0): `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x23c): `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x288): `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' に対する定義されていない参照です sample.cpp:(.text+0x2d8): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x2ec): `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' に対する定義されていない参照です sample.cpp:(.text+0x33c): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x350): `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' に対する定義されていない参照です sample.cpp:(.text+0x3a0): `cv::_InputArray::_InputArray(cv::Mat const&)' に対する定義されていない参照です sample.cpp:(.text+0x3b4): `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' に対する定義されていない参照です sample.cpp:(.text+0x3d4): `cv::waitKey(int)' に対する定義されていない参照です /tmp/ccnPKNgp.o: 関数 `cv::Mat::~Mat()' 内: sample.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3c): `cv::fastFree(void*)' に対する定義されていない参照です /tmp/ccnPKNgp.o: 関数 `cv::Mat::release()' 内: sample.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x58): `cv::Mat::deallocate()' に対する定義されていない参照です collect2: ld returned 1 exit status
###該当のソースコード
#include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> int main(int argc, char *argv[]) { cv::Mat src_img = cv::imread("../../image/lenna.png", 1); if(src_img.empty()) return -1; cv::Mat v_img, h_img, b_img; cv::flip(src_img, v_img, 0); // 水平軸で反転(垂直反転) cv::flip(src_img, h_img, 1); // 垂直軸で反転(水平反転) cv::flip(src_img, b_img, -1); // 両方の軸で反転 cv::namedWindow("vertical flip image", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO); cv::namedWindow("horizontal flip image", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO); cv::namedWindow("both flip image", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO); cv::imshow("vertical flip image", v_img); cv::imshow("horizontal flip image", h_img); cv::imshow("both flip image", b_img); cv::waitKey(0); }
###試したこと
下記のページなどを参考にOpenCV2.4.0のインストールを行いました。
http://homemadegarbage.0t0.jp/raspberry-pi-opencv3-1-0
https://iwaki2009.blogspot.jp/2015/08/raspberry-pi-2-opencv-2411.html
サンプルプログラムは下記のページのものを利用させていただきました。
http://opencv.jp/cookbook/opencv_img.html#image-flip
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/07 06:36 編集
2017/06/07 06:54
2017/06/12 03:16
2017/06/12 05:15