Hello everyones,
I am trying to integrate a camera inside weatherradio like said this section:
github.com/indilib/indi-3rdparty/blob/ma...adme-WeatherRadio.md
I am using:
a Raspberry Zero with raspbian buster os
a Raspberry Camera OV5647
Raspistill is working because i capture images with this instruction:
raspistill -ISO 100 -ss 1000 -v -o /usr/share/weatherradio/html/media/current_weather.jpg
"raspistill" Camera App (commit bab9bf8790cd Tainted)
Camera Name ov5647
Width 2592, Height 1944, filename /usr/share/weatherradio/html/media/current_weather.jpg
Using camera 0, sensor mode 0
GPS output Disabled
Quality 85, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Time delay 5000, Timelapse 0
Link to latest frame enabled no
Full resolution preview No
Capture method : Single capture
Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 100, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Flicker Avoid Mode 'off'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
Camera component done
Encoder component done
Starting component connection stage
Connecting camera preview port to video render.
Connecting camera stills port to encoder input port
Opening output file /usr/share/weatherradio/html/media/current_weather.jpg
Enabling encoder output port
Starting capture -1
Finished capture -1
Closing down
Close down completed, all components disconnected, disabled and destroyed
My problem its with script camery.py that is in
/usr/share/weatherradio/bin the script said this:
#!/usr/bin/python3
#
# Script for shooting single images with automatic exposure adaption
# day and night..
#
# Copyright (C) 2020 Wolfgang Reissenberger <
This email address is being protected from spambots. You need JavaScript enabled to view it.>
#
# This application is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
#
import os, stat
from datetime import datetime
from pathlib import Path
from configparser import ConfigParser
from pid.decorator import pidfile
from pid import PidFileError
from autoexposure import *
def init_config(inifile_name):
config = ConfigParser(interpolation=None)
config.optionxform = str
# default values
config.add_section('Camera')
config.set('Camera', 'ExposureTime', '400') # 1/250 sec
config.set('Camera', 'BaseDirectory', ".")
config.set('Camera', 'ConverterFIFO', "/tmp/imageconverter.fifo")
config.set('Camera', 'ISOSpeedRatings', '50')
config.set('Camera', 'Contrast', '0')
config.set('Camera', 'Brightness', '50')
config.set('Camera', 'Saturation', '0')
config.set('Camera', 'Options', '-md 4 -ex fixedfps')
# night default settings
config.add_section('Night')
config.set('Night', 'Contrast', '100')
config.set('Night', 'Brightness', '20')
config.set('Night', 'Saturation', '-80')
config.set('Night', 'MaxExposure', '10000000')
config.set('Night', 'MaxISO', '800')
config.read(inifile_name)
return config
@pidfile()
def main():
inifile_name = os.path.dirname(os.path.realpath(__file__)) + '/camera.ini'
now = datetime.now()
config = init_config(inifile_name)
dir = config.get('Camera', 'BaseDirectory')
filename = now.strftime("%Y-%m-%d_%H%M%S") + ".jpg"
fullname = dir + '/' + filename
fifo = config.get('Camera', 'ConverterFIFO')
exptime = config.getint('Camera', 'ExposureTime')
iso = config.getint('Camera', 'ISOSpeedRatings')
brightness = config.getint('Camera', 'Brightness')
contrast = config.getint('Camera', 'Contrast')
saturation = config.getint('Camera', 'Saturation')
opts = config.get('Camera', 'Options')
# ensure that the image directory exists
if not Path(dir).exists():
Path(dir).mkdir(parents=True)
# change to auto exposure for short exposure times
expstr = "-ss %d" % (exptime) if exptime > 10000 else "-ex auto"
# shoot the image
os.system("raspistill %s -ISO %d -br %d -co %d -sa %d %s -o %s" % (opts, iso, brightness, contrast, saturation, expstr, fullname))
# calculate the optimal exposure time
(imgExpTime, imgBrightness) = calibrateExpTime(fullname, config)
# start converter process
if os.path.exists(fifo) and stat.S_ISFIFO(os.stat(fifo).st_mode):
with open(fifo, 'w') as pipeout:
pipeout.write("%s\n" % filename)
else:
targetdir = dir + '/' + now.strftime("%Y-%m-%d")
target = targetdir + '/' + filename
# ensure that the image directory exists
if not Path(targetdir).exists():
Path(targetdir).mkdir(parents=True)
# mv to target directory
os.rename(fullname, target)
configfile = open(inifile_name, 'w')
config.write(configfile)
configfile.close()
print("date=%s; time=%s; file=%s; ex=%d; iso=%d; br=%s; sat=%d; co=%d img brightness=%d" % (now.strftime("%Y-%m-%d"), now.strftime("%H:%M:%S"), filename, imgExpTime, iso, brightness, saturation, contrast, imgBrightness))
if __name__ == "__main__":
try:
main()
except PidFileError:
print ("Capture still running")
When i run this script i got an error:
javier@raspberrypi:/usr/share/weatherradio $ ./bin/camera.py
Traceback (most recent call last):
File "./bin/camera.py", line 101, in <module>
main()
File "/usr/local/lib/python3.7/dist-packages/pid/decorator.py", line 14, in decorator
return func(*func_args, **func_kwargs)
File "./bin/camera.py", line 78, in main
(imgExpTime, imgBrightness) = calibrateExpTime(fullname, config)
File "/usr/share/weatherradio/bin/autoexposure.py", line 107, in calibrateExpTime
realExpTime = 1000000 * exifexptime[0] / exifexptime[1]
TypeError: 'IFDRational' object is not subscriptable
Please, somebody can help me?