ilabs-flir 2.2.31 → 2.2.32

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.
@@ -364,14 +364,22 @@ import ThermalSDK
364
364
 
365
365
  @objc public func getTemperatureAt(x: Int, y: Int) -> Double {
366
366
  #if FLIR_ENABLED
367
- guard let streamer = streamer else { return Double.nan }
367
+ guard let streamer = streamer, _isStreaming else { return Double.nan }
368
368
 
369
369
  var result = Double.nan
370
370
  streamer.withThermalImage { thermalImage in
371
- let w = thermalImage.getWidth()
372
- let h = thermalImage.getHeight()
373
- let cx = max(0, min(Int(w) - 1, x))
374
- let cy = max(0, min(Int(h) - 1, y))
371
+ let w = Double(thermalImage.getWidth())
372
+ let h = Double(thermalImage.getHeight())
373
+
374
+ // Map incoming integer coordinates (from latestImage) to normalized, then to sensor
375
+ // This assumes x,y are in latestImage coordinate space.
376
+ guard let img = self.latestImage, img.size.width > 0, img.size.height > 0 else { return }
377
+
378
+ let nx = Double(x) / Double(img.size.width)
379
+ let ny = Double(y) / Double(img.size.height)
380
+
381
+ let cx = max(0, min(Int(w) - 1, Int(nx * w)))
382
+ let cy = max(0, min(Int(h) - 1, Int(ny * h)))
375
383
 
376
384
  if let measurements = thermalImage.measurements,
377
385
  let spot = try? measurements.addSpot(CGPoint(x: cx, y: cy)) {
@@ -393,10 +401,28 @@ import ThermalSDK
393
401
 
394
402
 
395
403
  @objc public func getTemperatureAtNormalized(_ nx: Double, y: Double) -> Double {
396
- guard let img = latestImage else { return Double.nan }
397
- let px = Int(nx * Double(img.size.width))
398
- let py = Int(y * Double(img.size.height))
399
- return getTemperatureAt(x: px, y: py)
404
+ #if FLIR_ENABLED
405
+ guard let streamer = streamer, _isStreaming else { return Double.nan }
406
+
407
+ var result = Double.nan
408
+ streamer.withThermalImage { thermalImage in
409
+ let w = Double(thermalImage.getWidth())
410
+ let h = Double(thermalImage.getHeight())
411
+
412
+ // Map normalized (0.0 - 1.0) to actual sensor pixels
413
+ let cx = max(0, min(Int(w) - 1, Int(nx * w)))
414
+ let cy = max(0, min(Int(h) - 1, Int(y * h)))
415
+
416
+ if let measurements = thermalImage.measurements,
417
+ let spot = try? measurements.addSpot(CGPoint(x: cx, y: cy)) {
418
+ result = spot.getValue().value
419
+ try? measurements.remove(spot)
420
+ }
421
+ }
422
+ return result
423
+ #else
424
+ return Double.nan
425
+ #endif
400
426
  }
401
427
 
402
428
  // MARK: - Legacy / Compatibility Methods
@@ -604,16 +630,21 @@ extension FlirManager: FLIRStreamDelegate {
604
630
  _isProcessingFrame = true
605
631
  renderQueue.async { [weak self] in
606
632
  defer { self?._isProcessingFrame = false }
607
- guard let self = self, let streamer = self.streamer else {
608
- NSLog("[FLIR-TRACE ❌] No self or streamer in renderQueue")
633
+ guard let self = self, self._isStreaming, let streamer = self.streamer else {
634
+ NSLog("[FLIR-TRACE ❌] No self, streamer or not streaming in renderQueue")
609
635
  return
610
636
  }
611
637
 
612
638
  NSLog("[FLIR-TRACE 2️⃣] Processing on renderQueue")
613
639
 
614
640
  do {
615
- try streamer.update()
616
- NSLog("[FLIR-TRACE 3️⃣] Streamer updated successfully")
641
+ // Double check streaming state before update to prevent EXC_BAD_ACCESS during shutdown
642
+ if self._isStreaming {
643
+ try streamer.update()
644
+ NSLog("[FLIR-TRACE 3️⃣] Streamer updated successfully")
645
+ } else {
646
+ return
647
+ }
617
648
  } catch {
618
649
  NSLog("[FLIR-TRACE ❌] Streamer update failed: \(error)")
619
650
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.2.31",
3
+ "version": "2.2.32",
4
4
  "description": "FLIR Thermal SDK for React Native - iOS & Android (bundled at compile time via postinstall)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",