Skip to content

Commit

Permalink
gs-cv: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
plassalas committed Nov 3, 2017
1 parent bc489a9 commit 0c788c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public void drawOcrPerspectiveInverse(Img display, Mat homography, Scalar color,
stream().filter(field -> field.getDeadCounter() == 0).forEach(field -> field.drawOcrPerspectiveInverse(display, homography, color, thickness));
}

public void drawFieldsOnStabilized(Img stabilized) {
stream().filter(f -> f.getDeadCounter() == 0).forEach(f -> f.draw(stabilized, f.getDeadCounter() == 0 ? new Scalar(0, 255, 0) : new Scalar(0, 0, 255)));
}

public void drawConsolidated(Img stabilizedDisplay) {
consolidatedFieldStream().forEach(field -> field.draw(stabilizedDisplay, new Scalar(0, 0, 255)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ protected void fillGrid(GridPane mainGrid) {
Img stabilizedDisplay = new Img(stabilized.getSrc(), true);
if (stabilizationHasChanged) {
Stats.beginTask("stabilizationHasChanged");
Mat fieldsHomography = new Mat();
stabilized = newImgDescriptor.getDeperspectivedImg();
stabilizedDisplay = new Img(stabilized.getSrc(), true);
Mat fieldsHomography = new Mat();
Core.gemm(deperspectivGraphy, stabilizationHomography.inv(), 1, new Mat(), 0, fieldsHomography);
Stats.beginTask("restabilizeFields");
fields.restabilizeFields(fieldsHomography);
Expand All @@ -135,8 +135,7 @@ protected void fillGrid(GridPane mainGrid) {

fields.removeOverlaps();

final Img stabilizedDisplay_ = stabilizedDisplay;
fields.stream().filter(f -> f.getDeadCounter() == 0).forEach(f -> f.draw(stabilizedDisplay_, f.getDeadCounter() == 0 ? new Scalar(0, 255, 0) : new Scalar(0, 0, 255)));
fields.drawFieldsOnStabilized(stabilizedDisplay);

stabilizedImgDescriptor = newImgDescriptor;
stabilizationHomography = deperspectivGraphy;
Expand Down

0 comments on commit 0c788c5

Please sign in to comment.