adafruit / Adafruit_AMG88xx_python

AMG88xx Grid-EYE
MIT License
16 stars 21 forks source link

Hiccups in data reading (based on "thermalcam.py") #8

Closed garrett-laroy-johnson closed 6 years ago

garrett-laroy-johnson commented 6 years ago

Hello all

running some code based off AdaFruit's examples using AMG8833 module + Raspberry Pi Zero W.

The python code below reads the pixels in as quickly as it can, formats it as an OSC message and sends to a designated IP where I'd like to signal process in Max to compose some responsive media.

` from Adafruit_AMG88xx import Adafruit_AMG88xx from time import sleep from os import putenv from OSC import OSCClient, OSCMessage from socket import gethostname

putenv('SDL_FBDEV', '/dev/fb1')

get socket/hostname

id = gethostname()

initialize the sensor

sensor = Adafruit_AMG88xx() sleep(.1)

initialize OSC client

client = OSCClient() client.connect(('192.168.200.246', 9876))

224.0.0.1

run code, read sensor

while(True):

    client.send( OSCMessage("/thermal/"+id, sensor.readPixels()))

` screen shot 2018-07-11 at 5 13 08 pm

However I am running into a hiccup, and I am not sure the source (it could be the python code, streaming over the network, or some interrupting background process in the Raspbian stretch OS)

After receiving the data, I receive at a smooth frame rate (~80ms) for about 4 seconds, then a hiccup. This is entirely regular. See the screenshot of the visualization of the frame rate in Max Msp (attached).

I have tried experimenting with a time.sleep in the while loop at different intervals but the frame rate decreases and the hiccup persists. I have also tried experimenting with some overclocking settings, etc. I am wondering if anyone has run into a similar problem and knows what the source of the hiccup is and how to fix it! Thanks.

deanm1278 commented 6 years ago

hey @garrett-laroy-johnson I don't think this is an issue with this library. The stock raspbian operating system is doing lots of stuff in the background as you've noted, and isn't always going to be able to run your threads at the exact time you want. The best place to get help with your projects is the Adafruit forums, please make a post there :)