Hmmm... what is strange is that this cam is working when used with Ekos... even is qhy_ccd_test fails.

I will cont. test this setup.



Read More...

Hi,

1st - again congrats on this project!

this is strange - I build right now both core, libs and 3rd party drivers from github.

All successful. Mounts, etc - all working but not the driver for the qhy cams. I'm using a qhy 5 iii 178c- When I run qhy_ccd_test, I got the following


qhy_ccd_test
QHY Test CCD using SingleFrameMode, Version: 1.00
-- qhyccd.cpp param
QHYCCD|QHYCCD.CPP|InitQHYCCDResource()|START
QHYCCD|QHYCCD.CPP|InitQHYCCDResource|auto_detect_camera:false,call InitQHYCCDResourceInside
QHYCCD|QHYCCD.CPP|InitQHYCCDResourceInside|START
QHYCCD|QHYCCD.CPP|libusb_version 1.0.23.11397
QHYCCD|QHYCCD.CPP|libusb_init(libqhyccd_context) called...
QHYCCD|QHYCCD.CPP|InitQHYCCDResourceInside|numdev set to 0
QHYCCD|QHYCCD.CPP|InitQHYCCDResourceInside|END
************************** config file path 22.5.11.7 svn: 12117 ************************************
QHYCCD|QHYCCD.CPP|InitQHYCCDResource|Load ini filePath = /home/fritz fileName = qhyccd.ini
SDK resources initialized.
Number of QHYCCD cameras found: 1
Application connected to the following camera from the list: Index: 1, cameraID = QHY5III178C-1524fa4faea64cc25
Open QHYCCD success.
SetQHYCCDStreamMode set to: 0, success.
InitQHYCCD success.
GetQHYCCDOverScanArea:
Overscan Area startX x startY : 0 x 0
Overscan Area sizeX x sizeY : 0 x 0
GetQHYCCDEffectiveArea:
Effective Area startX x startY: 0 x 0
Effective Area sizeX x sizeY : 0 x 0
GetQHYCCDChipInfo:
Effective Area startX x startY: 0 x 0
Chip size width x height : 9.993 x 8.431 [mm]
Pixel size width x height : 2.400 x 2.400 [um]
Image size width x height : 3056 x 2048
This is a color camera.
SetQHYCCDParam CONTROL_USBTRAFFIC set to: 10, success.
SetQHYCCDParam CONTROL_GAIN set to: 10, success
SetQHYCCDParam CONTROL_GAIN set to: 140, success.
Default read mode: 0
Default read mode name STANDARD MODE
Read mode name STANDARD MODE
GetQHYCCDChipInfo in this ReadMode: imageW: 3056 imageH: 2048
SetQHYCCDParam CONTROL_EXPOSURE set to: 1, success.
SetQHYCCDResolution roiStartX x roiStartY: 0 x 0
SetQHYCCDResolution roiSizeX x roiSizeY : 3056 x 2048
SetQHYCCDBinMode set to: binX: 1, binY: 1, success.
SetQHYCCDParam CONTROL_GAIN set to: 10, success.
ExpQHYCCDSingleFrame(pCamHandle) - start...
ExpQHYCCDSingleFrame(pCamHandle) - end...
ExpQHYCCDSingleFrame success (8193).
Allocated memory for frame: 27116352 [uchar].
Segmentation fault

I have seen that in some other - older - posts - any hint?

uname -a
Linux nanopim1astro1 5.15.25-sunxi #22.02.1 SMP Sun Feb 27 09:23:25 UTC 2022 armv7l armv7l armv7l GNU/Linux

lscpu
Architecture: armv7l
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
Model: 5
Model name: Cortex-A7
Stepping: r0p5
CPU max MHz: 1368.0000
CPU min MHz: 480.0000
BogoMIPS: 22.85
Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm


Thanks!
Joerg

Read More...

A 1st version of the capture.py is locatde here:

Read More...

