Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- from picamera import PiCamera
- from time import sleep
- import os
- import datetime
- from orbit import ISS
- location = ISS.coordinates() # Equivalent to ISS.at(timescale.now()).subpoint()
- dir_path = os.path.dirname(os.path.realpath(__file__))
- cam = PiCamera()
- cam.resolution = (640, 360) # max resolution
- def convert(angle):
- sign, degrees, minutes, seconds = angle.signed_dms()
- exif_angle = f'{degrees:.0f}/1,{minutes:.0f}/1,{seconds*10:.0f}/10'
- return sign < 0, exif_angle
- def capture(camera, image):
- point = ISS.coordinates()
- # Convert the latitude and longitude to EXIF-appropriate representations
- south, exif_latitude = convert(point.latitude)
- west, exif_longitude = convert(point.longitude)
- # Set the EXIF tags specifying the current location
- camera.exif_tags['GPS.GPSLatitude'] = exif_latitude
- camera.exif_tags['GPS.GPSLatitudeRef'] = "S" if south else "N"
- camera.exif_tags['GPS.GPSLongitude'] = exif_longitude
- camera.exif_tags['GPS.GPSLongitudeRef'] = "W" if west else "E"
- # Capture the image
- camera.capture(image)
- index = 0
- start_time = datetime.datetime.now()
- now_time = datetime.datetime.now()
- while (now_time < start_time + datetime.timedelta(minutes=178)):
- capture(cam, dir_path+"/img_{}.jpg".format(index))
- x = Image.open(dir_path+"/img_{}.jpg".format(index))
- x = x.convert('RGB')
- brightness = 0
- for X in range(640):
- for Y in range(360):
- pixelRGB = x.getpixel((X,Y))
- R,G,B = pixelRGB
- brightness += sum([R,G,B])/3
- if brightness /(640*360) >= 50 :
- index += 1
- now_time = datetime.datetime.now()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement