Beispiel #1
0
	def saveToFile(image, time, path, sub_directory = True):
		SkyCameraFile.stampImage(image, time)
		
		if sub_directory:
			path = os.path.join(path, str(int(time.mjd)))
			
			if not os.path.exists(path):
				os.mkdir(path)
		
		filename = SkyCameraFile.getFileName(time)
		
		path = os.path.join(path, filename)
		
		cv2.imwrite(path, image)
Beispiel #2
0
    def changePath(self, index):
        path = self.filesystemmodel.fileInfo(index).absoluteFilePath()
        self.files = SkyCameraFile.glob(path)
        if len(self.files) > 0:
            self.ui.imageSelector.setMaximum(len(self.files) - 1)
            self.ui.imageSelector.setEnabled(True)
        else:
            self.ui.imageSelector.setEnabled(False)

        self.difference_mode.reset()
        self.selectFile(0)
Beispiel #3
0
	def selectImage(self, number, load=True):
		filename = self.files[number]
		self.current_file = SkyCameraFile.uniqueName(filename)
		
		if self.current_file not in self.correspondences:
			self.correspondences[self.current_file] = []
		
		if load:
			self.image = cv2.imread(filename)
			
		self.calibration.selectImage(filename)
Beispiel #4
0
	def changePath(self, index):
		path = self.filesystemmodel.fileInfo(index).absoluteFilePath()
		self.files = SkyCameraFile.glob(path)
		if len(self.files) > 0:
			self.ui.imageSelector.setMaximum(len(self.files) - 1)
			self.ui.imageSelector.setEnabled(True)
		else:
			self.ui.imageSelector.setEnabled(False)
		
		self.difference_mode.reset()
		self.selectFile(0)
    def selectImage(self, number, load=True):
        filename = self.files[number]
        self.current_file = SkyCameraFile.uniqueName(filename)

        if self.current_file not in self.correspondences:
            self.correspondences[self.current_file] = []

        if load:
            self.image = cv2.imread(filename)

        self.calibration.selectImage(filename)
    def __init__(self):
        if len(sys.argv) < 2:
            print('Usage: calibration <directory> [<filename>]')
            print(
                'The supplied directory should contain the calibration images.'
            )
            sys.exit(1)

        size = 640

        self.path = sys.argv[1]
        self.image_window = 'Image Calibration'
        self.sky_window = 'Sky Calibration'
        self.tb_image_switch = 'image'
        self.tb_max_mag = 'maximum magnitude'
        self.save_file_name = 'data'
        self.selected_star = None
        self.selected_color = (0, 0, 255)
        self.marked_color = (0, 255, 0)
        self.circle_radius = 5
        self.max_mag = 4
        self.renderer = SkyRenderer(size)

        try:
            self.calibrator = Calibrator(
                SkyCameraFile.glob(self.path),
                EarthLocation(lat=Configuration.latitude,
                              lon=Configuration.longitude,
                              height=Configuration.elevation))
        except Exception as e:
            print(e.message)
            sys.exit(2)

        if len(sys.argv) > 2:
            self.save_file_name = sys.argv[2]
            if os.path.exists(self.save_file_name):
                self.calibrator.load(self.save_file_name)

        cv2.namedWindow(self.image_window, cv2.WINDOW_AUTOSIZE)
        cv2.namedWindow(self.sky_window, cv2.WINDOW_AUTOSIZE)

        self.selectImage(0)

        cv2.setMouseCallback(self.image_window, self.imageMouseCallback)
        cv2.setMouseCallback(self.sky_window, self.skyMouseCallback)
        cv2.createTrackbar(self.tb_image_switch, self.image_window, 0,
                           len(self.calibrator.files) - 1, self.selectImage)
        cv2.createTrackbar(self.tb_max_mag, self.sky_window, self.max_mag, 6,
                           self.setMaxMag)
Beispiel #7
0
	def __init__(self, files, location = None, catalog = None):
		if files == None:
			files = []
		
		self.files = files
		
		if len(self.files) > 0:
			self.current_file = SkyCameraFile.uniqueName(files[0])
			self.correspondences = {self.current_file: []}
		else:
			self.current_file = None
			self.correspondences = {}
		
		self.min_max_range = 5
		self.orders = 1
		self.nonlinear = True
		self.parameter_set = 0
		self.image = None
		
		self.calibration = Calibration(location, catalog)
    def __init__(self, files, location=None, catalog=None):
        if files == None:
            files = []

        self.files = files

        if len(self.files) > 0:
            self.current_file = SkyCameraFile.uniqueName(files[0])
            self.correspondences = {self.current_file: []}
        else:
            self.current_file = None
            self.correspondences = {}

        self.min_max_range = 5
        self.orders = 1
        self.nonlinear = True
        self.parameter_set = 0
        self.image = None

        self.calibration = Calibration(location, catalog)