Python script gets the fits file from indilibserver, tze cam model (in my case a QGYIII178C, is hard codded for now). you can set a few parameters:

capture.py -b binding -g gain -e exposure -f filename

#########################################
#!/usr/bin/python3

import PyIndi
import time
import sys
import getopt
import threading
import io
import numpy as np
from PIL import Image
from astropy.io import fits



class IndiClient(PyIndi.BaseClient):
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
pass
def newProperty(self, p):
pass
def removeProperty(self, p):
pass
def newBLOB(self, bp):
global blobEvent
print("new BLOB ", bp.name)
blobEvent.set()
pass
def newSwitch(self, svp):
pass
def newNumber(self, nvp):
pass
def newText(self, tvp):
pass
def newLight(self, lvp):
pass
def newMessage(self, d, m):
pass
def serverConnected(self):
pass
def serverDisconnected(self, code):
pass

def main(argv):
global blobEvent
try:
opts, args = getopt.getopt(argv,"hb:g:e:f:")
except getopt.GetoptError:
print ('capture.py -b binding -g gain -e exposure -f filename')
sys.exit(2)

if len(opts) == 0:
print ('capture.py -b binding -g gain -e exposure -f filename')
sys.exit(2)

for opt, arg in opts:
if opt == '-h':
print ('capture.py -b binding -g gain -e exposure -f filename')
sys.exit()
elif opt in ("-b"):
binding = arg
elif opt in ("-g"):
gain = arg
elif opt in ("-e"):
exposure = arg
elif opt in ("-f"):
filename = arg

print ('binding is ', binding)
print ('gain is ', gain)
print ('exposure is ', exposure)
print ('filename is ', filename)

# connect the server
indiclient=IndiClient()
indiclient.setServer("localhost",7624)

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)

# Let's take some pictures
ccd="QHY CCD QHY5III178C-62f"
device_ccd=indiclient.getDevice(ccd)
while not(device_ccd):
time.sleep(0.5)
device_ccd=indiclient.getDevice(ccd)

ccd_connect=device_ccd.getSwitch("CONNECTION")
while not(ccd_connect):
time.sleep(0.5)
ccd_connect=device_ccd.getSwitch("CONNECTION")
if not(device_ccd.isConnected()):
ccd_connect[0].s=PyIndi.ISS_ON # the "CONNECT" switch
ccd_connect[1].s=PyIndi.ISS_OFF # the "DISCONNECT" switch
indiclient.sendNewSwitch(ccd_connect)

ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
while not(ccd_exposure):
time.sleep(0.5)
ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")

ccd_gain=device_ccd.getNumber("CCD_GAIN")
while not(ccd_gain):
time.sleep(0.5)
ccd_gain=device_ccd.getNumber("CCD_GAIN")

#ccd_temperature=device_ccd.getNumber("CCD_TEMPERATURE")
#while not(ccd_temperature):
# time.sleep(0.5)
# ccd_temperature=device_ccd.getNumber("CCD_TEMPERATURE")

ccd_binding=device_ccd.getNumber("CCD_BINNING")
while not(ccd_binding):
time.sleep(0.5)
ccd_binding=device_ccd.getNumber("CCD_BINNING")

print("Current Values:")
print("Exposure: ", ccd_exposure[0].value)
print("Gain: ", ccd_gain[0].value)
#print("Temperature: ", ccd_temperature[0].value)
print("Binding: ", ccd_binding[0].value)


# Ensure the CCD simulator snoops the telescope simulator
# otherwise you may not have a picture of vega
ccd_active_devices=device_ccd.getText("ACTIVE_DEVICES")
while not(ccd_active_devices):
time.sleep(0.5)
ccd_active_devices=device_ccd.getText("ACTIVE_DEVICES")
ccd_active_devices[0].text="Telescope Simulator"
indiclient.sendNewText(ccd_active_devices)

# we should inform the indi server that we want to receive the
# "CCD1" blob from this device
indiclient.setBLOBMode(PyIndi.B_ALSO, ccd, "CCD1")

