Exemplo n.º 1
0
    def load_data(self):
        data = None

        try:
            data = {}
            sensor = mp.AMGGridEye(self.i2c_address, self.i2c_bus)
            sensor.set_fps_mode(mp.AMGGridEye.FPS_1_MODE)
            sensor.update_temperature()
            data['temperature'] = float(sensor.get_temperature())

        except Exception as ex:
            print(ex)

        return data
Exemplo n.º 2
0
def main():
    # initialize pygame
    pygame.init()

    # screen globals

    resolution = 32
    rect_scale = 8
    game_screen = pygame.display.set_mode(
        (resolution * rect_scale, resolution * rect_scale))
    pygame.display.set_caption('grid eye')

    eye = mp.AMGGridEye()
    eye.reset_flags_and_settings()
    time.sleep(.1)
    eye.set_fps_mode(mp.AMGGridEye.FPS_10_MODE)

    #INTERPOLATION
    points = np.array([(i // 8, i % 8) for i in range(64)]).reshape(64, 2)
    grid_x, grid_y = np.mgrid[0:7:32j, 0:7:32j]

    do_main = True
    while do_main:
        pressed = pygame.key.get_pressed()
        pygame.key.set_repeat()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                do_main = False

            if pressed[pygame.K_ESCAPE]:
                do_main = False

        game_screen.fill((0, 0, 0))

        eye.update_pixel_temperature_matrix()
        matrix = np.array(eye.get_pixel_temperature_matrix()).reshape(64)
        interpolated_grid = interpolator.griddata(points,
                                                  matrix, (grid_x, grid_y),
                                                  method='cubic')
        for i, row in enumerate(interpolated_grid):
            for j, temp in enumerate(row):
                pygame.draw.rect(game_screen, temp_to_color(temp),
                                 ((rect_scale * j, rect_scale * i),
                                  (rect_scale, rect_scale)))

        pygame.display.update()

        #time.sleep(0.1)

    pygame.quit()
Exemplo n.º 3
0
import array
import picamera
import time
import numpy
import uuid
import melopero_amg8833 as mp
import matplotlib.pyplot as plt
from PIL import Image

cam = picamera.PiCamera(resolution=(1280, 720), framerate=30)
cam.color_effects = (128,128)
cam.start_preview()
sensor = mp.AMGGridEye()
sensor.set_fps_mode(mp.AMGGridEye.FPS_10_MODE)
time.sleep(.5)

def mapper(thefn):
    fig = plt.figure(frameon=False)
    grid = sensor.get_pixel_temperature_matrix()
    boondoggle = []
    for hrow in grid:
        boondoggle.append(hrow)       
    colorarray = numpy.array(boondoggle)
    fig.imshow(colorarray, cmap='plasma')
    savefn = thefn + ".png"
    fig.savefig(savefn,  transparent=True)

while(True):
    newfn = uuid.uuid4()
    sensor.update_pixel_temperature_matrix()
    camfn = str(newfn) + ".png"
Exemplo n.º 4
0
 def _load_hardware(self):
   address = self._address
   device = melopero_amg8833.AMGGridEye(address[0],1 if len(address) == 1 or int(address[1]) < 1 else int(address[1]))
   device.set_fps_mode(melopero_amg8833.AMGGridEye.FPS_1_MODE)
   return device