Welcome, Guest
Username: Password: Remember me
25 Jul 2018
Glad to announce of release of INDI Library v1.7.4 on 2018-07-25. A few drivers were added in this release as we continue to improve & stabilize existing drivers.
Read More...

TOPIC: Take image with python script

Take image with python script 3 years 5 months ago #3818

  • fehlfarbe
  • fehlfarbe's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 46
  • Karma: 1
  • Thank you received: 19
Do you habe the latest drivers and does the camera work with KStars/Ekos? (maybe this problem: indilib.org/forum/ccds-dslrs/548-zwo-asi...on.html?limitstart=0 )

I'm not really well versed in INDI but maybe you have to choose an avaiable camera after connecting to ASI CCD device.

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

Last Edit: by fehlfarbe.

Take image with python script 3 years 5 months ago #3819

I followed the tutorial on the indi web page for installing the driver, so I assume it is the newest one. I just installed Kstars, and did not get it to work there either, but that might have something to do with my lack of experience with astronomy software... I will investigate this further.

Thanks so far :-)

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

Take image with python script 3 years 5 months ago #3822

magnargj, I think you're using INDI packages for Raspberry PI which are using older ASI CCD driver. Try to compile INDI on your PI from SVN to use the latest driver which is known to work OK on the Raspberry PI.

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

Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info

Take image with python script 3 years 5 months ago #3824

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

Take image with python script 3 years 5 months ago #4028

  • gus_
  • gus_'s Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 6
I found this topic very interesting and went along the tutorial.
Compiling swig-indi-python showed many warnings, but I thought it wasn't important.
But as soon as I first ran:
python test-indiclient.py
I got:
pi@raspberrypi ~/swig-indi-python $ python test-indiclient.py
2015-04-21 14:24:52,125 creating an instance of PyQtIndi.IndiClient
Connecting and waiting 2secs
Server connected (localhost:7624)
2015-04-21 14:24:52,135 new device CCD Simulator
2015-04-21 14:24:52,136 new property CONNECTION for device CCD Simulator
2015-04-21 14:24:52,137 new property DRIVER_INFO for device CCD Simulator
2015-04-21 14:24:52,138 new property DEBUG for device CCD Simulator
2015-04-21 14:24:52,139 new property CONFIG_PROCESS for device CCD Simulator
2015-04-21 14:24:52,140 new property SIMULATOR_SETTINGS for device CCD Simulator
2015-04-21 14:24:52,141 new property ON_TIME_FACTOR for device CCD Simulator
List of devices
CCD Simulator
List of Device Properties
-- CCD Simulator
   > CONNECTION
swig/python detected a memory leak of type 'INDI_PROPERTY_TYPE *', no destructor found.
Traceback (most recent call last):
  File "test-indiclient.py", line 111, in <module>
    if p.getType()==PyIndi.INDI_TEXT:
AttributeError: 'module' object has no attribute 'INDI_TEXT'

Any advise?

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

Last Edit: by gus_.

Take image with python script 3 years 5 months ago #4039

  • fehlfarbe
  • fehlfarbe's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 46
  • Karma: 1
  • Thank you received: 19
Hey gus_,

that's weird. I had to recompile the Python wrappers and now I get the same errors. Maybe something changed in new Indi version?

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

Take image with python script 3 years 5 months ago #4040

INDI_TYPE was re-factored to INDI_PROPERTY_TYPE in v1.1.0 (which is not officially released yet), so to fix this, I suggest change all instances in the python stuff from INDI_TYPE to INDI_PROPERTY_TYPE
The following user(s) said Thank You: fehlfarbe, gus_

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

Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info

Take image with python script 3 years 5 months ago #4041

  • fehlfarbe
  • fehlfarbe's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 46
  • Karma: 1
  • Thank you received: 19
I'm using the PPA with the current version is 1.1.0. Did you also moved the INDI_TYPE enumerations to indibasetypes.h?

I solved the problem. Swig generates the Python wrappers but it didn't find the indibasetypes.h. So I just added in swig-indi-python/indiclientpython.i
%include <indibasetypes.h>
at line 48 (after %include <indiproperty.h>). Then I recompiled the wrappers (cmake, make, make install) and now the enumerations are avaiable by their old name (INDI_NUMBER etc.) and the script works :)

