-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add cascade classifier operation #678
Add cascade classifier operation #678
Conversation
Also adds a new socket input view for file selection
Current coverage is 53.92% (diff: 30.17%)@@ master #678 diff @@
==========================================
Files 209 214 +5
Lines 6713 6882 +169
Methods 0 0
Messages 0 0
Branches 656 671 +15
==========================================
+ Hits 3657 3711 +54
- Misses 2886 3001 +115
Partials 170 170
|
this.infoLabel.setText("Found " + numRegions + " regions of interest"); | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code seems eerily familiar, could this be refactored into the core (maybe behind an interface) with just a render
method that takes a boolean showInputImage
and also has a method like getDescriptionString
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy-pasted from the LinesReport
preview, that's probably what you're thinking of. I'll pretty it up with a refactor later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, if you move the render
into core then it becomes incredibly easy for me to render as a web server too. Because then the code for creating the preview image will be in the core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 08e53d3
954cbef
to
4afbf20
Compare
* to the operations to resolve the file associated with the path. | ||
*/ | ||
@XStreamAlias("grip:File") | ||
public class FileSource extends Source { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would disagree with this pattern. I would make this a classifiers source.
Just like we don't expect steps to resolve paths for images that are loaded from the filesystem this too should behave the same.
@@ -39,11 +38,10 @@ | |||
private final ImageConverter imageConverter = new ImageConverter(); | |||
private final ImageView imageView = new ImageView(); | |||
private final Label infoLabel = new Label(); | |||
private final Mat tmp = new Mat(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to @ThomasJClark we cached the Mat
in these classes because they were huge and were causing the memory usage of GRIP to grow at an incredibly fast rate and then the GC would kick in.
By caching the images in these temporary mats that we reused we were effectively re-using the same memory for each image rendered. If you can run a profiler and prove that this is not causing us to use more memory I'll allow this change, but you need to make sure of this.
* | ||
* @return a mat with the data drawn on it | ||
*/ | ||
public static <T> Mat draw(Mat image, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did like this solution, I just would have passed the tmp
mat into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not relevant to this PR. It can get refactored later, especially since #680 has to get merged ASAP
It'd be nice to have a |
OperationDescription.builder() | ||
.name("Cascade Classifier") | ||
.summary("Runs a cascade classifier on an image") | ||
.icon(Icon.iconStream("opencv")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want a custom icon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically a one-to-one mapping of an OpenCV function, so it's okay as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice icon for this feature would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically a one-to-one mapping of an OpenCV function
All the other OpenCV operations use the OpenCV icon. So this will use the OpenCV icon, too.
new SocketHint.Builder<>(Size.class) | ||
.identifier("Max size") | ||
.initialValue(new Size(0, 0)) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to put these in the socket hints builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, the default already initializes to (0, 0). I'm just going to use that
} catch (RuntimeException e) { | ||
// Error with the config file, reset the classifier and throw an exception | ||
classifier.load(lastFile); | ||
throw new IllegalArgumentException("Invalid XML in configuration file", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The classifier should not be loaded from within the operation. The source should be the object instantiating the CascadeClassifier
object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about this, if you ever want to add a HTTP source that creates a classifier then this won't work. Similarly, if someone sends one via network tables this won't work either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, though I think that would have a negative impact on code generation because it would require users to manually instantiate the classifiers instead of having the pipeline handle everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cooooode gen!
Add missing import in generated Java code
422f92e
to
844a91c
Compare
Is this ready to be merged? |
Yes |
Also adds a new source for cascade classifiers
Goals