title: Android OpenCV Drawing Hough Lines
body: <p>I am trying to use OpenCV on an android phone to detect lines. I modified the 'Tutorial 1 Basic - 2. Use OpenCV Camera' sample. I am also using <a href="http://opencv.itseez.com/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html">Hough Line Transform</a> as an example.
  However, I am getting weird numbers (at least what I believe to be weird numbers) for the points. In the range 1000 to -1000 for b.</p>
  
  <p>I don't fully understand the code (mostly the part about adding/subtracting 1000 * (a or -b)). </p>
  
  <p>In the end I do not see the lines at all.</p>
  
  <p>Could anyone give me a hand? Also let me know if you need more information.</p>
  
  <pre><code>capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME);
  Imgproc.Canny(mGray, mIntermediateMat, 80, 100);
  Imgproc.HoughLines(mIntermediateMat, mLines, 1, Math.PI/180, 100);
  
  Scalar color = new Scalar(0, 0, 255);
  
  double[] data;
  double rho, theta;
  Point pt1 = new Point();
  Point pt2 = new Point();
  double a, b;
  double x0, y0;
  for (int i = 0; i &lt; mLines.cols(); i++)
  {
      data = mLines.get(0, i);
      rho = data[0];
      theta = data[1];
      a = Math.cos(theta);
      b = Math.sin(theta);
      x0 = a*rho;
      y0 = b*rho;
      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, color, 3);
  }
  
  Imgproc.cvtColor(mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2BGRA, 4);
  
  Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
  
  if (Utils.matToBitmap(mRgba, bmp))
      return bmp;
  
  bmp.recycle();
  return null;
  </code></pre>