Python binding for ZWO ASI SDK now available
i would like to control my asi178mc with a raspberry pi 3 b+.
I have already wrote a program to test the raspberry with the picamera v2 and it works great, except the fact IMX219 is not a suitable sensor for astro. I used python language and common libraries like poencv, numpy, PIL, tkinter.
I have tried to install your python biding for asi sdk. The command pip install zwoasi seems to work fine.
When i try to run your zwoasi_demo.py program, it says "Import Error : no module named 'zwoasi'.
I can't find any solution.
I have also downloaded zwo SDK but i must say i don't know what to do with it.
I suppose you have understand i am complete newbie with linux and raspberry.
Could you explain me step by step :
- what i must do with zwo sdk
- how i can import zwoasi
What i would expect is to be able to import asi commands in python program as i import for example numpy in a python program and start to develop a software for the asi178mc.
Many thanks in advance for your lights !
Alain
maybe i have found some answers.
Concerning python binding :
i guess i must place zwoasi module in my working directory. In that case, when i run my program, python will look for __init__.py which is in zwoasi directory.
Is that correct ?
Concerning the SDK library, i should place the Armv7 files in a directory which is listed in Python path (for example /usr/lib/Python3).
Is that correct ?
In the python binding example (zwoasi_demo.py), there is a part concerning zwo library initialisation :
env_filename = os.getenv('ZWO_ASI_LIB')
parser = argparse.ArgumentParser(description='Process and save images from a camera')
parser.add_argument('filename',
nargs='?',
help='SDK library filename')
args = parser.parse_args()
# Initialize zwoasi with the name of the SDK library
if args.filename:
asi.init(args.filename)
elif env_filename:
asi.init(env_filename)
else:
print('The filename of the SDK library is required (or set ZWO_ASI_LIB environment variable with the filename)')
sys.exit(1)
Concerning this line : env_filename = os.getenv('ZWO_ASI_LIB')
I suppose it is used to point to the sdk library. I don't understand how a link can be created beteen ZWO_ASI_LIB and the library.
How can i make the link with the library file ?
Alain
ASI178MC works fine with raspberry pi 3 b+
Alain
I'm attempting to control my zwoasi 178MM with a raspberry pi 4 with no luck. I've downloaded both the zwoasi repo (both from Github and Pypi to see if one was bugged) as well as the required SDK, however when I attempt to execute the zwoasi_demo.py I receive 'The filename of the SDK library is required (or set ZWO_ASI_LIB environment variable with the filename)', so presumably it's not finding the library. I've attempted moving the demo script into the same directory as the libASICamera2.so (I'm assuming this is what it's looking for?), but all of my attempts have prompted the same output.
If anyone is able to provide a step by step method for executing the zwoasi_demo.py script that would be incredibly helpful! It's possible that I'm missing something completely obvious... Thanks in advance.
Can you post how you solved the whereabouts of zwo asi import? I am obviously more of newbie than you thought you were.
Bob
I guess ZWO could give you all the useful informations.
Alain
- Edited
I am new here. I try to get my camera working with python. But running asicap_main
.py, it does not find the zwoasi.py module. Where do I get it from? I don't find it on GitHub either.
amair Hi amair, can you send your email to me and we will send a demo to you. Thank you.
- Edited
Software@ZWO
Hi,
We have the ASI1600MM and the ASI6200MM and were looking for a Python SDK to test some still capture functions out from an existing Python program. Could you please provide us with the demo for the Python SDK?
ullasesper
Hi ullaseper,
This is a Demo of calling the SDK using Python. Hope that will help you.
https://github.com/AstroSoftDeveloper
Zzzz Thank you
For future reference:
The zwoasi-python
library is great. The part that confused me is that the ASICamera2.dll
library file to initiate it is located in ...\Program Files\ASIStudio\ASICamera2.dll
and not in the Program Files (x86)\ZWO Design\ZWO_USB_Cameras_driver\driver
folder.
Almost all examples are for Linux or Mac.
On my Windows computer, this works:
import zwoasi as asi
import os
asi.init(r"C:\Program Files\ASIStudio\ASICamera2.dll")
num_cameras = asi.get_num_cameras()
I am not able to trigger the camera as I would expect. I am using an Arduino Nano board to send a trigger signal (5V) to my ZWO ASI6200MM Pro.
Obtaining images in camera mode 0 is not problem.
The camera does not trigger. I can't even get it to trigger when sending a soft trigger:
This does not work with a (verified) 5V trigger from the Arduino.
filename = "image_mono16_triggered.tiff"
print("Ready for triggered image")
camera.set_image_type(asi.ASI_IMG_RAW16)
camera.set_camera_mode(asi.ASI_MODE_TRIG_SOFT_LEVEL)
camera.capture(filename=filename)
print("Triggered image acquisition")
and even this does not result in an image:
filename = "image_mono16_triggered.tiff"
print("Ready for triggered image")
camera.set_image_type(asi.ASI_IMG_RAW16)
camera.set_camera_mode(asi.ASI_MODE_TRIG_SOFT_LEVEL)
camera.send_soft_trigger(1)
camera.capture(filename=filename)
print("Triggered image acquisition")
janalexand If your camera is not a trigger camera, please do not use this method to obtain images.
If you use Python to get images from a regular USB camera, please refer to https://github.com/AstroSoftDeveloper.
Looking forward to your reply!
Zzzz Thank you for your reply. I can confirm that the used camera sensor (ZWO ASI6200MM Pro) is a trigger camera.
The output from theget_camera_property
function confirms this.
My problem is not yet solved. Sending a 5V trigger does not trigger the camera. The trigger is confirmed with 2 different oscilloscopes.
@janalexand You can refer to this documentation to check that the camera is being used correctly.
Looking forward to your reply!