start convert file by file

This commit is contained in:
Henry Schimke
2022-08-20 12:09:33 -05:00
parent 1901c96559
commit 9f72478dc8
2 changed files with 19 additions and 26 deletions

View File

@@ -14,17 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.common.detector; //package com.google.zxing.common.detector;
/** /**
* General math-related and numeric utility functions. * General math-related and numeric utility functions.
*/ */
public final class MathUtils {
private MathUtils() { /**
}
/**
* Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its
* argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut
* differ slightly from {@link Math#round(float)} in that half rounds down for negative * differ slightly from {@link Math#round(float)} in that half rounds down for negative
@@ -33,8 +29,8 @@ public final class MathUtils {
* @param d real value to round * @param d real value to round
* @return nearest {@code int} * @return nearest {@code int}
*/ */
public static int round(float d) { pub fn round(d:f32) -> i32 {
return (int) (d + (d < 0.0f ? -0.5f : 0.5f)); return (d + (if d < 0.0f { -0.5f } else { 0.5f}));
} }
/** /**
@@ -44,10 +40,10 @@ public final class MathUtils {
* @param bY point B y coordinate * @param bY point B y coordinate
* @return Euclidean distance between points A and B * @return Euclidean distance between points A and B
*/ */
public static float distance(float aX, float aY, float bX, float bY) { pub fn distance( aX:f32, aY:f32, bX: f32, bY:f32) -> f32 {
double xDiff = aX - bX; let xDiff:f64 = aX - bX;
double yDiff = aY - bY; let yDiff:f64 = aY - bY;
return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
} }
/** /**
@@ -57,22 +53,20 @@ public final class MathUtils {
* @param bY point B y coordinate * @param bY point B y coordinate
* @return Euclidean distance between points A and B * @return Euclidean distance between points A and B
*/ */
public static float distance(int aX, int aY, int bX, int bY) { pub fn distance( aX : i32, aY: i32, bX: i32, bY: i32) -> f32 {
double xDiff = aX - bX; let xDiff : f64 = aX - bX;
double yDiff = aY - bY; let yDiff :f64 = aY - bY;
return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
} }
/** /**
* @param array values to sum * @param array values to sum
* @return sum of values in array * @return sum of values in array
*/ */
public static int sum(int[] array) { pub fn sum( array : &[i32]) -> i32 {
int count = 0; let count = 0;
for (int a : array) { for a in array {
count += a; count += a;
} }
return count; return count;
} }
}

View File

@@ -14,11 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.common.detector; //package com.google.zxing.common.detector;
use crate::{NotFoundException,ResultPoint};
use crate::common::BitMatrix;
import com.google.zxing.NotFoundException;
import com.google.zxing.ResultPoint;
import com.google.zxing.common.BitMatrix;
/** /**
* <p>A somewhat generic detector that looks for a barcode-like rectangular region within an image. * <p>A somewhat generic detector that looks for a barcode-like rectangular region within an image.