def __init__(self, debug=False, simulate_file=None, use_leds=True):
        exclogger.init()
        self.simulate = False
        self.cam = astro_sensor.AstroCam(simulate=simulate_file)
        self.cam.init(gain_db=-1, shutter_us=250000)
        self.time_mgr = time_location.TimeLocationManager()
        self.has_time = False

        self.debug = debug
        self.use_leds = use_leds
        self.sleeping = False
        self.cam_err = False

        t = pyb.millis()
        self.diag_cnt = 0
        self.frm_cnt = 0
        self.tick_all = t
        self.dur_all = -1
        self.snap_millis = 0

        self.settings = {}
        self.settings.update({"time": self.time_mgr.get_sec()})
        self.settings.update({"center_x": self.cam.width / 2})
        self.settings.update({"center_y": self.cam.height / 2})
        self.settings.update({"gain": self.cam.gain})
        self.settings.update({"shutter": self.cam.shutter})
        self.settings.update({"thresh": (0)})
        self.settings.update({"max_stars": 0})
        self.settings.update({"force_solve": False})
        self.load_settings()
        self.time_mgr.readiness = False
        exclogger.log_exception("Time Guessed (%u)" % pyb.millis(),
                                time_str=time_location.fmt_time(
                                    self.time_mgr.get_time()))

        self.portal = captive_portal.CaptivePortal(debug=self.debug)

        self.img = None
        self.img_compressed = None
        self.extra_fb = None
        self.expo_code = 0
        self.histogram = None
        self.img_stats = None
        self.stars = []
        self.hot_pixels = []
        self.max_stars = 0
        self.packjpeg = False
        self.zoom = 1
        self.prevzoom = 1
        self.mem_errs = 0
        self.accel_sec = 0
        if self.portal is not None:
            self.register_http_handlers()
        while self.cam.check_init() == False:
            self.cam.check_init()
        self.cam.snapshot_start()
        self.snap_millis = pyb.millis()

        self.stream_sock = None
        self.stream_sock_err = 0
def test():
    print("hello")
    cam = astro_sensor.AstroCam(simulate="simulate.bmp")
    print("loaded image")

    img = cam.snapshot()

    stars, code = star_finder.find_stars(img, thresh=0, force_solve=True)

    print("found %u stars" % len(stars))

    i = 0
    while i < len(stars):
        s = stars[i]
        print("[%u]: [%.1f, %.1f, %.1f, %.1f]" %
              (i, s.cx, s.cx, s.r, s.brightness))
        i += 1

    solution = pole_finder.PoleSolution(stars, search_limit=1, debug=True)

    if solution.solve():
        print("solved, %u matches" % len(solution.stars_matched))
    else:
        print("failed")

    print("bye")
import micropython
import pyb
import math
import star_finder, astro_sensor, guidestar

cam = astro_sensor.AstroCam()
#cam = astro_sensor.AstroCam(simulate = "polaris.bmp")

print("cam init...", end="")
cam.init(gain_db=32, shutter_us=1500 * 1000)

while cam.check_init() == False:
    print(".", end="")
print(" done")

print("capturing...")
img = cam.snapshot()
print("done")
hist = img.get_histogram()
stats = hist.get_statistics()

stars, code = star_finder.find_stars(img,
                                     hist=hist,
                                     stats=stats,
                                     thresh=(16 * 3),
                                     guider=True)

print("stars: %u , mean: %u" % (len(stars), stats.mean()))

guidestar.process_list(stars, 100, [], 2)
sel_star = guidestar.select_first(stars)
Exemplo n.º 4
0
    def __init__(self, debug = False, simulate_file = None, use_leds = True):
        exclogger.init()
        self.highspeed = False
        self.daymode = False
        self.simulate = False
        self.cam = astro_sensor.AstroCam(simulate = simulate_file)
        self.cam.init(gain_db = 32, shutter_us = 1000000)
        self.time_mgr = time_location.TimeLocationManager()
        self.has_time = False

        self.debug = debug
        self.use_leds = use_leds
        self.sleeping = False
        self.cam_err = False

        t = pyb.millis()
        self.diag_cnt    = 0
        self.frm_cnt     = 0
        self.tick_all    = t
        self.dur_all     = -1
        self.solu_dur    = -1
        self.snap_millis = 0

        self.settings = {}
        self.settings.update({"longitude":   self.time_mgr.longitude})
        self.settings.update({"latitude":    self.time_mgr.latitude})
        self.settings.update({"time":        self.time_mgr.get_sec()})
        self.settings.update({"center_x":    self.cam.width / 2})
        self.settings.update({"center_y":    self.cam.height / 2})
        self.settings.update({"gain":        self.cam.gain})
        self.settings.update({"shutter":     self.cam.shutter})
        self.settings.update({"thresh":      (0)})
        self.settings.update({"use_refraction": False})
        self.settings.update({"force_solve": False})
        self.settings.update({"max_stars":   0})
        self.load_settings()
        self.time_mgr.readiness = False
        exclogger.log_exception("Time Guessed (%u)" % pyb.millis(), time_str=comutils.fmt_time(self.time_mgr.get_time()))

        self.portal = captive_portal.CaptivePortal(debug = self.debug)

        self.img = None
        self.img_compressed = None
        self.extra_fb = None
        self.expo_code = 0
        self.histogram = None
        self.img_stats = None
        self.stars = []
        self.hot_pixels = []
        self.max_stars = 0
        self.packjpeg = False
        self.zoom = 1
        self.prevzoom = 1
        self.mem_errs = 0
        self.accel_sec = 0
        self.solution = None
        if self.portal is not None:
            self.register_http_handlers()
        while self.cam.check_init() == False:
            self.cam.check_init()
        self.cam.snapshot_start()
        self.snap_millis = pyb.millis()

        self.imgstream_sock = None
        self.websock = None
        self.websock_millis = 0
        self.websock_randid = 0
        self.stream_sock_err = 0

        self.extdisp = None
        try:
            import extdisp
            self.extdisp = extdisp.ExtDisp()
            if self.extdisp.oled.test_connect():
                self.extdisp.oled.init_display()
                self.extdisp.oled_ok = True
                print("OLED initialized on boot")
            if self.extdisp.gps.test_connect():
                print("GPS module found on boot")
        except Exception as exc:
            exclogger.log_exception(exc)