ilabs-flir 2.4.4 → 2.4.6
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/android/Flir/src/main/java/flir/android/FlirManager.kt +16 -4
- package/android/Flir/src/main/java/flir/android/FlirModule.kt +2 -2
- package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +31 -0
- package/ios/Flir/src/FlirManager.swift +16 -3
- package/ios/Flir/src/FlirModule.m +6 -5
- package/package.json +1 -1
|
@@ -250,11 +250,23 @@ object FlirManager {
|
|
|
250
250
|
return if (temp != null && !temp.isNaN()) temp else null
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
fun getTemperatureAtNormalized(nx: Double, ny: Double): Double? {
|
|
253
|
+
fun getTemperatureAtNormalized(nx: Double, ny: Double, rotation: Int = -90): Double? {
|
|
254
254
|
val bitmap = latestBitmap ?: return null
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
|
|
256
|
+
// Map UI normalized (0..1) to Raw sensor normalized (0..1) based on display rotation
|
|
257
|
+
// Using generic trigonometric rotation formula for total precision
|
|
258
|
+
val angle = -rotation.toDouble() // Inverse the display rotation
|
|
259
|
+
val rad = Math.toRadians(angle)
|
|
260
|
+
val cosA = Math.cos(rad)
|
|
261
|
+
val sinA = Math.sin(rad)
|
|
262
|
+
|
|
263
|
+
// Rotate around center (0.5, 0.5)
|
|
264
|
+
val dx = nx - 0.5
|
|
265
|
+
val dy = ny - 0.5
|
|
266
|
+
val rawX = dx * cosA - dy * sinA + 0.5
|
|
267
|
+
val rawY = dx * sinA + dy * cosA + 0.5
|
|
268
|
+
|
|
269
|
+
return FlirSdkManager.getInstance(reactContext).getTemperatureAtNormalized(rawX, rawY)
|
|
258
270
|
}
|
|
259
271
|
|
|
260
272
|
fun getTemperatureAtPoint(x: Int, y: Int): Double? = getTemperatureAt(x, y)
|
|
@@ -69,9 +69,9 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
@ReactMethod
|
|
72
|
-
fun getTemperatureAtNormalized(nx: Double, ny: Double, promise: Promise?) {
|
|
72
|
+
fun getTemperatureAtNormalized(nx: Double, ny: Double, rotation: Int, promise: Promise?) {
|
|
73
73
|
try {
|
|
74
|
-
val temp = FlirManager.getTemperatureAtNormalized(nx, ny)
|
|
74
|
+
val temp = FlirManager.getTemperatureAtNormalized(nx, ny, rotation)
|
|
75
75
|
if (temp != null) promise?.resolve(temp) else promise?.resolve(null)
|
|
76
76
|
} catch (e: Exception) {
|
|
77
77
|
promise?.reject("ERR_FLIR_TEMP_NORM", e)
|
|
@@ -579,6 +579,37 @@ public class FlirSdkManager {
|
|
|
579
579
|
return result[0];
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Samples temperature using normalized coordinates (0.0 to 1.0)
|
|
584
|
+
* This avoids clamping bugs when UI dimensions differ from sensor dimensions.
|
|
585
|
+
*/
|
|
586
|
+
public double getTemperatureAtNormalized(double nx, double ny) {
|
|
587
|
+
final double[] result = { Double.NaN };
|
|
588
|
+
synchronized (this) {
|
|
589
|
+
if (streamer == null) return Double.NaN;
|
|
590
|
+
try {
|
|
591
|
+
streamer.withThermalImage(thermalImage -> {
|
|
592
|
+
try {
|
|
593
|
+
int w = thermalImage.getWidth();
|
|
594
|
+
int h = thermalImage.getHeight();
|
|
595
|
+
// Map normalized 0..1 to sensor pixels 0..w-1
|
|
596
|
+
int cx = (int) Math.max(0, Math.min(w - 1, nx * w));
|
|
597
|
+
int cy = (int) Math.max(0, Math.min(h - 1, ny * h));
|
|
598
|
+
ThermalValue value = thermalImage.getValueAt(new Point(cx, cy));
|
|
599
|
+
if (value != null) {
|
|
600
|
+
result[0] = value.asCelsius().value;
|
|
601
|
+
}
|
|
602
|
+
} catch (Exception e) {
|
|
603
|
+
Log.w(TAG, "Normalized temp query error", e);
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
} catch (Exception e) {
|
|
607
|
+
Log.w(TAG, "Normalized temp query failed", e);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return result[0];
|
|
611
|
+
}
|
|
612
|
+
|
|
582
613
|
// ==================== LISTENERS ====================
|
|
583
614
|
|
|
584
615
|
public void setPalette(String paletteName) {
|
|
@@ -468,7 +468,7 @@ import ThermalSDK
|
|
|
468
468
|
#endif
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
@objc public func getTemperatureAtNormalized(_ nx: Double, y: Double) -> Double {
|
|
471
|
+
@objc public func getTemperatureAtNormalized(_ nx: Double, y: Double, rotation: Int) -> Double {
|
|
472
472
|
#if FLIR_ENABLED
|
|
473
473
|
guard let streamer = streamer, _isStreaming else { return Double.nan }
|
|
474
474
|
|
|
@@ -477,9 +477,22 @@ import ThermalSDK
|
|
|
477
477
|
let w = Double(thermalImage.getWidth())
|
|
478
478
|
let h = Double(thermalImage.getHeight())
|
|
479
479
|
|
|
480
|
+
// Map UI normalized (0..1) to Raw sensor normalized (0..1) based on display rotation
|
|
481
|
+
// Using generic trigonometric rotation formula for total precision
|
|
482
|
+
let angle = -Double(rotation) // Inverse the display rotation
|
|
483
|
+
let rad = angle * .pi / 180.0
|
|
484
|
+
let cosA = cos(rad)
|
|
485
|
+
let sinA = sin(rad)
|
|
486
|
+
|
|
487
|
+
// Rotate around center (0.5, 0.5)
|
|
488
|
+
let dx = nx - 0.5
|
|
489
|
+
let dy = y - 0.5
|
|
490
|
+
let rawX = dx * cosA - dy * sinA + 0.5
|
|
491
|
+
let rawY = dx * sinA + dy * cosA + 0.5
|
|
492
|
+
|
|
480
493
|
// Map normalized (0.0 - 1.0) to actual sensor pixels
|
|
481
|
-
let cx = max(0, min(Int(w) - 1, Int(
|
|
482
|
-
let cy_fixed = max(0, min(Int(h) - 1, Int(
|
|
494
|
+
let cx = max(0, min(Int(w) - 1, Int(rawX * w)))
|
|
495
|
+
let cy_fixed = max(0, min(Int(h) - 1, Int(rawY * h)))
|
|
483
496
|
|
|
484
497
|
if let measurements = thermalImage.measurements,
|
|
485
498
|
let spot = try? measurements.addSpot(CGPoint(x: cx, y: cy_fixed)) {
|
|
@@ -332,7 +332,8 @@ RCT_EXPORT_METHOD(getTemperatureAt : (nonnull NSNumber *)x y : (
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
RCT_EXPORT_METHOD(getTemperatureAtNormalized : (nonnull NSNumber *)nx y : (
|
|
335
|
-
nonnull NSNumber *)ny
|
|
335
|
+
nonnull NSNumber *)ny rotation : (nonnull NSNumber *)rotation
|
|
336
|
+
resolver : (RCTPromiseResolveBlock)
|
|
336
337
|
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
337
338
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
338
339
|
id manager = flir_manager_shared();
|
|
@@ -340,11 +341,11 @@ RCT_EXPORT_METHOD(getTemperatureAtNormalized : (nonnull NSNumber *)nx y : (
|
|
|
340
341
|
if (manager &&
|
|
341
342
|
[manager
|
|
342
343
|
respondsToSelector:sel_registerName(
|
|
343
|
-
"getTemperatureAtNormalized:y:")]) {
|
|
344
|
-
temp = ((double (*)(id, SEL, double, double))objc_msgSend)(
|
|
344
|
+
"getTemperatureAtNormalized:y:rotation:")]) {
|
|
345
|
+
temp = ((double (*)(id, SEL, double, double, NSInteger))objc_msgSend)(
|
|
345
346
|
manager,
|
|
346
|
-
sel_registerName("getTemperatureAtNormalized:y:"),
|
|
347
|
-
[nx doubleValue], [ny doubleValue]);
|
|
347
|
+
sel_registerName("getTemperatureAtNormalized:y:rotation:"),
|
|
348
|
+
[nx doubleValue], [ny doubleValue], [rotation integerValue]);
|
|
348
349
|
}
|
|
349
350
|
if (isnan(temp)) {
|
|
350
351
|
if (resolve) resolve([NSNull null]);
|