Android4opencv를 이용해서 지금 차선 검출을 하고 있는데
opencv에서 있는 기존 카메라 받아오는 소스를 수정하여서
Gray변환, Sobel edge, HoughTransform 순으로 진행하려고 했는데요....
Sobel까지는 휴대폰으로 잘 되는 것을 확인했는데 HoughTransform이 전혀 안되네요...
실행하면 초록색화면이 뜨고 아무것도 안됩니다....
방법쫌알려주세요.... 머가 잘못됐는지라도 ㅠㅠㅠ
Mat rgba = inputFrame.rgba();
Mat gray = new Mat();// = inputFrame.gray();
Size sizeRgba = rgba.size();
int rows = (int) sizeRgba.height;
int cols = (int) sizeRgba.width;
int left = cols;
int top = rows;
int width = 0;
int height = 1*rows/4;
Mat rgbaWindow = rgba.submat(height, top, width, left);
Imgproc.cvtColor(rgbaWindow, gray, Imgproc.COLOR_RGB2GRAY);
Mat sobel = new Mat();
Mat hough = new Mat();
double[] data = new double[2];
double rho = .0, theta = .0;
Point pt1 = new Point();
Point pt2 = new Point();
double a = .0, b = .0;
double x0 = .0, y0 = .0;
Imgproc.Sobel(gray, sobel, CvType.CV_8U, 1, 0);
Imgproc.HoughLines(sobel, hough, 1, Math.PI/180.0, 100, 100, 100);
for(int i = 0; i < hough.cols(); i++)
{
data = hough.get(0, i);
rho = data[0];
theta = data[1];
a = Math.cos(theta);
b = Math.sin(theta);
x0 = a * rho;
y0 = b * rho;
if((theta*180.0/Math.PI > 130.0) && (theta*180.0/Math.PI < 150.0 ))
{
pt1.x = Math.round(x0 + 1000*(-b));
pt1.y = Math.round(y0 + 1000*a);
pt2.x = Math.round(x0 - 1000*(-b));
pt2.y = Math.round(y0 - 1000 *a);
Core.line(mIntermediateMat, pt1, pt2, new Scalar(0, 0, 255), 3, 8 , 0);
}
else if((theta*180.0/Math.PI > 40.0) && (theta*180.0/Math.PI < 60.0 ))
{
pt1.x = Math.round(x0 + 1000*(-b));
pt1.y = Math.round(y0 + 1000*a);
pt2.x = Math.round(x0 - 1000*(-b));
pt2.y = Math.round(y0 - 1000 *a);
Core.line(mIntermediateMat, pt1, pt2, new Scalar(0, 255, 0), 3, 8 , 0);
}
}
// mIntermediateMat = hough.clone();
// Core.convertScaleAbs(mIntermediateMat, mIntermediateMat, 10, 0);
Imgproc.cvtColor(mIntermediateMat, rgbaWindow, Imgproc.COLOR_GRAY2BGRA, 4);
gray.release();
rgbaWindow.release();
sobel.release();
hough.release();
return rgba;