ilabs-flir 2.4.10 → 2.4.11
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.
package/Flir.podspec
CHANGED
|
@@ -504,103 +504,105 @@ public class FlirSdkManager {
|
|
|
504
504
|
// to ensure the native frame reference remains valid.
|
|
505
505
|
if (isProcessingFrame.compareAndSet(false, true)) {
|
|
506
506
|
try {
|
|
507
|
-
|
|
508
|
-
streamer
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
507
|
+
synchronized (FlirSdkManager.this) {
|
|
508
|
+
if (streamer != null && activeStream != null) {
|
|
509
|
+
streamer.update();
|
|
510
|
+
|
|
511
|
+
final String paletteToApply = currentPaletteName;
|
|
512
|
+
final String snapshotPath = pendingSnapshotPath;
|
|
513
|
+
pendingSnapshotPath = null;
|
|
514
|
+
streamer.withThermalImage(thermalImage -> {
|
|
515
|
+
// 1. Apply Palette
|
|
516
|
+
if (paletteToApply != null) {
|
|
517
|
+
try {
|
|
518
|
+
List<Palette> sdkPalettes = cachedSdkPalettes;
|
|
519
|
+
if (sdkPalettes == null) {
|
|
520
|
+
synchronized (FlirSdkManager.this) {
|
|
521
|
+
sdkPalettes = cachedSdkPalettes;
|
|
522
|
+
if (sdkPalettes == null) {
|
|
523
|
+
try {
|
|
524
|
+
sdkPalettes = PaletteManager.getDefaultPalettes();
|
|
525
|
+
cachedSdkPalettes = sdkPalettes;
|
|
526
|
+
} catch (Throwable t) {
|
|
527
|
+
Log.e(TAG, "Failed to get default palettes", t);
|
|
528
|
+
}
|
|
527
529
|
}
|
|
528
530
|
}
|
|
529
531
|
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (paletteToApply.equalsIgnoreCase("Gray") || paletteToApply.equalsIgnoreCase("grayscale")) {
|
|
533
|
-
// User wants Gray - map to WhiteHot which is the SDK's standard grayscale
|
|
534
|
-
for (Palette p : sdkPalettes) {
|
|
535
|
-
if (p.name.equalsIgnoreCase("WhiteHot") || p.name.equalsIgnoreCase("White hot")) {
|
|
536
|
-
thermalImage.setPalette(p);
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
} else {
|
|
541
|
-
Palette palette = null;
|
|
542
|
-
for (Palette p : sdkPalettes) {
|
|
543
|
-
if (p.name.equalsIgnoreCase(paletteToApply)) {
|
|
544
|
-
palette = p;
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
532
|
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
} else if (paletteToApply.equalsIgnoreCase("Wheel")) {
|
|
552
|
-
// Fallback for Wheel if not found - some SDKs use different names
|
|
533
|
+
if (paletteToApply.equalsIgnoreCase("Gray") || paletteToApply.equalsIgnoreCase("grayscale")) {
|
|
534
|
+
// User wants Gray - map to WhiteHot which is the SDK's standard grayscale
|
|
553
535
|
for (Palette p : sdkPalettes) {
|
|
554
|
-
if (p.name.
|
|
536
|
+
if (p.name.equalsIgnoreCase("WhiteHot") || p.name.equalsIgnoreCase("White hot")) {
|
|
555
537
|
thermalImage.setPalette(p);
|
|
556
538
|
break;
|
|
557
539
|
}
|
|
558
540
|
}
|
|
541
|
+
} else {
|
|
542
|
+
Palette palette = null;
|
|
543
|
+
for (Palette p : sdkPalettes) {
|
|
544
|
+
if (p.name.equalsIgnoreCase(paletteToApply)) {
|
|
545
|
+
palette = p;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (palette != null) {
|
|
551
|
+
thermalImage.setPalette(palette);
|
|
552
|
+
} else if (paletteToApply.equalsIgnoreCase("Wheel")) {
|
|
553
|
+
// Fallback for Wheel if not found - some SDKs use different names
|
|
554
|
+
for (Palette p : sdkPalettes) {
|
|
555
|
+
if (p.name.contains("Wheel") || p.name.contains("ColorWheel") || p.name.contains("Rainbow")) {
|
|
556
|
+
thermalImage.setPalette(p);
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
559
561
|
}
|
|
562
|
+
} catch (Throwable t) {
|
|
563
|
+
Log.e(TAG, "Failed to apply palette: " + paletteToApply, t);
|
|
560
564
|
}
|
|
561
|
-
} catch (Throwable t) {
|
|
562
|
-
Log.e(TAG, "Failed to apply palette: " + paletteToApply, t);
|
|
563
565
|
}
|
|
564
|
-
}
|
|
565
566
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
567
|
+
// 2. Save Radiometric Snapshot if requested
|
|
568
|
+
if (snapshotPath != null) {
|
|
569
|
+
try {
|
|
570
|
+
Log.i(TAG, "[SNAPSHOT] Attempting to save radiometric snapshot: " + snapshotPath);
|
|
571
|
+
thermalImage.saveAs(snapshotPath);
|
|
572
|
+
Log.i(TAG, "[SNAPSHOT] ✅ Success: Radiometric snapshot saved");
|
|
573
|
+
if (snapshotCallback != null) {
|
|
574
|
+
snapshotCallback.onSnapshotSaved(snapshotPath);
|
|
575
|
+
snapshotCallback = null;
|
|
576
|
+
}
|
|
577
|
+
} catch (java.io.IOException e) {
|
|
578
|
+
Log.e(TAG, "Failed to save radiometric snapshot", e);
|
|
579
|
+
if (snapshotCallback != null) {
|
|
580
|
+
snapshotCallback.onSnapshotError(e.getMessage());
|
|
581
|
+
snapshotCallback = null;
|
|
582
|
+
}
|
|
581
583
|
}
|
|
582
584
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
585
|
+
|
|
586
|
+
// 3. Generate Bitmap for display
|
|
587
|
+
// We use streamer.getImage() to get the rendered image with palette applied.
|
|
588
|
+
try {
|
|
589
|
+
Bitmap newBitmap = BitmapAndroid.createBitmap(streamer.getImage()).getBitMap();
|
|
590
|
+
if (newBitmap != null) {
|
|
591
|
+
Bitmap oldBitmap = latestBitmap;
|
|
592
|
+
latestBitmap = newBitmap;
|
|
593
|
+
if (listener != null) {
|
|
594
|
+
listener.onFrame(newBitmap);
|
|
595
|
+
}
|
|
596
|
+
// Recycle old bitmap to prevent memory leak
|
|
597
|
+
if (oldBitmap != null && oldBitmap != newBitmap) {
|
|
598
|
+
oldBitmap.recycle();
|
|
599
|
+
}
|
|
598
600
|
}
|
|
601
|
+
} catch (Exception e) {
|
|
602
|
+
Log.e(TAG, "Bitmap creation failed", e);
|
|
599
603
|
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
+
});
|
|
605
|
+
}
|
|
604
606
|
}
|
|
605
607
|
} catch (Exception e) {
|
|
606
608
|
Log.e(TAG, "Frame processing error", e);
|
|
@@ -629,16 +631,18 @@ public class FlirSdkManager {
|
|
|
629
631
|
}
|
|
630
632
|
|
|
631
633
|
private void stopStreamInternal() {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
634
|
+
synchronized (this) {
|
|
635
|
+
if (activeStream != null) {
|
|
636
|
+
try {
|
|
637
|
+
activeStream.stop();
|
|
638
|
+
} catch (Exception e) {
|
|
639
|
+
Log.e(TAG, "Stop stream error", e);
|
|
640
|
+
}
|
|
641
|
+
activeStream = null;
|
|
637
642
|
}
|
|
638
|
-
|
|
643
|
+
streamer = null;
|
|
644
|
+
latestBitmap = null;
|
|
639
645
|
}
|
|
640
|
-
streamer = null;
|
|
641
|
-
latestBitmap = null;
|
|
642
646
|
Log.d(TAG, "Streaming stopped");
|
|
643
647
|
}
|
|
644
648
|
|