impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 1, 2019 4:06:25 GMT -8
I was planning on stopping my images at night time being uploaded... which did not work out well - as Stemweather just blanks to a white screen which did not look pretty. The reason I thought of doing this was - boring black images and therefore wasting bandwidth.
Now I took that thought further - as I was developing my next mod...
What if night time images took longer exposures - maybe 1 sec or 3 sec or 5 sec... Not long enough for star trails to show - but long enough to get some definitions... It might show some stars, but it might capture clouds to see patterns and if its cloudy or clear night... Its got to be better than just black...
Has anyone thought of doing this before I start experimenting...
|
|
|
Post by SDL on Sept 1, 2019 12:44:29 GMT -8
|
|
|
Post by topher2880 on Sept 2, 2019 3:28:17 GMT -8
This is a great idea, it would use more power (unfortunately) but could work for meteorites, or planes flying through the field of view. Id definitely be interested in being able to do that.
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 2, 2019 4:07:28 GMT -8
I had to wait until night time to give it a try... and lets just say I am impressed with this little camera on the PI.... For those that have followed my other mods - I use Astral to determine sunrise, sunset, dawn, dusk.... As I take a separate picture for my twitter feed to show the previous days sunset. The code below might need to be modified for your circumstance - but it gives you the idea of what to do... I check to see if its night time, and then my camera exposures are 6 seconds.... I found it does not work unless you set both framerate and shutter speed... that took ages to debug ! All the examples use Fraction that I found so I also had to do an import on this utility.... And I also found leave it wait for 30 seconds to get the light balance right - but that seemed too long - so I only did a sleep for 10 seconds.... Help yourself to my changes to SkyCamera.py; import requests import time import picamera import state
import hashlib
from PIL import ImageFont, ImageDraw, Image import traceback import util import datetime as dt import astral # Need to install this via sudo pip install astral import pytz from fractions import Fraction
# Check for user imports try: import conflocal as config except ImportError: import config
def SkyWeatherKeyGeneration(userKey):
catkey = "AZWqNqDMhvK8Lhbb2jtk1bucj0s2lqZ6" +userKey
md5result = hashlib.md5(catkey) #print ("hashkey =", md5result.hexdigest()) return md5result.hexdigest()
def takeSkyPicture():
sun_altos = astral.Location(info=("Melbourne", "AUS", -37.180594, 144.324194, "Australia/Victoria", config.BMP280_Altitude_Meters/3.2808399)) sun_altos.solar_depression = "civil"
result = sun_altos.sun(date=dt.date.today())
sunsettime = result['sunset'] sunsettimeplus10 = sunsettime + dt.timedelta(minutes=10) sunsettimeless1h = sunsettime + dt.timedelta(hours=-1) tz = pytz.timezone('Australia/Sydney') currtime = dt.datetime.now(tz) print "Sunset: " , sunsettime print "Sunset + 10 mins: " , sunsettimeplus10 print "Sunset - 1hr: " , sunsettimeless1h print "Current Time: " , currtime
if (config.SWDEBUG): print ("--------------------") print ("SkyCam Picture Taken") print ("--------------------") camera = picamera.PiCamera()
if dt.datetime.now().time() > result['dawn'].time() and dt.datetime.now().time() < result['dusk'].time(): #Daytime camera.exposure_mode = "auto" else: #Nighttime print "Night time exposure" # Set a framerate of 1/6fps, then set shutter # speed to 6s and ISO to 800 camera.framerate = Fraction(1, 6) camera.shutter_speed = 6000000 camera.iso = 800 # Give the camera a good long time to set gains and # measure AWB (you may wish to use fixed AWB instead) time.sleep(10) camera.exposure_mode = 'off' # Finally, capture an image with a 6s exposure. Due # to mode switching on the still port, this will take # longer than 6 seconds
try: camera.rotation = 180 #camera.rotation = 270 camera.resolution = (1920, 1080) # Camera warm-up time time.sleep(2)
camera.capture('static/skycamera.jpg') camera.capture('static/skycamera-raw.jpg')
etc etc etc
Now I just need to wait for the morning to see if the daylight pictures revert back to normal.... What really impressed me on this 6 second exposure was not what I was expecting... Its storm here tonight - expecting rain - huge cloud cover... Standing outside I cannot see the sky at all - clouds everywhere... But from the first picture I took - I could see stars through the clouds... Lots of stars. I am only a couple of miles from the CBD of Melbourne - several million people live here - and huge light pollution... Yet the detail of the stars through the clouds - WOW - What a great little camera the PI has.... I am still experimenting in my backyard, and can not wait to take this to the farm where there is no light pollution, and can clearly see the milky way by eye sight alone.... Im expecting some great pics now!!! Might have to change the parameters down a little once I have it on site! If you want to see an example - if you look at the right time (my night) - here you go... cdn.weatherstem.com/user_generated/skyweather/malmsbury/snapshot.jpgEnjoy
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 2, 2019 4:37:51 GMT -8
Damn... Still happy but closer examination - most are artifacts… not stars... but there is still a couple there!
Come on clear night - so I can fiddle some more!
|
|
|
Post by topher2880 on Sept 2, 2019 18:49:44 GMT -8
Hi mate, I had a bit of your code already, so added this lot. I WAS going to add the 2nd Pi and cam to the system after sourcing another lipo, but now I will simply see what I can get tonight with this Maybe I will angle higher into the sky to crop off most of the neighbours and exposure from street lighting.. Fantastic work!! Excited for sunset today to see what happens
|
|
|
Post by jrwilling on Sept 3, 2019 7:50:05 GMT -8
Some fine stuff there!
I'm folding this code into my unit as well, was really hoping for some insights on better imaging in the evenings so am really excited by this.
Thanks!
|
|
|
Post by topher2880 on Sept 3, 2019 14:27:13 GMT -8
How is it working for you? I was having some big issues last night, managed to get it to take one snapshot after dusk last night, but morning is very stable for me. What is your STEM address so we can have a look?
|
|
|
Post by SDL on Sept 3, 2019 16:49:40 GMT -8
Yes, definitely!
BP
|
|
|
Post by jrwilling on Sept 3, 2019 18:38:17 GMT -8
How is it working for you? I was having some big issues last night, managed to get it to take one snapshot after dusk last night, but morning is very stable for me. I appear to have run into the same issue. It took one image after dusk and then the camera appeared to hang and no further pictures were taken until the unit was rebooted.
Noted some entries in the "nohup.out" file indicating that the scheduler could not launch the "takeSkyPicture" process since the maximum number of instances (1) already existed.
Sounds like the take picture process is hanging once it shifts to "night" mode?
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 3, 2019 21:46:51 GMT -8
Yes I noticed this yesterday - it worked all good the first couple of nights, then last night it died - just as you said... and your spot on about how the task scheduler has got confused... Trying to understand why it worked for me on the first couple of nights and then it stopped, and it broke for you guys on the first night...
Wondering when I copied and pasted the code here that I introduced something strange - anyway... partly resolved last night, working on it now, and hope to have it fixed for tonight... standby
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 3, 2019 22:50:41 GMT -8
I believe I fixed it...
change the code
finally: try: camera.exposure_mode = "auto" time.sleep(1) camera.close()
except: if (config.SWDEBUG): print ("--------------------") print ("SkyCam Close Failed ") print ("--------------------")
Just before the import base64
I was able to determine it was 'hanging' on the close camera statement... and I mean hanging - if you were running it in a terminal - you could not even control-c out of it, nor could you start another terminal and do a reboot!!!
For whatever reason - it was hangning and it would not get trapped as an error - and everything just stalls...
I googled everywhere and could not find anyone else with a similar issue. So I just thought I would try... - It only occurs when it is doing a long exposure (the sunset shots are done prior to this as normal, then it changes the paramaters to do a long expsosure, and hangs on the close only if it was set as a long exposure). - So I thought I would reset the camera back to normal, give it a second to make up its mind, and then close... It now works.
SO I will continue to monitor it - and if there is indeed further problems - I will get it fixed quickly, as I want to be using this myself!
(Sorry guys - its only software.... LOL)
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Sept 4, 2019 3:03:01 GMT -8
I believe I now fixed it - change to this bit of code
else: #Nighttime print "Night time exposure" # Set a framerate of 1/6fps, then set shutter # speed to 6s and ISO to 800 camera.exposure_mode = "night" camera.framerate = 1 camera.shutter_speed = 600000 camera.iso = 800 # Give the camera a good long time to set gains and # measure AWB (you may wish to use fixed AWB instead) time.sleep(2) # Finally, capture an image with a 6s exposure. Due # to mode switching on the still port, this will take # longer than 6 seconds
As previously mentioned - for whatever reason changes to shutter speed do not work unless you change the framerate. The Framerate was causing issues - changing this to a value of 1 frame per second seems to have it all working again!
Shall try to improve the image and get it all working a little better - and I shall clean up the code - but at least this gets you working again !
|
|
|
Post by jrwilling on Sept 4, 2019 5:40:39 GMT -8
Your efforts are greatly appreciated! I've rolled your code changes into my unit and will see what happens.
It all seems to make sense, so fingers crossed!
|
|
|
Post by topher2880 on Sept 4, 2019 6:10:27 GMT -8
Thats awesome... and.. as you say.. its only software. Some of my issue, however, was not. When I switched out the camera, I forgot to take note that when THIS one takes photos, there is a little red LED that goes on. Some very technical, and careful engineering solved the issue. With Blu Tack. Images are a little dark, but I have Jupiter (I think) in the frame quite nicely. Lengthened to 60s and no real change. So will tinker in the light tomorrow and see where Im actually pointed and wait til tomorrow night to see what comes out Thanks so much for your efforts, and also allowing us to use it
|
|