Skip to content

Commit

Permalink
Fix two issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nfeybesse committed Jun 4, 2018
1 parent c175d75 commit 3676ad1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
Expand Up @@ -315,6 +315,7 @@ public static List<HoughTrajectStep> bestTrajectFHT(Mat houghTransform, int blur
public static List<HoughTrajectStep> bestTrajectFHT2(Mat houghTransform, int blurSize, double penality, int stepCount) {
int stripWidth = (houghTransform.cols() + 1) / 2;
Mat adaptivHough = adaptivHough(houghTransform, blurSize);
Core.pow(houghTransform, 3, adaptivHough);
double[][] fastAdaptivHough = new double[adaptivHough.rows()][adaptivHough.cols()];
for (int row = 0; row < adaptivHough.rows(); row++)
for (int col = 0; col < adaptivHough.cols(); col++)
Expand Down
@@ -1,15 +1,5 @@
package org.genericsystem.cv.application;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.math3.analysis.interpolation.LinearInterpolator;
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
import org.genericsystem.cv.AbstractApp;
Expand All @@ -25,6 +15,16 @@
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javafx.application.Platform;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
Expand Down Expand Up @@ -133,14 +133,14 @@ private Image[] doWork() {

List<List<OrientedPoint>[]> fhtHorizontals = new ArrayList<>();
for (int vStripIndex = 0; vStripIndex < vHoughTrajs.size(); vStripIndex++)
fhtHorizontals.add(RadonTransform.toHorizontalOrientedPoints(vHoughTrajs.get(vStripIndex), (vStripIndex + 1) * vStep, 0.2, 0.08));
fhtHorizontals.add(RadonTransform.toHorizontalOrientedPoints(vHoughTrajs.get(vStripIndex), (vStripIndex + 1) * vStep, 0.3, 0.05));
List<List<OrientedPoint>[]> fhtVerticals = new ArrayList<>();
for (int hStrip = 0; hStrip < hHoughTrajs.size(); hStrip++)
fhtVerticals.add(RadonTransform.toVerticalOrientedPoints(hHoughTrajs.get(hStrip), (hStrip + 1) * hStep, 0.2, 0.08));
fhtVerticals.add(RadonTransform.toVerticalOrientedPoints(hHoughTrajs.get(hStrip), (hStrip + 1) * hStep, 0.3, 0.05));

List<List<Segment>>[] horizontalSegments = connect(fhtHorizontals, hStep, 1, false);
List<List<Segment>>[] horizontalSegments = connect(fhtHorizontals, hStep, 2, false);
List<PolynomialSplineFunction>[] horizontalSplines = toSplines(horizontalSegments, false);
List<List<Segment>>[] verticalSegments = connect(fhtVerticals, vStep, 1, true);
List<List<Segment>>[] verticalSegments = connect(fhtVerticals, vStep, 2, true);
List<PolynomialSplineFunction>[] verticalSplines = toSplines(verticalSegments, true);

Img splineDisplay = new Img(superFrame.getFrame().getSrc().clone(), false);
Expand Down Expand Up @@ -229,7 +229,7 @@ private Image[] doWork() {
images[6] = dewarpedBinarized2.toJfxImage();
ref = trace("Binarize dewarp", ref);

Layout layout = dewarpedBinarized2.buildLayout(new Size(2, 0.0), new Size(0.01, 0.01), 8);
Layout layout = dewarpedBinarized2.buildLayout(new Size(2, 0.0), new Size(0.001, 0.001), 8);
layout.draw(dewarpFHT, new Scalar(255, 0, 0), new Scalar(0, 0, 255), 1, 2);
images[7] = dewarpFHT.toJfxImage();
ref = trace("Layout", ref);
Expand Down
@@ -1,11 +1,11 @@
package org.genericsystem.cv.application;

import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;

public class SplineInterpolator implements Interpolator {

private final List<PolynomialSplineFunction[]> horizontals;
Expand All @@ -27,7 +27,7 @@ public double interpolateVerticals(double x, double y) {
if (left != null && right != null) {
double x1 = left[0].value(y);
double x2 = right[0].value(y);
return -((x - x1) / (x2 - x1) * Math.atan(right[1].value(y)) + (x2 - x) / (x2 - x1) * Math.atan(left[1].value(y)));
return -Math.atan((x - x1) / (x2 - x1) * right[1].value(y) + (x2 - x) / (x2 - x1) * left[1].value(y));
} else
return subInterpolator.interpolateVerticals(x, y);
// if (left != null) {
Expand Down Expand Up @@ -83,8 +83,7 @@ public double interpolateHorizontals(double x, double y) {
if (top != null && bottom != null) {
double y1 = top[0].value(x);
double y2 = bottom[0].value(x);

return (y - y1) / (y2 - y1) * Math.atan(bottom[1].value(x)) + (y2 - y) / (y2 - y1) * Math.atan(top[1].value(x));
return Math.atan((y - y1) / (y2 - y1) * bottom[1].value(x) + (y2 - y) / (y2 - y1) * top[1].value(x));
} else
return subInterpolator.interpolateHorizontals(x, y);
}
Expand Down
@@ -1,8 +1,5 @@
package org.genericsystem.cv.application.mesh;

import java.util.ArrayList;
import java.util.List;

import org.genericsystem.cv.utils.GPUTools;
import org.genericsystem.cv.utils.NativeLibraryLoader;
import org.opencv.core.Core;
Expand All @@ -14,6 +11,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class Svd {

private static final Logger logger = LoggerFactory.getLogger(Svd.class);
Expand Down Expand Up @@ -127,7 +127,6 @@ public static List<Point3> solve(List<Point> srcPts, int[][] rects) {
for (int i = 0; i < pts.size(); i++) {
pts.get(i).x *= stdxy[0];
pts.get(i).y *= stdxy[1];
pts.get(i).z *= Math.sqrt(stdxy[0] * stdxy[1]);
}

return pts;
Expand Down

0 comments on commit 3676ad1

Please sign in to comment.