-
Notifications
You must be signed in to change notification settings - Fork 107
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
Added crop functionality #926
Added crop functionality #926
Conversation
height.intValue() | ||
); | ||
|
||
final Mat output = new Mat(input, regionOfInterest).clone(); |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
Yes there is: https://github.com/WPIRoboticsProjects/GRIP/blob/master/checkstyle.xml 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
LGTM!
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:
![image](https://user-images.githubusercontent.com/11065157/54800061-736d5200-4c36-11e9-980c-99247d97098b.png)