fix dumb bug
diff --git a/app/src/main/java/com/libremobileos/facedetect/FaceBoundsOverlayView.java b/app/src/main/java/com/libremobileos/facedetect/FaceBoundsOverlayView.java
index 7e3b786..63e6e3e 100644
--- a/app/src/main/java/com/libremobileos/facedetect/FaceBoundsOverlayView.java
+++ b/app/src/main/java/com/libremobileos/facedetect/FaceBoundsOverlayView.java
@@ -55,8 +55,8 @@
}
// please give me RectF's that wont be used otherwise as I modify them
- public void updateBounds(RectF[] bounds, int sensorWidth, int sensorHeight) {
- this.bounds = bounds;
+ public void updateBounds(RectF[] inputBounds, int sensorWidth, int sensorHeight) {
+ this.bounds = inputBounds;
// if we have no paint yet, make one
if (paint == null) {
paint = new Paint();
@@ -73,8 +73,8 @@
extraw = 0;
extrah = 0;
// calculate scaling keeping aspect ratio
- int newh = (oldw / sensorWidth) * sensorHeight;
- int neww = (oldh / sensorHeight) * sensorWidth;
+ int newh = (int)((oldw / (float)sensorWidth) * sensorHeight);
+ int neww = (int)((oldh / (float)sensorHeight) * sensorWidth);
// calculate out black bars
if (neww > oldw) {
extrah = (oldh - newh) / 2;
diff --git a/app/src/main/java/com/libremobileos/facedetect/MainActivity.java b/app/src/main/java/com/libremobileos/facedetect/MainActivity.java
index f7189d5..ba6fb38 100644
--- a/app/src/main/java/com/libremobileos/facedetect/MainActivity.java
+++ b/app/src/main/java/com/libremobileos/facedetect/MainActivity.java
@@ -90,19 +90,13 @@
imageAnalysis.setAnalyzer(getMainExecutor(), imageProxy -> {
Pair<List<Pair<FaceDetector.Face, FaceScanner.Face>>, Long> data = faceFinder.process(BitmapUtils.getBitmap(imageProxy));
ArrayList<RectF> bounds = new ArrayList<>();
- Log.i("cam", String.valueOf(imageProxy.getImageInfo().getRotationDegrees()));
for (Pair<FaceDetector.Face, FaceScanner.Face> faceFacePair : data.first) {
RectF boundingBox = new RectF(faceFacePair.first.getLocation());
if (selectedCamera == CameraSelector.LENS_FACING_FRONT) {
// camera is frontal so the image is flipped horizontally
// flips horizontally
Matrix flip = new Matrix();
- int sensorOrientation = imageProxy.getImageInfo().getRotationDegrees();
- if (sensorOrientation == 0 || sensorOrientation == 180) {
- flip.postScale(1, -1, previewWidth / 2.0f, previewHeight / 2.0f);
- } else {
- flip.postScale(-1, 1, previewWidth / 2.0f, previewHeight / 2.0f);
- }
+ flip.postScale(-1, 1, previewWidth / 2.0f, previewHeight / 2.0f);
flip.mapRect(boundingBox);
}
bounds.add(boundingBox);