ilabs-flir 2.3.3 → 2.3.4
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.
|
@@ -85,8 +85,18 @@ object FlirManager {
|
|
|
85
85
|
}
|
|
86
86
|
fun getAvailablePalettes(): List<String> {
|
|
87
87
|
return try {
|
|
88
|
-
PaletteManager.getDefaultPalettes().map { it.name }
|
|
89
|
-
|
|
88
|
+
val palettes = PaletteManager.getDefaultPalettes().map { it.name }.toMutableList()
|
|
89
|
+
// Move WhiteHot/Gray to the front
|
|
90
|
+
val grayIdx = palettes.indexOfFirst {
|
|
91
|
+
it.equals("WhiteHot", ignoreCase = true) || it.equals("Gray", ignoreCase = true) || it.contains("gray", ignoreCase = true)
|
|
92
|
+
}
|
|
93
|
+
if (grayIdx > 0) {
|
|
94
|
+
val gray = palettes.removeAt(grayIdx)
|
|
95
|
+
palettes.add(0, gray)
|
|
96
|
+
}
|
|
97
|
+
palettes
|
|
98
|
+
} catch (t: Throwable) {
|
|
99
|
+
Log.e(TAG, "Failed to get available palettes from SDK", t)
|
|
90
100
|
listOf("grayscale", "iron", "rainbow", "arctic", "lava", "contrast", "hotcold", "medical")
|
|
91
101
|
}
|
|
92
102
|
}
|
|
@@ -477,7 +487,18 @@ object FlirManager {
|
|
|
477
487
|
fun generatePaletteIcons(context: Context): List<Map<String, String>> {
|
|
478
488
|
val results = mutableListOf<Map<String, String>>()
|
|
479
489
|
try {
|
|
480
|
-
val
|
|
490
|
+
val rawPalettes = PaletteManager.getDefaultPalettes()
|
|
491
|
+
val palettes = rawPalettes.toMutableList()
|
|
492
|
+
|
|
493
|
+
// Reorder: Move WhiteHot/Gray to the front
|
|
494
|
+
val grayIdx = palettes.indexOfFirst {
|
|
495
|
+
it.name.equals("WhiteHot", ignoreCase = true) || it.name.equals("Gray", ignoreCase = true) || it.name.contains("gray", ignoreCase = true)
|
|
496
|
+
}
|
|
497
|
+
if (grayIdx > 0) {
|
|
498
|
+
val gray = palettes.removeAt(grayIdx)
|
|
499
|
+
palettes.add(0, gray)
|
|
500
|
+
}
|
|
501
|
+
|
|
481
502
|
val dir = File(context.cacheDir, "flir_palettes")
|
|
482
503
|
if (!dir.exists()) dir.mkdirs()
|
|
483
504
|
|
|
@@ -510,8 +531,8 @@ object FlirManager {
|
|
|
510
531
|
"uri" to if (iconFile.exists()) "file://${iconFile.absolutePath}" else ""
|
|
511
532
|
))
|
|
512
533
|
}
|
|
513
|
-
} catch (
|
|
514
|
-
Log.e(TAG, "Palette icon generation error",
|
|
534
|
+
} catch (t: Throwable) {
|
|
535
|
+
Log.e(TAG, "Palette icon generation error", t)
|
|
515
536
|
}
|
|
516
537
|
return results
|
|
517
538
|
}
|
|
@@ -51,7 +51,7 @@ public class FlirSdkManager {
|
|
|
51
51
|
private Stream activeStream;
|
|
52
52
|
private final List<Identity> discoveredDevices = Collections.synchronizedList(new ArrayList<>());
|
|
53
53
|
private volatile Bitmap latestBitmap;
|
|
54
|
-
private volatile String currentPaletteName = "
|
|
54
|
+
private volatile String currentPaletteName = "WhiteHot";
|
|
55
55
|
private final AtomicBoolean isProcessingFrame = new AtomicBoolean(false);
|
|
56
56
|
private boolean useHalfScale = false;
|
|
57
57
|
private String pendingSnapshotPath = null;
|
|
@@ -356,13 +356,23 @@ public class FlirSdkManager {
|
|
|
356
356
|
streamer.withThermalImage(thermalImage -> {
|
|
357
357
|
// 1. Apply Palette
|
|
358
358
|
if (paletteToApply != null) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
try {
|
|
360
|
+
Palette palette = null;
|
|
361
|
+
// Try modern way if available (via image's palette manager)
|
|
362
|
+
// Otherwise fallback to static PaletteManager
|
|
363
|
+
List<Palette> sdkPalettes = PaletteManager.getDefaultPalettes();
|
|
364
|
+
for (Palette p : sdkPalettes) {
|
|
365
|
+
if (p.name.equalsIgnoreCase(paletteToApply)) {
|
|
366
|
+
palette = p;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (palette != null) {
|
|
372
|
+
thermalImage.setPalette(palette);
|
|
373
|
+
}
|
|
374
|
+
} catch (Throwable t) {
|
|
375
|
+
Log.e(TAG, "Failed to apply palette: " + paletteToApply, t);
|
|
366
376
|
}
|
|
367
377
|
}
|
|
368
378
|
|
|
@@ -67,7 +67,7 @@ import ThermalSDK
|
|
|
67
67
|
private let stateLock = NSObject()
|
|
68
68
|
|
|
69
69
|
// Palette and Snapshot state
|
|
70
|
-
private var currentPaletteName: String = "
|
|
70
|
+
private var currentPaletteName: String = "WhiteHot"
|
|
71
71
|
private var pendingSnapshotPath: String?
|
|
72
72
|
|
|
73
73
|
// Dedicated render queue for frame processing (matches sample app pattern)
|
|
@@ -530,22 +530,21 @@ import ThermalSDK
|
|
|
530
530
|
|
|
531
531
|
@objc public func getAvailablePalettes() -> [String] {
|
|
532
532
|
#if FLIR_ENABLED
|
|
533
|
-
// We use a dummy thermal image to access palette manager if no streamer exists,
|
|
534
|
-
// but typically PaletteManager.getDefaultPalettes() might be static or available via streamer
|
|
535
533
|
if let streamer = streamer {
|
|
536
534
|
var names: [String] = []
|
|
537
535
|
streamer.withThermalImage { img in
|
|
538
|
-
|
|
536
|
+
var palettes = img.paletteManager.getDefaultPalettes().map { $0.name }
|
|
537
|
+
// Reorder: Move WhiteHot/Gray to the front
|
|
538
|
+
if let grayIdx = palettes.firstIndex(where: { $0.lowercased() == "whitehot" || $0.lowercased() == "gray" }) {
|
|
539
|
+
let gray = palettes.remove(at: grayIdx)
|
|
540
|
+
palettes.insert(gray, at: 0)
|
|
541
|
+
}
|
|
542
|
+
names = palettes
|
|
539
543
|
}
|
|
540
544
|
if !names.isEmpty { return names }
|
|
541
545
|
}
|
|
542
|
-
|
|
543
|
-
// Fallback: Try to get from a temporary thermal image if possible,
|
|
544
|
-
// but FLIR SDK often requires a valid image.
|
|
545
|
-
// For now, return a standard list if we can't get it dynamically,
|
|
546
|
-
// or try to find a static way.
|
|
547
546
|
#endif
|
|
548
|
-
return ["
|
|
547
|
+
return ["WhiteHot", "iron", "rainbow", "arctic", "lava", "contrast", "hotcold", "medical"]
|
|
549
548
|
}
|
|
550
549
|
|
|
551
550
|
@objc public func generatePaletteIcons() -> [[String: String]] {
|
|
@@ -562,7 +561,14 @@ import ThermalSDK
|
|
|
562
561
|
}
|
|
563
562
|
|
|
564
563
|
streamer.withThermalImage { thermalImage in
|
|
565
|
-
|
|
564
|
+
var palettes = thermalImage.paletteManager.getDefaultPalettes()
|
|
565
|
+
|
|
566
|
+
// Reorder: Move WhiteHot/Gray to the front
|
|
567
|
+
if let grayIdx = palettes.firstIndex(where: { $0.name.lowercased() == "whitehot" || $0.name.lowercased() == "gray" }) {
|
|
568
|
+
let gray = palettes.remove(at: grayIdx)
|
|
569
|
+
palettes.insert(gray, at: 0)
|
|
570
|
+
}
|
|
571
|
+
|
|
566
572
|
for palette in palettes {
|
|
567
573
|
let iconURL = paletteDir.appendingPathComponent("\(palette.name.lowercased()).png")
|
|
568
574
|
if !fileManager.fileExists(atPath: iconURL.path) {
|