2021年7月

红外热成像测试

ir (3).jpg
微信图片_20210718135025.jpg
微信图片_20210718135017.jpg

  # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""This example is for Raspberry Pi (Linux) only!
   It will not work on microcontrollers running CircuitPython!"""

import math
from PIL import Image
import board
import adafruit_mlx90640

FILENAME = "mlx.jpg"

MINTEMP = 25.0  # low range of the sensor (deg C)
MAXTEMP = 45.0  # high range of the sensor (deg C)
COLORDEPTH = 1000  # how many color values we can have
INTERPOLATE = 10  # scale factor for final image

mlx = adafruit_mlx90640.MLX90640(board.I2C())

# the list of colors we can choose from
heatmap = (
    (0.0, (0, 0, 0)),
    (0.20, (0, 0, 0.5)),
    (0.40, (0, 0.5, 0)),
    (0.60, (0.5, 0, 0)),
    (0.80, (0.75, 0.75, 0)),
    (0.90, (1.0, 0.75, 0)),
    (1.00, (1.0, 1.0, 1.0)),
)

colormap = [0] * COLORDEPTH

# some utility functions
def constrain(val, min_val, max_val):
    return min(max_val, max(min_val, val))


def map_value(x, in_min, in_max, out_min, out_max):
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min


def gaussian(x, a, b, c, d=0):
    return a * math.exp(-((x - b) ** 2) / (2 * c ** 2)) + d


def gradient(x, width, cmap, spread=1):
    width = float(width)
    r = sum(
        [gaussian(x, p[1][0], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    g = sum(
        [gaussian(x, p[1][1], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    b = sum(
        [gaussian(x, p[1][2], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    r = int(constrain(r * 255, 0, 255))
    g = int(constrain(g * 255, 0, 255))
    b = int(constrain(b * 255, 0, 255))
    return r, g, b


for i in range(COLORDEPTH):
    colormap[i] = gradient(i, COLORDEPTH, heatmap)

# get sensor data
frame = [0] * 768
success = False
while not success:
    try:
        mlx.getFrame(frame)
        success = True
    except ValueError:
        continue

# create the image
pixels = [0] * 768
for i, pixel in enumerate(frame):
    coloridx = map_value(pixel, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1)
    coloridx = int(constrain(coloridx, 0, COLORDEPTH - 1))
    pixels[i] = colormap[coloridx]
    print(pixels[i])

# save to file
img = Image.new("RGB", (32, 24))
img.putdata(pixels)
img = img.transpose(Image.FLIP_TOP_BOTTOM)
img = img.resize((32 * INTERPOLATE, 24 * INTERPOLATE), Image.BICUBIC)
img.save("ir.jpg")

利用玄学解决液压履带式起重机力矩算法及古法锻造青铜剑

玄学与科学的区别在于科学在乎过程而玄学却可以忽略过程。就拿数据函数y=f(x)做个比方,玄学并不在乎f是什么,他只需要不断的穷举x的值获得y的值从而建立一张表,下次可以直接通过y的值查出x的值,中医和炼丹术皆用此种方法,从神农尝百草就可以片面看出。
履带式起重机的力矩算法相当让人头疼,第一臂长是可伸缩的,也并不是均匀,越往远端越细,关节间也不是耦合紧密 可能存在松动,在吊取物体时臂杆还存在挠性,吊得越重弯的越厉害,第二臂杆在起落的过程与地面形成的夹角也在变化,这个变化单独拿来当做理想情况下算都好算,最终的目的是需要根据臂杆的支撑轴安装的液压传感器的压力值来计算出当前吊重,如果都是在理想情况下都好计算,但实际情况不可能理想,连起重机的使用年限都会影响计算结果,当然 如果这些用科学来计算法也不是无解,只是花的时间和精力会比较大,而且也不是一般学渣能够完成。
针对此种情况,用玄学来解决这个问题似乎是完美的,首先实时采集吊取物体的重量和液压的压力值和臂杆的夹角,并把臂杆慢慢伸缩一遍,抬起放下一遍,吊装物体的重量从小到大从大到小过一遍,并且实时记录这些值经过简单分析入库,正常工作时就可以通过查询当前压力夹角和臂长就可以查询到当前起吊的重量。
几千年前的青铜剑的锻造技术,现在人都不一定能复制出完全一模一样,是现在人技术不行吗,不是的,只是现在人缺乏那种多代人甚至很多个多代人经过无数次的尝试才造出来。
针对三体问题也是一样,宇宙中的两个天体之间的作用力很好计算,下一时刻的姿态也很好计算,当第三个天体加入的时候兴许也能计算,但当第四个五个....参入时,是不是差不多无解了,是不是玄学也也无法解决这个问题呢,当然不是src=http___www.tlang.com_images_store_611703_item_XGC120T.jpg_m.jpg&refer=http___www.tlang.jpg