Houghlines in android with opencv -


i trying make perspective correction quadrilateral objects using opencv3. managed show lines , implemented houghlines using imgproc.houghlinesp() , tried highlight lines using imgproc.lines() output no success. below code , have attached output image.

please let me know wrong happening , should done...

mat initimg; // initial image mat greyimg; // converted grey  mat lines = new mat(); int threshold = 50; int minlinesize = 20; int linegap = 10;  initimg = imgcodecs.imread(imgloc, 1); greyimg = new mat(); imgproc.cvtcolor(initimg, greyimg, imgproc.color_bgr2gray); bitmap bitm = bitmap.createbitmap(greyimg.cols(), greyimg.rows(),bitmap.config.argb_8888);  imgproc.blur(greyimg, greyimg, new size(3.d, 3.d)); imgproc.adaptivethreshold(greyimg, greyimg, 255, imgproc.adaptive_thresh_mean_c, imgproc.thresh_binary_inv, 15, 4);  imgproc.houghlinesp(greyimg, lines, 1, math.pi/180, threshold,         minlinesize, linegap); // lines returns rows x columns , rows 1. dont know why please me understand (int x = 0; x < lines.cols(); x++) {      double[] vec = lines.get(0, x);     double[] val = new double[4];      double x1 = vec[0],             y1 = vec[1],             x2 = vec[2],             y2 = vec[3];      system.out.println(tag+"coordinates: x1=>"+x1+" y1=>"+y1+" x2=>"+x2+" y2=>"+y2);     point start = new point(x1, y1);     point end = new point(x2, y2);      imgproc.line(greyimg, start, end, new scalar(0,255, 0, 255), 3);  }  utils.mattobitmap(greyimg, bitm);  if(bitm!=null){     toast.maketext(getapplicationcontext(), "bitmap not null", toast.length_short).show();     iv.setimagebitmap(bitm); }else{     toast.maketext(getapplicationcontext(), "bitmap null", toast.length_short).show(); } 

my output:

output above code

i managed houghlines. houghlines not showing in grey images , extracted houghlines in grey image plotted lines in color image , worked.

imgproc.houghlinesp(greyimg, lines, 1, math.pi/180, threshold,                 minlinesize, linegap);          (int x = 0; x < lines.rows(); x++)         {             double[] vec = lines.get(x, 0);             double x1 = vec[0],                     y1 = vec[1],                     x2 = vec[2],                     y2 = vec[3];             point start = new point(x1, y1);             point end = new point(x2, y2);             double dx = x1 - x2;             double dy = y1 - y2;              double dist = math.sqrt (dx*dx + dy*dy);              if(dist>300.d)  // show lines have length greater 300                 imgproc.line(initimg, start, end, new scalar(0,255, 0, 255),5);// here initimg original image.          } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -