奔驰c63amg:树莓派 AMG8833热像仪 如何打印检测到的最高温度

关于奔驰c63amg的问题,在thermal camera for raspberry pi中经常遇到, 我一直在遵循本教程-https://www.instructables.com/Thermal-Camera-AMG833-Raspberry-Pi/

我一直在遵循本教程-https://www.instructables.com/Thermal-Camera-AMG833-Raspberry-Pi/

它工作良好,如图所示。我可以在窗口中看到图形温度参考。

代码:

from Adafruit_AMG88xx import Adafruit_AMG88xx
import pygame
import os
import math
import time
import numpy as np
from scipy.interpolate import griddata
from colour import Color
#low range of the sensor (this will be blue on the screen)
MINTEMP = 26
#high range of the sensor (this will be red on the screen)
MAXTEMP = 32
#how many color values we can have
COLORDEPTH = 1024
os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()
#initialize the sensor
sensor = Adafruit_AMG88xx()
points = [(math.floor(ix / 8), (ix % 8)) for ix in range(0, 64)]
grid_x, grid_y = np.mgrid[0:7:32j, 0:7:32j]
#sensor is an 8x8 grid so lets do a square
height = 240
width = 240
#the list of colors we can choose from
blue = Color("indigo")
colors = list(blue.range_to(Color("red"), COLORDEPTH))
#create the array of colors
colors = [(int(c.red * 255), int(c.green * 255), int(c.blue * 255)) for c in colors]
displayPixelWidth = width / 30
displayPixelHeight = height / 30
lcd = pygame.display.set_mode((width, height))
lcd.fill((255,0,0))
pygame.display.update()
pygame.mouse.set_visible(False)
lcd.fill((0,0,0))
pygame.display.update()
#some utility functions
def constrain(val, min_val, max_val):
    return min(max_val, max(min_val, val))
def map(x, in_min, in_max, out_min, out_max):
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
#let the sensor initialize
time.sleep(.1)
    
while(1):
    #read the pixels
    pixels = sensor.readPixels()
    pixels = [map(p, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1) for p in pixels]
    
    #perdorm interpolation
    bicubic = griddata(points, pixels, (grid_x, grid_y), method='cubic')
    
    #draw everything
    for ix, row in enumerate(bicubic):
        for jx, pixel in enumerate(row):
            pygame.draw.rect(lcd, colors[constrain(int(pixel), 0, COLORDEPTH- 1)], (displayPixelHeight * ix, displayPixelWidth * jx, displayPixelHeight, displayPixelWidth))
    
    pygame.display.update()
https://github.com/adafruit/Adafruit_AMG88xx_python/blob/master/examples/thermal_cam.py

但是如何将最高测量温度打印到控制台,以便以后可以使用该值?

谢谢

1

要获得每帧的最大值,只需在pixels = sensor.readPixels()之后立即添加print(max(pixels))

这应该足够快,不会对脚本的其余部分造成任何明显的缓慢。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(66)
编程符号:Mathematica:什么是符号编程
上一篇
前列腺高c是什么:树高的定义是什么 (definition of a tree)
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(39条)