Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Filter Contours #627

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

osulacam
Copy link
Contributor

@osulacam osulacam commented Jul 18, 2016

Adds best fit bounding boxes and splits filter contours into two operations.

@codecov-io
Copy link

codecov-io commented Jul 18, 2016

Current coverage is 57.85% (diff: 44.57%)

Merging #627 into master will decrease coverage by 0.10%

@@             master       #627   diff @@
==========================================
  Files           196        197     +1   
  Lines          6165       6238    +73   
  Methods           0          0          
  Messages          0          0          
  Branches        561        566     +5   
==========================================
+ Hits           3573       3609    +36   
- Misses         2427       2464    +37   
  Partials        165        165          

Sunburst

Powered by Codecov. Last update a700892...394cd58

@SamCarlberg
Copy link
Member

Nice. Though might it be a good a idea to use best-fit bounding boxes instead of the simple x-y-oriented bounding boxes?

Take a look at this image. The current bounding box we use to calculate the ratio will be the blue rectangle, which has a very different ratio than the object (the oblong rectangle)

@osulacam
Copy link
Contributor Author

Best fit bounding boxes are useful but may not be what all users want. There could be an option for it but that might complicate the step.

@SamCarlberg
Copy link
Member

Yeah, it would be hard to change the existing stuff because it's already in use. I'm reluctant to add more stuff to the filter operation because there's just so much crap packed into it already and it makes the UI a mess. @JLLeitschuh what are your thoughts?

@JLLeitschuh
Copy link
Member

Uhhhhh... An AdvancedFilterArgs object that you can pass in?
Just a thought.

@osulacam
Copy link
Contributor Author

We could just make a separate advanced filter contours and simple filter contours operation. The simple would just have area and perimeter, while the advanced could have everything.

@osulacam
Copy link
Contributor Author

Bytedeco RotatedRect is broken so we can't actually do the best fit bounding boxes.

@SamCarlberg
Copy link
Member

How are they broken? I got them working fine when I was playing around with them.

@osulacam
Copy link
Contributor Author

They don't give a list of points for the vertices and the bounding rectangle wasn't even remotely correct so I couldn't use that either.

@SamCarlberg
Copy link
Member

SamCarlberg commented Jul 20, 2016

RotatedRect contains the center point, width, height, and rotation. You can calculate the vertices from that. And how was it so far off? They've always been accurate for me. I assume you're using something like

for (int i = 0; i < contours.size(); i++) {
  RotatedRect rr = opencv_imgproc.minAreaRect(contours.get(i));
  // ... 
}

Edit: take a look here

final opencv_core.RotatedRect bb = minAreaRect(contour);
opencv_core.Point2f points = new opencv_core.Point2f(4);
bb.points(points);
final double rotatedWidth = Math.sqrt( Math.pow(points.position(0).x() - points.position(1)
Copy link
Member

@SamCarlberg SamCarlberg Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the space in Math.sqrt( Math.pow.... Should also use a sensical scheme of line breaks, right now it's hard to keep track of what's going on. I'd put the Math.pow statements each on their own line.

@SamCarlberg
Copy link
Member

This seems like a breaking change. Old FilterContours steps won't be compatible.

@osulacam osulacam changed the title Filter Contours Ratio Rounding Split Filter Contours Aug 10, 2016
@osulacam
Copy link
Contributor Author

The integer division problem was fixed by #618. The rest of this PR will split up filter contours to make it easier to use.

@AustinShalit
Copy link
Member

@osulacam Is this PR ready for review?

@osulacam
Copy link
Contributor Author

@AustinShalit Yes

@SamCarlberg
Copy link
Member

I'll take a look at this tonight

@JLLeitschuh
Copy link
Member

Is it still a breaking change or has that been resolved?

@osulacam
Copy link
Contributor Author

Because this technically creates a two new operations to get rid of an old one it has to be a breaking change. It is still a necessary change that shouldn't break anything significantly.

@SamCarlberg SamCarlberg modified the milestones: v1.5.0, 2.0.0 Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants