Eclipse3.8にてC++でOpenCVを使いたいです。
画像の表示はできたのですが、
グレースケール化→2値化処理
ができません。
Eclipseの設定が間違っているのか、使えない関数が多く、困っています。
よろしくお願いいたします。
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
using namespace std;
int main() {
cv::Mat input_img = cv::imread("/home/LisaXXXX/デスクトップ/test5/0.jpg"); cv::Mat gray_img; cv::Mat bin_img; cv::threshold(gray_img, bin_img, 0, 255, THRESH_BINARY|THRESH_OTSU); cv::cvtColor(input_img, gray_img, CV_BGR2GRAY); imshow("gray", gray_img); imshow("binary", bin_img) cv::waitKey(0); return 0;
}
エラーコード
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/include/opencv2 -I/usr/local/include/opencv -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.d" -o "src/test.o" "../src/test.cpp"
../src/test.cpp: In function ‘int main()’:
../src/test.cpp:57:43: error: ‘THRESH_BINARY’ was not declared in this scope
cv::threshold(gray_img, bin_img, 0, 255, THRESH_BINARY|THRESH_OTSU);
^
../src/test.cpp:57:43: note: suggested alternative:
In file included from /usr/local/include/opencv2/opencv.hpp:47:0,
from ../src/test.cpp:14:
/usr/local/include/opencv2/imgproc.hpp:311:5: note: ‘THRESH_BINARY’
THRESH_BINARY = 0, //!< \f[\texttt{dst} (x,y) = \fork{\texttt{maxval}}{if (\texttt{src}(x,y) > \texttt{thresh})}{0}{otherwise}\f]
^
../src/test.cpp:57:57: error: ‘THRESH_OTSU’ was not declared in this scope
cv::threshold(gray_img, bin_img, 0, 255, THRESH_BINARY|THRESH_OTSU);
^
../src/test.cpp:57:57: note: suggested alternative:
In file included from /usr/local/include/opencv2/opencv.hpp:47:0,
from ../src/test.cpp:14:
/usr/local/include/opencv2/imgproc.hpp:317:5: note: ‘THRESH_OTSU’
THRESH_OTSU = 8, //!< flag, use Otsu algorithm to choose the optimal threshold value
^
src/subdir.mk:18: ターゲット 'src/test.o' のレシピで失敗しました
make: *** [src/test.o] エラー 1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/01 08:01
2018/06/01 08:08
2018/06/01 08:25
2018/06/01 08:29
2018/06/01 08:33
2018/06/01 08:37
2018/06/01 08:39