0

要获得特定点的温度,您需要 X 和 Y 位置。

例如,您可以使用 View.IOnTouchListener 的 OnTouch 事件获取像素位置。

示例代码:

public bool OnTouch(View v, MotionEvent e)
{
   Position_X = (int)e.GetX();
   Position_Y = (int)e.GetY();
   return true;
}

和 OnFrameProcessed,您的代码将如下所示:

public void OnFrameProcessed(RenderedImage renderedImage)
{
  if (renderedImage.InvokeImageType() == RenderedImage.ImageType.ThermalRadiometricKelvinImage)
  {
      var step = renderedImage.Width();
      var pixel = Position_X + (Position_Y * step);
      var thermalPixels = renderedImage.ThermalPixelValues();
      if (thermalPixels.Length < pixel)
      {
         pixel = thermalPixels.Length - 1;
      }
      //temperature in point
      AvgPointTemperature = (thermalPixels[pixel] / 100.0) - 273.15;
  }
}

我不知道这是否是最好的方法,但这是我找到的方法。

谢谢。

4

1 回答 1

0

好的,这需要自定义一个 ContentPage以从 IOS 或 Android 设备获取 X 和 Y。

安卓

public override bool OnTouchEvent(MotionEvent e)
{
    Console.WriteLine("x->" + e.GetX() + "y->" + e.GetY());
    return base.OnTouchEvent(e);
}

IOS

public override void TouchesBegan(NSSet touches, UIEvent evt)
{
    base.TouchesBegan(touches, evt);
    UITouch touch = (UITouch)touches.AnyObject;
    CGPoint cp = touch.LocationInView(this.View);
    Console.WriteLine("x->" + cp.X + "y->" + cp.Y);
}
于 2019-07-05T07:37:21.973 回答