Added crop functionality#926
Conversation
| height.intValue() | ||
| ); | ||
|
|
||
| final Mat output = new Mat(input, regionOfInterest).clone(); |
There was a problem hiding this comment.
This can lead to a memory leak. @SamCarlberg Do you know of a good class to use as an example of how this should be done to avoid the memory leak?
There was a problem hiding this comment.
I don't think the clone is necessary. The constructor used here uses the same memory as the base image IIRC so there's only minimal overhead. I'll have to take a look when I'm at my computer
There was a problem hiding this comment.
Well, we don't want this operation modifying the original input matrix.
|
This is awesome! We'll try to get to it. Can you work on fixing the build so that CI passes? |
|
I fixed the 2 [WhitespaceAfter] errors I believe. However, the [CustomImportOrder] errors are the same ones I see in ResizeOperation (I used ResizeOperation as a starter file). Also, based on another fork I just saw, I refactored the perform method to not create a new mat every iteration. |
|
Right now, I'm just running the Google Checkstyle. Is there a custom checkstyle file for GRIP? |
Codecov Report
@@ Coverage Diff @@
## master #926 +/- ##
=========================================
Coverage ? 52.93%
Complexity ? 1
=========================================
Files ? 330
Lines ? 8939
Branches ? 562
=========================================
Hits ? 4732
Misses ? 4002
Partials ? 205 |
core/src/main/java/edu/wpi/grip/core/operations/composite/CropOperation.java
Outdated
Show resolved
Hide resolved
I haven't actually developed in this codebase in so long that I honestly forget. @SamCarlberg can you help out here? |
|
Run |
|
@TheTripleV With the recent addition of CUDA support, you'll need to change the I can add the code generation in a followup if you're not comfortable with it |
|
Cool. I'll take a look at it after my finals next week. I'm just unsure on running tests on GRIP in general. For the operation files, I see test cases/files written. But for code generation, do we just run each piece of generated code manually? |
fcd0bec to
76ee236
Compare
|
I updated the crop operation to use MatWrapper. Interestingly, the operation performs just fine without a clone. This is because every operation that occurs after a crop makes a copy of the data in the MatWrapper. Should I leave the |
|
@SamCarlberg ^^ |
|
You can safely omit calling |
| if (input.isCpu()) { | ||
| output.set(input.getCpu().apply(regionOfInterest)); // .clone() optional | ||
| } else { | ||
| output.set(input.getGpu().apply(regionOfInterest)); // .clone() optional |
There was a problem hiding this comment.
I don't think the .clone() comments are necessary.
-Fixed incorrect Socket Name -Checkstyle errors?
-If memory is in GPU, keep it there
07e1e1d to
cc708b3
Compare
|
I added Java Code Generation. One weird thing I haven't been able to figure out is how it sets default values. In this step, |
|
There's a hardcoded macro in You should be able to add an 'or' there to generate the expected enum lookup |
- Allow Top Left Origin to be accessible
|
Sorry for letting this sit for so long. Happy to merge if it's in a working state. |
|
Thanks for your contribution @TheTripleV!! |
A CropOperation has been added that allows an image to be cropped down to a smaller size.
Users can specify a location and size for the crop. They can also specify the location of the rectangle from which the crop propogates: top left, bottom left, top right, bottom right, center.
Note: I don't know how I would go about writing/testing the code generation.
Example usage:
