GRIP icon indicating copy to clipboard operation
GRIP copied to clipboard

Add contour angle to contours report

Open SamCarlberg opened this issue 6 years ago • 5 comments

Angle is from minAreaRect, and is in the closed range [-90, 0] Rework contours operations to be a bit more functional Make filter contours a bit more optimized

Add a LazyInit class for lazily creating objects, instead of using a bizarre pattern with Optional Add a utility class for streaming Java-fied std::vector types such as MatVector as Java Stream objects. This currently just supports MatVector, but can be added to in the future.

SamCarlberg avatar Jan 23 '19 21:01 SamCarlberg

Just want to make sure we're not unintentionally introducing any memory leaks with this logic. Are there any native pointers that are created in these new stream operations that need to be cleaned up?

JLLeitschuh avatar Jan 28 '19 15:01 JLLeitschuh

The stream operation itself doesn't allocate anything - it's just standard indexed iteration. A new RotatedRect array is created for each contour report object, but the impact in native memory is minimal and the garbage collector can easily handle it.

SamCarlberg avatar Jan 28 '19 16:01 SamCarlberg

Reminder, the garbage collector has no idea how large native objects truly are, so it can leave them around for far longer than you think it will.

If there is a clean place to de-allocate them after usage, please do so. Otherwise, it's fine.

JLLeitschuh avatar Jan 28 '19 16:01 JLLeitschuh

Right. The C++ class is small (only holds a few numbers), so the memory impact is low. We also prompt the garbage collector every few seconds so I'm not too worried

SamCarlberg avatar Jan 28 '19 16:01 SamCarlberg

Codecov Report

Merging #915 into master will increase coverage by 0.11%. The diff coverage is 29.09%.

@@             Coverage Diff              @@
##             master     #915      +/-   ##
============================================
+ Coverage     52.86%   52.98%   +0.11%     
  Complexity        1        1              
============================================
  Files           327      329       +2     
  Lines          8852     8869      +17     
  Branches        560      555       -5     
============================================
+ Hits           4680     4699      +19     
+ Misses         3969     3967       -2     
  Partials        203      203

codecov-io avatar Apr 18 '19 23:04 codecov-io