Add cascade classifier operation#678
Add cascade classifier operation#678SamCarlberg merged 13 commits intoWPIRoboticsProjects:masterfrom
Conversation
Also adds a new socket input view for file selection
Current coverage is 53.92% (diff: 30.17%)
|
| this.infoLabel.setText("Found " + numRegions + " regions of interest"); | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
| 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.
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.
I did like this solution, I just would have passed the tmp mat into it.
There was a problem hiding this comment.
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.
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.
A nice icon for this feature would be nice.
There was a problem hiding this comment.
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.
Want to put these in the socket hints builder?
There was a problem hiding this comment.
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.
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.
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.
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
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