ccd_ccd1=device_ccd.getBLOB("CCD1")
while not(ccd_ccd1):
time.sleep(0.5)
ccd_ccd1=device_ccd.getBLOB("CCD1")

# a list of our exposure times
#exposure = 10
#gain = 0
#binding = 2

# we use here the threading.Event facility of Python
# we define an event for newBlob event
blobEvent=threading.Event()
blobEvent.clear()

ccd_exposure[0].value=float(exposure)
indiclient.sendNewNumber(ccd_exposure)

ccd_gain[0].value=float(gain)
indiclient.sendNewNumber(ccd_gain)

ccd_binding[0].value=float(binding)
indiclient.sendNewNumber(ccd_binding)

ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
while not(ccd_exposure):
time.sleep(0.5)
ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")

ccd_gain=device_ccd.getNumber("CCD_GAIN")
while not(ccd_gain):
time.sleep(0.5)
ccd_gain=device_ccd.getNumber("CCD_GAIN")

#ccd_temperature=device_ccd.getNumber("CCD_TEMPERATURE")
#while not(ccd_temperature):
# time.sleep(0.5)
# ccd_temperature=device_ccd.getNumber("CCD_TEMPERATURE")

ccd_binding=device_ccd.getNumber("CCD_BINNING")
while not(ccd_binding):
time.sleep(0.5)
ccd_binding=device_ccd.getNumber("CCD_BINNING")

print("Set values to:")
print("Exposure: ", ccd_exposure[0].value)
print("Gain: ", ccd_gain[0].value)
#print("Temperature: ", ccd_temperature[0].value)
print("Binding: ", ccd_binding[0].value)

blobEvent.wait()
for blob in ccd_ccd1:
print("name: ", blob.name," size: ", blob.size," format: ", blob.format)
# pyindi-client adds a getblobdata() method to IBLOB item
# for accessing the contents of the blob, which is a bytearray in Python
fits=blob.getblobdata()
# print("fits data type: ", type(fits))

# write image data to StringIO buffer
blobfile = io.BytesIO(fits)
# open a file and save buffer to disk
with open(filename, "wb") as f:
f.write(blobfile.getvalue())


if __name__ == "__main__":
main(sys.argv[1:])

########################


For the fits -> png conversion I use this script below - still work in progress, i generate lots of files to find the best one. Seems that the little auto stretching, white balancing function does its job. Its looks very similar as the KStars Fits debayering / preview or as in ZWOs ASIFitsView.
Best one seems to be the combination of Menon2007 debayering and white balancing - capture_image_int8_Menon2007_wb.png.

########################

import os
import cv2
import numpy as np
import astropy.io.fits as pyfits

from colour_demosaicing import (
EXAMPLES_RESOURCES_DIRECTORY,
demosaicing_CFA_Bayer_bilinear,
demosaicing_CFA_Bayer_Malvar2004,
demosaicing_CFA_Bayer_Menon2007,
mosaicing_CFA_Bayer)

def white_balance(img):
stack = []
for i in cv2.split(img):
hist, bins = np.histogram(i, 256, (0, 256))
# remove colors at each end of the histogram which are used by only by .05%
tmp = np.where(hist > hist.sum() * 0.0005)[0]
i_min = tmp.min()
i_max = tmp.max()
# stretch history a bit
tmp = (i.astype(np.int32) - i_min) / (i_max - i_min) * 255
tmp = np.clip(tmp, 0, 255)
stack.append(tmp.astype(np.uint8))
return np.dstack(stack)

hdul = pyfits.open('/home/fritz/python/test.fits')
print (hdul.info)
image_uint16=hdul[0].data
print("Raw fits file:")
print(image_uint16)
print("######################################################")

image_int8 = cv2.normalize(image_uint16, None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U)

print("Normalized data:")
print(image_int8)
print("######################################################")


image_int8_eq = cv2.equalizeHist(image_int8)

