일단 소스는 아래와 같습니다.
안드로이드 폰에서 촬영한 사진의 외곽선을(contour) 뽑는중인데,
기존의 잘돌아가는 소스를 부재중인 개발자분에게 받아서
메뉴얼 없이 혼자 제 컴터에 셋팅하다가 다른 에러는 다 잡았는데
빨간색으로 표시한 findcontour, drawcontour 부분만 계속 에러가 떠있네요
라이브러리 셋팅 문제인지, 인자값 설정 문제인지...
구글링하며 여러모로 만져봐도 다시 제자리로 돌아왔어요 ㅡㅡ;;
한번 보시고 뭐가 문제인지 답변 좀 부탁드릴게요
class ReContourAsync extends AsyncTask<String, Void, Bitmap> {
@Override
protected Bitmap doInBackground(String... params) {
Mat srcMat = null;
Mat dstMat = null;
Mat threshMat = null;
Mat hierachyMat = null;
Mat contouredMat = null;
Bitmap tempBitmap = Bitmap.createBitmap(Integer.parseInt(params[1]), Integer.parseInt(params[2]), Bitmap.Config.ARGB_8888);
try {
srcMat = Highgui.imread(params[0], Highgui.CV_LOAD_IMAGE_GRAYSCALE);
Imgproc.resize(srcMat, srcMat, new Size((double)tempBitmap.getWidth(), (double)tempBitmap.getHeight()));
threshMat = new Mat();
Imgproc.threshold(srcMat, threshMat, thresValue, 255, Imgproc.THRESH_TOZERO);
List<Mat> contours = new ArrayList<Mat>();
// List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
hierachyMat = new Mat();
Imgproc.findContours(threshMat, contours, hierachyMat, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE);
Scalar color = new Scalar(255, 0, 0, 255);
contouredMat = new Mat();
Imgproc.cvtColor(threshMat, contouredMat, Imgproc.COLOR_GRAY2RGBA, 4);
Imgproc.drawContours(contouredMat, contours, -1, color);
dstMat = new Mat();
Imgproc.cvtColor(srcMat, srcMat, Imgproc.COLOR_GRAY2RGBA, 4);
Core.add(srcMat, contouredMat, dstMat);
extractMat = contouredMat.clone();
Utils.matToBitmap(dstMat, tempBitmap);
// Imgproc.cvtColor(srcMat, srcMat, Imgproc.COLOR_GRAY2RGBA, 4);
// Utils.matToBitmap(srcMat, tempBitmap);
} catch (Exception ex) {
logger.warn("##### ReContourAsync", ex);
} finally {
resizedWidth = extractMat.cols();
resizedHeight = extractMat.rows();
try{
srcMat.release();
dstMat.release();
threshMat.release();
hierachyMat.release();
}catch(Exception e){
logger.warn("##### ReContourAsync.doInBackground() release object ", e);
}
}
return tempBitmap;
}
에러 메세지는 다음과 같습니다. : The method findContours(Mat, List<MatOfPoint>, Mat, int, int) in the type Imgproc is not applicable for the arguments (Mat, List<Mat>, Mat, int, int)
The method drawContours(Mat, List<MatOfPoint>, int, Scalar) in the type Imgproc is not applicable for the arguments (Mat, List<Mat>, int, Scalar)