Edit:
Ok, now I see it. indibasetypes.h was added two weeks ago: sourceforge.net/p/indi/code/2194/?page=1#diff-1
The following user(s) said Thank You: gus_

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

Last Edit: by fehlfarbe.

Take image with python script 3 years 5 months ago #4044

  • gus_
  • gus_'s Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 45
  • Thank you received: 6
It worked for me too. Thank you!

Now let's code something interesting... ;)

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

Take image with python script 2 years 3 months ago #8572

  • patdut
  • patdut's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • Posts: 311
  • Karma: 1
  • Thank you received: 37
Hello I am trying to compile the swig-iindi-python. Compilation failed and I get the following message error.
Looks like something is missing to find the libindiserver.h file.

[ 33%] Building CXX object CMakeFiles/_PyIndi.dir/indiclientpythonPYTHON_wrap.cxx.o
[ 50%] Linking CXX shared module _PyIndi.so
[ 50%] Built target _PyIndi
[ 66%] Building C object CMakeFiles/_PyIndiServer.dir/indiserverpythonPYTHON_wrap.c.o
/home/pat/Téléchargements/YYY/libindipython/indiserverpythonPYTHON_wrap.c:3030:29: fatal error: libindiserver.h: Aucun fichier ou dossier de ce type
compilation terminated.
CMakeFiles/_PyIndiServer.dir/build.make:70 : la recette pour la cible « CMakeFiles/_PyIndiServer.dir/indiserverpythonPYTHON_wrap.c.o » a échouée
make[2]: *** [CMakeFiles/_PyIndiServer.dir/indiserverpythonPYTHON_wrap.c.o] Erreur 1
CMakeFiles/Makefile2:104 : la recette pour la cible « CMakeFiles/_PyIndiServer.dir/all » a échouée
make[1]: *** [CMakeFiles/_PyIndiServer.dir/all] Erreur 2
Makefile:127 : la recette pour la cible « all » a échouée
make: *** [all] Erreur 2

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

Last Edit: by patdut.

Take image with python script 2 years 3 months ago #8577

  • anat
  • anat's Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 50
  • Thank you received: 8
Use Revision 36 instead of the latest one which has Experimental libindiserver:
# install swig-indi-python
apt-get install swig2.0
cd /home/pi/INDI/
svn co -r 36 svn://svn.code.sf.net/p/pyindi-client/code/trunk/swig-indi/swig-indi-python/
mkdir libindipython
cd libindipython
cmake ../swig-indi-python
make
sudo make install
The following user(s) said Thank You: patdut

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

Take image with python script 2 years 3 months ago #8578

  • patdut
  • patdut's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • Posts: 311
  • Karma: 1
  • Thank you received: 37
Thank you Anat. I still have some misunderstanding. I am testing PyIndi with the following code:

import logging
import PyIndi
import cStringIO
import pyfits
import cv2
import time
from datetime import datetime
from threading import Thread

class IndiClient(PyIndi.BaseClient):

roi = None
device = None
run = True
gain = 15.0
exposure_time = 30.0

