Advertisement
Anon2005

Astro3 cod

Feb 24th, 2022 (edited)
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PIL import Image
  2. from picamera import PiCamera
  3. from time import sleep
  4. import os
  5. import datetime
  6.  
  7. from orbit import ISS
  8. location = ISS.coordinates() # Equivalent to ISS.at(timescale.now()).subpoint()
  9.  
  10. dir_path = os.path.dirname(os.path.realpath(__file__))
  11.  
  12. cam = PiCamera()
  13. cam.resolution = (640, 360)  # max resolution
  14.  
  15. def convert(angle):
  16.  
  17.     sign, degrees, minutes, seconds = angle.signed_dms()
  18.     exif_angle = f'{degrees:.0f}/1,{minutes:.0f}/1,{seconds*10:.0f}/10'
  19.     return sign < 0, exif_angle
  20.  
  21. def capture(camera, image):
  22.     point = ISS.coordinates()
  23.  
  24.     # Convert the latitude and longitude to EXIF-appropriate representations
  25.     south, exif_latitude = convert(point.latitude)
  26.     west, exif_longitude = convert(point.longitude)
  27.  
  28.     # Set the EXIF tags specifying the current location
  29.     camera.exif_tags['GPS.GPSLatitude'] = exif_latitude
  30.     camera.exif_tags['GPS.GPSLatitudeRef'] = "S" if south else "N"
  31.     camera.exif_tags['GPS.GPSLongitude'] = exif_longitude
  32.     camera.exif_tags['GPS.GPSLongitudeRef'] = "W" if west else "E"
  33.  
  34.     # Capture the image
  35.     camera.capture(image)
  36.  
  37. index = 0
  38. start_time = datetime.datetime.now()
  39. now_time = datetime.datetime.now()
  40.  
  41. while (now_time < start_time + datetime.timedelta(minutes=178)):
  42.     capture(cam, dir_path+"/img_{}.jpg".format(index))
  43.     x = Image.open(dir_path+"/img_{}.jpg".format(index))
  44.     x = x.convert('RGB')
  45.     brightness = 0
  46.     for X in range(640):
  47.         for Y in range(360):
  48.             pixelRGB = x.getpixel((X,Y))
  49.             R,G,B = pixelRGB
  50.             brightness += sum([R,G,B])/3
  51.     if brightness /(640*360) >= 50 :
  52.         index += 1
  53.     now_time = datetime.datetime.now()
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement