How to improve Edge Detection of Rectangular objects

asked 2015-11-16 13:42:42 -0500

VeTaLio gravatar image

updated 2015-11-16 13:43:32 -0500

Hello everyone. I'm using OpenCV to find biggest rectangular object(paper sheet A4).
My work flow:

  1. Apply filters(cvtColor/Canny/Blur)
  2. via method FindContours() fill List with contours
  3. loop List of contours(size)
  4. Via ApproxPolyDP() method,fill ApproxCurve
  5. If ApproxCurve.Cols() == 0 , then begin again recursively step 1 with another filters.

So all works,but no so good,as i except and i need some advanced tips.
I have two types of filters,that i apply on source image:

Imgproc.cvtColor(SourceImage,SourceImage, Imgproc.COLOR_BGR2GRAY);
Imgproc.GaussianBlur(SourceImage, gray, new org.opencv.core.Size(5, 5), 0);
Imgproc.Canny(gray,gray, 75, 200);

after that,if my approxCurves == 0 or object is to small,i apply another filters:

Imgproc.cvtColor(SourceImage,SourceImage,Imgproc.COLOR_RGB2GRAY);
Imgproc.Canny(SourceImage, SourceImage,50,50);
Imgproc.GaussianBlur(SourceImage,gray,new Org.Opencv.Core.Size(5,5),5);

And that's it. For some "cases" it helps,but frequently fails. How can i improve my detection?
Thanks!

edit retag flag offensive close merge delete

Comments

1

take a look at squares.cpp

sturkmen gravatar imagesturkmen ( 2015-11-16 14:15:53 -0500 )edit

@sturkmen thanks,i will try.

VeTaLio gravatar imageVeTaLio ( 2015-11-16 14:54:57 -0500 )edit