#low range of the sensor (this will be blue on the screen) MINTEMP = 20 #high range of the sensor (this will be red on the screen) MAXTEMP = 28 #how many color values we can have COLORDEPTH = 1024 os.putenv('SDL_FBDEV', '/dev/fb1') pygame.init() #initialize the sensor sensor = Seeed_AMG8833.AMG8833() 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]
def __init__(self): self.sensor = Seeed_AMG8833.AMG8833() self.filter_list = [] self.window_list = [] self.filt_data = [] self.counts = 0
def main_function(): # 여러 용도로 사용할 시스템타임의 변수 (형식: 년-월-일-시-분-초) System_Time = time.strftime("%Y-%m-%d-%H-%M-%S") WAVE_OUTPUT_FILENAME = System_Time + ".wav" rasp_function.speech("원하는 기능을 말씀해주세요. 5초 동안 녹음이 시작됩니다.") time.sleep(5) os.system('play -nq -t alsa synth {} sine {}'.format(0.5, 440)) rasp_function.recording(WAVE_OUTPUT_FILENAME) #생성한 wav파일을 S3로 업로드 및 wav파일 삭제 rasp_function.S3("/tmp/%s" % WAVE_OUTPUT_FILENAME, wav_bucket, WAVE_OUTPUT_FILENAME) time.sleep(2) os.remove("/tmp/%s" % WAVE_OUTPUT_FILENAME) rasp_function.speech("녹음이 종료되었습니다. 음성인식이 완료될 떄 까지 잠시만 기다려주세요.") #transcribejob 생성될 때 까지 대기 후 텍스트 받아오기 text = rasp_function.transcribe(WAVE_OUTPUT_FILENAME) print("Transcribe 결과 " + "\"" + text + "\"") #transcribe 결과에 따른 별도절차 진행 if text[0:1] == 등록: status = "IN" rasp_function.speech("등록절차를 진행합니다. 카메라 위치에 얼굴을 맞춰주세요.") time.sleep(2) print("사진촬영을 시작합니다.") capture(status, WAVE_OUTPUT_FILENAME) # 이미지를 s3에 업로드 IMAGE_OUTPUT_FILENAME = "%s-%s.jpg" % (status, WAVE_OUTPUT_FILENAME) print(IMAGE_OUTPUT_FILENAME) rasp_function.S3("/tmp/%s" % IMAGE_OUTPUT_FILENAME, image_bucket, IMAGE_OUTPUT_FILENAME) time.sleep(5) rasp_function.speech( rasp_function.read_text(text_bucket, IMAGE_OUTPUT_FILENAME)) elif text[0:1] == 출석: status = "CI" rasp_function.speech("출석절차를 진행합니다. 카메라 위치에 얼굴을 맞춰주세요.") time.sleep(2) print("사진촬영을 시작합니다.") capture(status, WAVE_OUTPUT_FILENAME) IMAGE_OUTPUT_FILENAME = "%s-%s.jpg" % (status, WAVE_OUTPUT_FILENAME, temp) temp = Seeed_AMG8833.cal_temp() # 온도값을 S3에 업로드 rasp_function.write_text(text_bucket, IMAGE_OUTPUT_FILENAME, temp) print(IMAGE_OUTPUT_FILENAME) rasp_function.S3("/tmp/%s" % IMAGE_OUTPUT_FILENAME, image_bucket, IMAGE_OUTPUT_FILENAME) time.sleep(5) rasp_function.speech( rasp_function.read_text(text_bucket, IMAGE_OUTPUT_FILENAME)) elif text[0:1] == 퇴실: status = "CO" time.sleep(2) rasp_function.speech("퇴실절차를 진행합니다. 카메라 위치에 얼굴을 맞춰주세요.") print("사진촬영을 시작합니다.") capture(status, WAVE_OUTPUT_FILENAME) IMAGE_OUTPUT_FILENAME = "%s-%s.jpg" % (status, WAVE_OUTPUT_FILENAME) temp = Seeed_AMG8833.cal_temp() # 온도값을 S3에 업로드 rasp_function.write_text(text_bucket, IMAGE_OUTPUT_FILENAME, temp) print(IMAGE_OUTPUT_FILENAME) rasp_function.S3("/tmp/%s" % IMAGE_OUTPUT_FILENAME, image_bucket, IMAGE_OUTPUT_FILENAME) time.sleep(5) rasp_function.speech( rasp_function.read_text(text_bucket, IMAGE_OUTPUT_FILENAME)) else: rasp_function.speech("음성을 인식하지 못했습니다. 다시 한번 시도해주세요.")
def thermal_cam(): #low range of the sensor (this will be blue on the screen) MINTEMP = 32 #high range of the sensor (this will be red on the screen) MAXTEMP = 37 #how many color values we can have COLORDEPTH = 1024 os.putenv('SDL_FBDEV', '/dev/fb1') pygame.init() #initialize the sensor sensor = Seeed_AMG8833.AMG8833() 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.read_temp() 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()