print("EqualizeHist data:")
print(image_int8_eq)
print("######################################################")


balanced_img = np.zeros_like(image_int8) #Initialize final image

image_rgb1 = cv2.cvtColor(image_uint16, cv2.COLOR_BayerGB2RGB)
image_rgb2 = cv2.cvtColor(image_int8, cv2.COLOR_BayerGB2RGB)
image_rgb3 = cv2.cvtColor(image_int8_eq, cv2.COLOR_BayerGB2RGB)
debayerImage1 = demosaicing_CFA_Bayer_Malvar2004(image_int8, pattern='GRBG')
debayerImage2 = demosaicing_CFA_Bayer_bilinear(image_int8)
debayerImage3 = demosaicing_CFA_Bayer_Menon2007(image_int8, pattern='GRBG', refining_step=True)

print("RGB image_uint16 data:")
print(image_rgb1)
print("######################################################")

print("RGB image_int8 data:")
print(image_rgb2)
print("######################################################")

print("RGB image_int8_eq data:")
print(image_rgb3)
print("######################################################")

cv2.imwrite('/home/fritz/python/capture_image_uint16.png', image_rgb1)
cv2.imwrite('/home/fritz/python/capture_image_int8.png', image_rgb2)
cv2.imwrite('/home/fritz/python/capture_image_int8_eq.png', image_rgb3)
cv2.imwrite('/home/fritz/python/capture_image_int8_Malvar2004.png', debayerImage1)
cv2.imwrite('/home/fritz/python/capture_image_int8_bilinear.png', debayerImage2)
cv2.imwrite('/home/fritz/python/capture_image_int8_Menon2007.png', debayerImage3)
cv2.imwrite('/home/fritz/python/capture_image_int8_wb.png', white_balance(image_rgb2))
cv2.imwrite('/home/fritz/python/capture_image_int8_Malvar2004_wb.png', white_balance(debayerImage1))
cv2.imwrite('/home/fritz/python/capture_image_int8_Menon2007_wb.png', white_balance(debayerImage3))

########################

Read More...

Thanks for all the feedback. I think I have made good progress - I will share current status tomorrow.

Looks promising...

Read More...

Yes... seems not that easy. The KStars FITS Viewer gives best results so far. Any way that there is a command line version of that?

Read More...

Maybe somebody have a nice way to debayering those fits coming from indilib one color short cams. I have tested a few - so far I have not found something that would produce good results.

Any idea?

Read More...

Joerg Koenig replied to the topic 'Saved fits not debayred' in the forum. 4 years ago

Thanks! I was looking for something like that...

Read More...

Hi,

maybe a few how this fantastic project from Thomas about his allsky cam.

github.com/thomasjacquin/allsky

Sadly it linked to Zwo cams only, so I'm thinking about replacing his capture.cpp file with some python script that does same but using indilib.

As most of the other - not hardware related scripts - use png or jpg files, I'm wondering how to convert fits into jpg or png files.

I tried something like that, using a color cam from QHY, so there is only one HDU object in.

##########################

#!/usr/bin/python3

import sys
import getopt
import PyIndi
import time
import sys
import threading
import io
import numpy as np
from PIL import Image
from astropy.io import fits


def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:")
except getopt.GetoptError:
print ('fitsTojpg.py -i <inputfile> -o <outputfile>')
sys.exit(2)

for opt, arg in opts:
if opt == '-h':
print ('fitsTojpg.py -i <inputfile> -o <outputfile>')
sys.exit()
elif opt in ("-i"):
inputfile = arg
elif opt in ("-o"):
outputfile = arg

print ('Input file is "', inputfile)
print ('Output file is "', outputfile)

image_data = fits.open(inputfile)
print (image_data.info())
dataImage = image_data[0].data
im = Image.fromarray(dataImage)
if im.mode != 'RGB':
im = im.convert('RGB')
im.save(outputfile)
im.close()


if __name__ == "__main__":
main(sys.argv[1:])

##########################

