capacitor-plugin-camera-forked 3.1.121 → 3.1.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,6 +66,11 @@ public class BlurDetectionHelper {
|
|
|
66
66
|
private static final double MIN_WORD_CONFIDENCE = 0.8; // 80% confidence threshold
|
|
67
67
|
private static final double AT_LEAST_N_PERCENT_OF_WORDS_ARE_READABLE = 0.6; // 60% of words are readable
|
|
68
68
|
private static final double AT_LEAST_N_PERCENT_OF_AVERAGE_CONFIDENCE = 0.85; // 85% of average confidence
|
|
69
|
+
|
|
70
|
+
// Method based confidence threshold
|
|
71
|
+
private static final double MIN_SHARP_CONFIDENCE_FOR_OBJECT_DETECTION = 0.4; // 40% confidence threshold
|
|
72
|
+
private static final double MIN_SHARP_CONFIDENCE_FOR_TEXT_DETECTION = 0.1; // 10% confidence threshold
|
|
73
|
+
private static final double MIN_SHARP_CONFIDENCE_FOR_FULL_IMAGE = 0.7; // 70% confidence threshold
|
|
69
74
|
|
|
70
75
|
// TFLite components
|
|
71
76
|
private Interpreter tflite;
|
|
@@ -239,7 +244,7 @@ public class BlurDetectionHelper {
|
|
|
239
244
|
Bitmap roi = cropBitmap(bitmap, boundingBox);
|
|
240
245
|
if (roi != null) {
|
|
241
246
|
// Run TFLite blur detection on ROI
|
|
242
|
-
Map<String, Object> roiResult = detectBlurWithTFLiteConfidence(roi);
|
|
247
|
+
Map<String, Object> roiResult = detectBlurWithTFLiteConfidence(roi, MIN_SHARP_CONFIDENCE_FOR_OBJECT_DETECTION);
|
|
243
248
|
|
|
244
249
|
Log.d(TAG, "Object Detection ROI Result isBlur: " + roiResult.get("isBlur"));
|
|
245
250
|
roiResult.put("boundingBox", boundingBox);
|
|
@@ -299,7 +304,7 @@ public class BlurDetectionHelper {
|
|
|
299
304
|
|
|
300
305
|
// Step 3: Full-Image Blur Detection (Final Fallback)
|
|
301
306
|
Log.d(TAG, "Step 3: Using Full-Image Blur Detection");
|
|
302
|
-
return detectBlurWithTFLiteConfidence(bitmap);
|
|
307
|
+
return detectBlurWithTFLiteConfidence(bitmap, MIN_SHARP_CONFIDENCE_FOR_FULL_IMAGE);
|
|
303
308
|
|
|
304
309
|
} catch (Exception e) {
|
|
305
310
|
Log.e(TAG, "Error in blur detection pipeline: " + e.getMessage());
|
|
@@ -355,7 +360,7 @@ public class BlurDetectionHelper {
|
|
|
355
360
|
double sharpConfidence = probabilities.length > 1 ? probabilities[1] : 0.0;
|
|
356
361
|
|
|
357
362
|
// Determine if image is blurry using TFLite confidence
|
|
358
|
-
boolean isBlur = sharpConfidence <
|
|
363
|
+
boolean isBlur = sharpConfidence < MIN_SHARP_CONFIDENCE_FOR_FULL_IMAGE;
|
|
359
364
|
|
|
360
365
|
|
|
361
366
|
// Return 1.0 for blur, 0.0 for sharp (to maintain double return type)
|
|
@@ -498,7 +503,7 @@ public class BlurDetectionHelper {
|
|
|
498
503
|
* @param bitmap Input image bitmap
|
|
499
504
|
* @return Map with isBlur, blurConfidence, and sharpConfidence
|
|
500
505
|
*/
|
|
501
|
-
public java.util.Map<String, Object> detectBlurWithTFLiteConfidence(Bitmap bitmap) {
|
|
506
|
+
public java.util.Map<String, Object> detectBlurWithTFLiteConfidence(Bitmap bitmap, double minSharpConfidence) {
|
|
502
507
|
java.util.Map<String, Object> result = new java.util.HashMap<>();
|
|
503
508
|
|
|
504
509
|
if (!isInitialized || tflite == null) {
|
|
@@ -553,7 +558,7 @@ public class BlurDetectionHelper {
|
|
|
553
558
|
Log.d(TAG, "TFLite Blur confidence: " + blurConfidence + " Sharp confidence: " + sharpConfidence);
|
|
554
559
|
|
|
555
560
|
// Determine if image is blurry using TFLite confidence
|
|
556
|
-
boolean isBlur = sharpConfidence <
|
|
561
|
+
boolean isBlur = sharpConfidence < minSharpConfidence;
|
|
557
562
|
|
|
558
563
|
Log.d(TAG, "TFLite Blur detection isBlur: " + isBlur);
|
|
559
564
|
|
|
@@ -783,7 +788,7 @@ public class BlurDetectionHelper {
|
|
|
783
788
|
try {
|
|
784
789
|
Bitmap cropped = cropBitmap(bitmap, roi);
|
|
785
790
|
if (cropped != null) {
|
|
786
|
-
Map<String, Object> result = detectBlurWithTFLiteConfidence(cropped);
|
|
791
|
+
Map<String, Object> result = detectBlurWithTFLiteConfidence(cropped, MIN_SHARP_CONFIDENCE_FOR_TEXT_DETECTION);
|
|
787
792
|
result.put("boundingBox", roi);
|
|
788
793
|
results.add(result);
|
|
789
794
|
}
|
|
@@ -27,10 +27,10 @@ class BlurDetectionHelper {
|
|
|
27
27
|
private static let AT_LEAST_N_PERCENT_OF_AVERAGE_CONFIDENCE: Double = 0.85 // 85% of average confidence
|
|
28
28
|
|
|
29
29
|
// Method based confidence threshold
|
|
30
|
-
private static let MIN_SHARP_CONFIDENCE_FOR_OBJECT_DETECTION: Double = 0.
|
|
31
|
-
private static let MIN_SHARP_CONFIDENCE_FOR_TEXT_DETECTION: Double = 0.
|
|
30
|
+
private static let MIN_SHARP_CONFIDENCE_FOR_OBJECT_DETECTION: Double = 0.3 // 40% confidence threshold
|
|
31
|
+
private static let MIN_SHARP_CONFIDENCE_FOR_TEXT_DETECTION: Double = 0.09 // 10% confidence threshold
|
|
32
32
|
private static let MIN_SHARP_CONFIDENCE_FOR_FULL_IMAGE: Double = 0.7 // 70% confidence threshold
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
private var interpreter: Interpreter?
|
|
35
35
|
private var isInitialized = false
|
|
36
36
|
|
package/package.json
CHANGED