View Single Post
  #4   Spotlight this post!  
Unread 31-03-2012, 13:44
Kovs's Avatar
Kovs Kovs is offline
Registered User
FRC #1259 (Paradigm Shift)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Pewaukee, Wisconsin
Posts: 19
Kovs will become famous soon enough
Re: Rectangle corner extraction in JavaCV with source

Just saw this today and I felt like integrating my code into yours (mostly because I need to do a lot of clean-up with my code and doing this forces me to figure out what parts are and aren't needed in my own code).
  • A much easier way to do a threshold is cvInRangeS(..)
    an example would be
    Code:
    cvInRangeS(src, cvScalar(b_low, g_low, r_low, 0), cvScalar(b_high, g_high, r_high, 0), dst);
  • I kept the BGR threshold, but cvInRangeS also works if you convert your image to another type (like HSL)
  • For blurring, I scale it down to half-size and back up... I have no real reason for why I do it this way.
  • I also use a convexHull operation to fill in the gaps after that
  • I take each blob and find points which are closest to the corners of a bounding rectangle, I choose these as the corners.
  • I eliminate found rectangles that are within other found rectangles (this is a problem that comes with the logic I use).
  • I also eliminate small polygons, so that my threshold can be wider

I hope somebody will find this useful, it's a pain to get started with javaCV. Classes to add and result are attached.
Attached Thumbnails
Click image for larger version

Name:	05_polyCornersOnOriginal.jpg
Views:	90
Size:	29.6 KB
ID:	12490  
Attached Files
File Type: java PolygonStructure.java (5.2 KB, 116 views)
File Type: java RectangleDetectKovs.java (10.7 KB, 158 views)
Reply With Quote