But the quality is not good:

pic1.fits (within pic1.zip): original

File Attachment:

File Name: pic1.zip
File Size: 8,224 KB
one, got by another python script via BLOB.
pic1_astconvertt.jpg: better but still no color (done by astconvertt, part of GNU Astronomy Utilities)
pic1_myscript.jpg: done by the script above

Read More...

Joerg Koenig replied to the topic 'Seems the repo is broken?' in the forum. 4 years ago

Right... my mistake.

Read More...

Joerg Koenig replied to the topic 'Seems the repo is broken?' in the forum. 4 years ago

sudo apt-get install indi-full gsc
...
E: Unable to locate package gsc

sudo apt-get install indi-full

...

The following packages have unmet dependencies:
indi-full : Depends: libindi1 (>= 1.8) but it is not going to be installed
Depends: indi-bin (>= 1.8) but it is not going to be installed
Depends: indi-eqmod but it is not going to be installed
Depends: indi-sx but it is not going to be installed
Depends: indi-sbig but it is not going to be installed
Depends: indi-apogee but it is not going to be installed
Depends: indi-gphoto but it is not going to be installed
Depends: indi-qsi but it is not going to be installed
Depends: indi-fishcamp but it is not going to be installed
Depends: indi-maxdomeii but it is not going to be installed
Depends: indi-asi but it is not going to be installed
Depends: indi-aagcloudwatcher but it is not going to be installed
Depends: indi-aagcloudwatcher-ng but it is not going to be installed
Depends: indi-ffmv but it is not going to be installed
Depends: indi-dsi but it is not going to be installed
Depends: indi-qhy but it is not going to be installed
Depends: indi-gpsd but it is not going to be installed
Depends: indi-mi but it is not going to be installed
Depends: indi-duino but it is not going to be installed
Depends: indi-fli but it is not going to be installed
Depends: indi-nexstarevo but it is not going to be installed
Depends: indi-nexdome but it is not going to be installed
Depends: indi-gpsnmea but it is not going to be installed
Depends: indi-armadillo-platypus but it is not going to be installed
Depends: indi-mgen but it is not going to be installed
Depends: indi-shelyak but it is not going to be installed
Depends: indi-nightscape but it is not going to be installed
Depends: indi-toupbase but it is not going to be installed
Depends: indi-atik but it is not going to be installed
Depends: indi-avalon but it is not going to be installed
Depends: indi-starbook but it is not going to be installed
Depends: indi-astromechfoc but it is not going to be installed
Depends: indi-dreamfocuser but it is not going to be installed
Depends: indi-aok but it is not going to be installed
Depends: indi-talon6 but it is not going to be installed
Depends: indi-pentax but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Read More...

Joerg Koenig replied to the topic 'Seems the repo is broken?' in the forum. 4 years ago

uname -a
Linux allsky 5.7.15-sunxi #20.08 SMP Sun Aug 16 23:54:33 CEST 2020 armv7l GNU/Linux

Running Armbian on Orange PI one.

Read More...

Joerg Koenig created a new topic ' Seems the repo is broken?' in the forum. 4 years ago

HI,

just want to install indi as decribed here:

indilib.org/get-indi/download-ubuntu.html

Seems the repo is broken: 1st, no OpenPGP data, it seems to be lost. Also when I try:

sudo apt-get install indi-full gsc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gsc
fritz@allsky:/etc/raspap$

It affec ts both main and nighly repo...

Just to let you know...

Regards
Joerg

Read More...

Joerg Koenig replied to the topic 'ASI120MM is dead' in the forum. 5 years ago

Hi Oleg,

one question you may can help me with.

I also have issues with my ASI120mm - seems eeprom is bad, I can flash but fiormware gets lost each time I unplug. Plan is to use with a raspberry pi, I would not mind to flash it with a script, but seems those linux flashing tools are gone from zwo website.


Any change you can provide this zwo_FWTool_USB2 tool?

Thanks
Joerg

Read More...