Beispiel #9
0
	def __init__(self):
		if len(sys.argv) < 2:
			print('Usage: calibration <directory> [<filename>]')
			print('The supplied directory should contain the calibration images.')
			sys.exit(1)
		
		size = 640
		
		self.path = sys.argv[1]
		self.image_window = 'Image Calibration'
		self.sky_window = 'Sky Calibration'
		self.tb_image_switch = 'image'
		self.tb_max_mag = 'maximum magnitude'
		self.save_file_name = Configuration.calibration_file
		self.selected_star = None
		self.selected_color = (0, 0, 255)
		self.marked_color = (0, 255, 0)
		self.circle_radius = 5
		self.max_mag = 4
		self.renderer = SkyRenderer(size)
		
		try:
			self.calibrator = Calibrator(SkyCameraFile.glob(self.path), EarthLocation(lat=Configuration.latitude, lon=Configuration.longitude, height=Configuration.elevation))
		except Exception as e:
			print(e.message)
			sys.exit(2)
		
		if len(sys.argv) > 2:
			self.save_file_name = sys.argv[2]
			if os.path.exists(self.save_file_name):
				self.calibrator.load(self.save_file_name)

		cv2.namedWindow(self.image_window, cv2.WINDOW_AUTOSIZE)
		cv2.namedWindow(self.sky_window, cv2.WINDOW_AUTOSIZE)
		
		self.selectImage(0)

		cv2.setMouseCallback(self.image_window, self.imageMouseCallback)
		cv2.setMouseCallback(self.sky_window, self.skyMouseCallback)
		cv2.createTrackbar(self.tb_image_switch, self.image_window, 0, len(self.calibrator.files) - 1, self.selectImage)
		cv2.createTrackbar(self.tb_max_mag, self.sky_window, self.max_mag, 6, self.setMaxMag)
Beispiel #10
0
		self.alt = alt[0]

		return self.alt
		
	def isNight(self):
		return self.alt < Configuration.night_angle

	def isDay(self):
		return self.alt > Configuration.day_angle

	def __str__(self):
		if self.isNight():
			return "Night"
		elif self.isDay():
			return "Day"
		else:
			return "Twilight"

if __name__ == '__main__':
	checker = NightChecker()

	if len(sys.argv) > 1:
		files = SkyCameraFile.glob(sys.argv[1])

		for f in files:
			time = SkyCameraFile.parseTime(f)
			checker.setTime(time)
			print(f, checker)
	else:
		print(checker)
Beispiel #11
0
        cv2.circle(image, pos, radius, color)


if __name__ == '__main__':
    import sys
    window = 'Stars'
    size = 1024

    location = EarthLocation(lat=Configuration.latitude,
                             lon=Configuration.longitude,
                             height=Configuration.elevation)
    time = Time.now()

    if len(sys.argv) >= 2:
        try:
            time = SkyCameraFile.parseTime(sys.argv[1])
        except:
            pass

    catalog = SkyCatalog()
    catalog.setLocation(location)
    catalog.setTime(time)
    catalog.calculate()

    renderer = SkyRenderer(size)
    image = renderer.renderCatalog(catalog, 5)

    cv2.namedWindow(window, cv2.WINDOW_AUTOSIZE)
    cv2.imshow(window, image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
Beispiel #12
0
		
		pos = (int(pos[0]), int(pos[1]))
		
		cv2.circle(image, pos, radius, color)

if __name__ == '__main__':
	import sys
	window = 'Stars'
	size = 768

	location = EarthLocation(lat=Configuration.latitude, lon=Configuration.longitude, height=Configuration.elevation)
	time = Time.now()

	if len(sys.argv) >= 2:
		try:
			time = SkyCameraFile.parseTime(sys.argv[1])
		except:
			pass

	catalog = SkyCatalog()
	catalog.setLocation(location)
	catalog.setTime(time)
	catalog.calculate()

	renderer = SkyRenderer(size)
	image = renderer.renderCatalog(catalog, 5)

	cv2.namedWindow(window, cv2.WINDOW_AUTOSIZE)
	cv2.imshow(window, image)
	cv2.waitKey(0)
	cv2.destroyAllWindows()
Beispiel #13
0
    def setTime(self, time):
        self.catalog.setTime(time)
        _, _, alt, _ = self.catalog.calculate()

        self.alt = alt[0]

        return self.alt

    def isUp(self):
        return self.alt > Configuration.moon_up_angle

    def __str__(self):
        if self.isUp():
            return "Up"
        else:
            return "Down"


if __name__ == '__main__':
    checker = MoonChecker()

    if len(sys.argv) > 1:
        files = SkyCameraFile.glob(sys.argv[1])

        for f in files:
            time = SkyCameraFile.parseTime(f)
            checker.setTime(time)
            print(f, checker)
    else:
        print(checker)
Beispiel #14
0
	def selectImage(self, filename):
		time = SkyCameraFile.parseTime(filename)
		self.catalog.setTime(time)
		self.catalog.calculate()
Beispiel #15
0
 def selectImage(self, filename):
     time = SkyCameraFile.parseTime(filename)
     self.catalog.setTime(time)
     self.catalog.calculate()