×
INDI Library v1.8.5 Released (19 Apr 2020)

April 2020 release of INDI Library v1.8.5 introduces new drivers while providing fixes and improvements to existing devices and core framework.

Python and INDI: from BLOBS to numpy.array

8 months 4 days ago
andreaconsole
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Python and INDI: from BLOBS to numpy.array #45594
Hi everyone,
I'm developing a Python program based on INDI for EAA (Electronically Assisted Astronomy). The interface with INDI is based on this tutorial : indilib.org/develop/tutorials/151-time-l...ith-indi-python.html
My problem is that I don't know how to convert the BLOB bytes I get to numpy.array to allow further processing. Can anybody help me?

<code>
# get image data
img = bp.getblobdata()
# write image data to BytesIO buffer
import io
blobfile = io.BytesIO(img)
# open a file and save buffer to disk
with open("frame.fit", "wb") as f:
f.write(blobfile.getvalue())
</code>

Please Log in or Create an account to join the conversation.

8 months 4 days ago
mikefulb
Expert Boarder
Expert Boarder
Posts: 96
Karma: 2
More
Python and INDI: from BLOBS to numpy.array #45603
This is a quick and dirty example that should work.

import astropy.io.fits as pyfits
blob = blobEvent
fits=blob.getblobdata()
blobfile = BytesIO(fits)
hdulist = pyfits.open(blobfile)
image_data =hdulist[0].data

image_data will now be a 2D numpy array with the first index being 'Y' and the second 'X' in the traditional sense of indexing images.

You can do:

image_data = numpy.transpose(image_data)

to flip it around to X first then Y.

This example assumes the data is in the primary HDU header which I think is always the case for INDI generated FITS representations of an image in memory.

You can read more starting here:

docs.astropy.org/en/stable/io/fits/usage/headers.html

Please Log in or Create an account to join the conversation.

8 months 3 days ago
andreaconsole
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Python and INDI: from BLOBS to numpy.array #45608
It works like a charm, thank you!

Please Log in or Create an account to join the conversation.

8 months 3 days ago
mikefulb
Expert Boarder
Expert Boarder
Posts: 96
Karma: 2
More
Python and INDI: from BLOBS to numpy.array #45611
Great - I've written a large amount of code for INDI using Python so let me know if I can be any help.

Please Log in or Create an account to join the conversation.

5 months 1 week ago
limburg11
Senior Boarder
Senior Boarder
Posts: 47
More
Python and INDI: from BLOBS to numpy.array #48814
This project sounds great! How's your progress? I'd love to see some EAA feature in Ekos...

Cheers,
Bernd

Celestron C9.25 on HEQ-5 with belt mod, Celestron SCT focuser, ASI294MC Pro, ASI290MM mini (off-axis guiding), Astroberry on RPi4b, PixInsight

Please Log in or Create an account to join the conversation.

5 months 1 week ago
andreaconsole
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Python and INDI: from BLOBS to numpy.array #48815
Hi,
I wrote the software and tested it with the simulated camera and it seems working. Unfortunately, I've been too lazy to bring my setup back to life for a real test on the field so far...

Please Log in or Create an account to join the conversation.

5 months 1 week ago
limburg11
Senior Boarder
Senior Boarder
Posts: 47
More
Python and INDI: from BLOBS to numpy.array #48823
Live stacking in Ekos should be thrilling and motivating, shouldn't it? ;) :cheer:

Celestron C9.25 on HEQ-5 with belt mod, Celestron SCT focuser, ASI294MC Pro, ASI290MM mini (off-axis guiding), Astroberry on RPi4b, PixInsight

Please Log in or Create an account to join the conversation.

5 months 2 days ago
andreaconsole
Fresh Boarder
Fresh Boarder
Posts: 7
More
Topic Author
Python and INDI: from BLOBS to numpy.array #49356
That was the idea! But questionable weather, the hassle to start again after five years and small children around work against me :lol:
By the way, here (GitHub) anyone with more energy than me can find my first experiment to further develop. It has just the basic functions, I have more fancy algorithms in mind once this first proof of concept seems to work properly

Please Log in or Create an account to join the conversation.

Time to create page: 0.538 seconds