def __init__(self):
super(IndiClient, self).__init__()
self.logger = logging.getLogger('PyQtIndi.IndiClient')
self.logger.info('creating an instance of PyQtIndi.IndiClient')
def disconnectServer(self):
return PyIndi.BaseClient.disconnectServer(self)
self.run = False
def newDevice(self, d):
self.logger.info("new device " + d.getDeviceName())
self.device = d
def newProperty(self, p):
self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
if p.getName() == "CONNECTION":
self.connectDevice(self.device.getDeviceName())
if p.getName() == "CCD_EXPOSURE":
self.takeExposure()
if p.getName() == "CCD_GAIN":
gain = self.device.getNumber("CCD_GAIN")
gain[0].value = self.gain
self.sendNewNumber(gain)
def removeProperty(self, p):
self.logger.info("remove property "+ p.getName() + " for device "+ p.getDeviceName())
def newBLOB(self, bp):
self.logger.info("new BLOB ")
img = bp.getblobdata()
### process data in new Thread
Thread(target=self.process_image, args=(img,)).start()
if self.run:
self.takeExposure()
def newSwitch(self, svp):
self.logger.info ("new Switch "+ svp.name.decode() + " for device "+ svp.device.decode())
def newNumber(self, nvp):
self.logger.info("new Number "+ nvp.name.decode() + " for device "+ nvp.device.decode())
print nvp[0].value
def newText(self, tvp):
self.logger.info("new Text "+ tvp.name.decode() + " for device "+ tvp.device.decode())
def newLight(self, lvp):
self.logger.info("new Light "+ lvp.name.decode() + " for device "+ lvp.device.decode())
def newMessage(self, d, m):
#self.logger.info("new Message "+ m)
self.logger.info("New Message")
print "MESSAGE", m
def serverConnected(self):
self.logger.info("Server connected ("+self.getHost()+":"+str(self.getPort())+")")
def serverDisconnected(self, code):
self.logger.info("Server disconnected (exit code = "+str(code)+","+str(self.getHost())+":"+str(self.getPort())+")")
def takeExposure(self):
self.logger.info("<<<<<<<< Exposure >>>>>>>>>")
exp = self.device.getNumber("CCD_EXPOSURE")
exp[0].value = self.exposure_time
self.sendNewNumber(exp)
def process_image(self, imgdata):
blobfile=cStringIO.StringIO(imgdata)
hdulist=pyfits.open(blobfile)
scidata = hdulist[0].data
if self.roi is not None:
scidata = scidata[self.roi[1]:self.roi[1]+self.roi[3], self.roi[0]:self.roi[0]+self.roi[2]]
hdulist[0].data = scidata
hdulist.writeto("%s.fit" % datetime.now())
cv2.imwrite("%s.png" % datetime.now() , scidata)
cv2.imwrite("%s.jpg" % datetime.now() , scidata)

#logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)

#DEVICE = 'QHY CCD QHY5-0-M-'
DEVICE = 'CCD Simulator'

if __name__ == '__main__':
indiclient=IndiClient()
indiclient.roi = (270, 200, 700, 700) # region of interest for my allsky cam
indiclient.setServer("localhost",7624)
indiclient.watchDevice(DEVICE)
if (not(indiclient.connectServer())):
print("No indiserver running on "+indiclient.getHost()+":"+str(indiclient.getPort())+" - Try to run")
print(" indiserver indi_simulator_telescope indi_simulator_ccd")
sys.exit(1)
time.sleep(2)
indiclient.setBLOBMode(1, DEVICE, None)
while True:
pass
print("Disconnecting")
indiclient.disconnectServer()


And I get a weird message about telescope simulator and an unexpected end.
Furthermore I don't understand the concept of BLOB ???

Dispatch command error(-4): Device Telescope Simulator not found
<getProperties device="Telescope Simulator" name="EQUATORIAL_EOD_COORD"/>
Dispatch command error(-4):
<getProperties device="Telescope Simulator" name="TELESCOPE_INFO"/>
Dispatch command error(-4):
<getProperties device="CCD Simulator" name="FILTER_SLOT"/>
Dispatch command error(-4):
<getProperties device="CCD Simulator" name="FILTER_NAME"/>
Dispatch command error(-4):
<getProperties device="Telescope Simulator" name="EQUATORIAL_PE"/>
Dispatch command error(-4): Device Focuser Simulator not found
<getProperties device="Focuser Simulator" name="FWHM"/>
30.0
29.829000473
28.827999115
27.827999115
26.8260002136
25.8250007629
24.8239994049
23.8229999542
22.8220005035
21.8209991455
20.8209991455
19.8199996948
18.8190002441
17.8180007935
16.8169994354
15.8159999847
14.8149995804
13.8140001297
12.8129997253
11.8120002747
10.8109998703
9.81000041962
8.80900001526
7.80800008774
6.80700016022
5.8060002327
4.80499982834
3.8029999733
2.80200004578
1.80099999905
0.800000011921
0.0
terminate called after throwing an instance of 'Swig::DirectorMethodException'
what(): SWIG director method error. Error detected when calling 'BaseClient.newBLOB'
Abandon (core dumped)

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

Last Edit: by patdut.
Time to create page: 0.180 seconds

Login



3rd Party

Choose from the numerous 3rd party INDI drivers to suit your needs!

Got Problem?

Check out the FAQ, the forum, and the bug tracking system to resolve any issues you might have!
You can also subscribe to INDI newsletter and development mailing lists to get the latest updates on INDI!


Gallery

Replica

Why INDI

Replica