Skip to content

Commit

Permalink
fix #130 incorrect camera intrinsics matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrupczak3 committed Apr 20, 2024
1 parent 22e50bc commit 17ac89d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/src/main/java/com/openathena/MetadataExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,21 @@ public static JSONObject getMatchingDrone(ExifInterface exif) {
throw new RuntimeException("could not determine width and height of image!");
}

int smallestDifference = Integer.MAX_VALUE;
double smallestDifference = Double.MAX_VALUE;
JSONObject closestDrone = null;

for (int i = 0; i < matchingDrones.length(); i++) {
try {
JSONObject drone = matchingDrones.getJSONObject(i);
int droneWidth = drone.getInt("widthPixels");
double droneWidth = drone.getInt("widthPixels");

int difference = (int) Math.abs(droneWidth - targetWidth);
if (difference < smallestDifference) {
double difference_ratio = droneWidth / targetWidth;
if (difference_ratio < 1.0d) {
difference_ratio = 1 / difference_ratio;
}
if (difference_ratio < smallestDifference) {
closestDrone = drone;
smallestDifference = difference;
smallestDifference = difference_ratio;
}
} catch (JSONException e) {
return null;
Expand Down

0 comments on commit 17ac89d

Please sign in to comment.