-
Notifications
You must be signed in to change notification settings - Fork 0
/
thermalimg2file.py
38 lines (32 loc) · 1 KB
/
thermalimg2file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import pygame
import pygame.camera
import cv2
from imutils.video import VideoStream
import imutils
import os
imageSwapFolder = "/dev/shm/pineal"
newImageFlagFile = "/dev/shm/pineal/thermal_image_status.txt"
if not os.path.exists(imageSwapFolder):
os.makedirs(imageSwapFolder)
if not os.path.exists(newImageFlagFile):
os.system("sudo touch /dev/shm/pineal/thermal_image_status.txt")
os.chown('/dev/shm/pineal/thermal_image_status.txt', 0, 0)
pygame.init()
pygame.camera.init()
#find, open and start low-res camera
cam_list = pygame.camera.list_cameras()
webcam = pygame.camera.Camera(cam_list[0],(32,24))
webcam.start()
while True:
#grab image, scale and blit to screen
img = webcam.get_image()
pygame.image.save(img, '/dev/shm/pineal/thermal.bmp')
f = open(newImageFlagFile, 'w+')
f.write('new')
# check for quit events
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
webcam.stop()
pygame.quit()
sys.exit()