Ejemplo n.º 1
0
 def __init__(self):
     self.ownShip = Aircraft(0, 0, 0, 0, 0, 0, 0, 0)
     self.aircraftQueue = PriorityQueue()
     self.myAction = Action(0, 0)
     self.ads_bInt = ADS_BDriver()
     self.display = Display()
     self.loudSpeaker = LoudSpeaker()
     self.panelBtns = FrontPanelButtons()
Ejemplo n.º 2
0
def main():
    print("ALP test")
    # This segment of code tests generating an Instruction with a single frame
    scalp_frame = fr.Frame()
    single_contour = scalp_frame.get_contour_of_image(
        image_path="./whitestar.jpg")
    scalp_instruction = ins.Instruction()
    scalp_instruction = scalp_frame.get_instruction_from_contour(
        contour=single_contour)
    scalp_instruction.plot_instruction()
    # This segment of code tests an Instruction with multiple frames
    file_dir = "./current_video_frame_threshs/"
    if [f for f in os.listdir(file_dir) if not f.startswith('.')] == []:
        print("empty dir")
        get_frames_diff_from_video()
    else:
        print("not empty")
    # instruction_set = get_contour_instructions_per_frame()
    scalp_instruction_set = ins.Instruction()
    scalp_instruction_set.get_instruction_series_from_video_frames(
        directory=file_dir)
    print(scalp_instruction_set.instruction_series[1])
    # scalp_instruction_set.instruction_series = instruction_set
    # scalp_instruction_set.get_instruction_size()
    # scalp_instruction_set.plot_instruction_series()
    A = scalp_instruction_set.instruction_series
    scalp_display = disp.Display()
    scalp_display.display_series_of_instructions(instruct_series=A,
                                                 display_time=1)
Ejemplo n.º 3
0
 def __init__(self):
     self.ownShip = Aircraft(0, 0, 0, 0, 0, 0, 0, 0)
     self.aircraftQueue = PriorityQueue()
     self.myAction = Action(0, 0)
     self.ads_bInt = ADS_BDriver()
     self.display = Display()
     self.loudSpeaker = LoudSpeaker()
     self.panelBtns = FrontPanelButtons()
Ejemplo n.º 4
0
def start():
    #Do tworzenia pixeli i odcinków algorytmem Bresenhama
    imgProc = ImageProcessing.PProcessing()

    #Tworzenie okręgu i tablicy promieni z każdej iteracji (ogólnie zbieranie informacji)
    structBuilder = StructBuilder.StructBuilder(WIDTH, HEIGHT, deltha.get(),
                                                detectors.get(),
                                                d_width.get(), ACCURACY,
                                                iterations.get(), RADIUS)

    #Wyświetlanie obrazków, tworzenie sinogramu i odwzorowanie oryginalnego obrazka
    displayImages = Display.DisplayImages(entry.get(), imgProc, structBuilder,
                                          WIDTH, HEIGHT, iterations.get(),
                                          detectors.get())

    displayImages.showImages()
Ejemplo n.º 5
0
class MainClass:
    def __init__(self):
        self.ownShip = Aircraft(0, 0, 0, 0, 0, 0, 0, 0)
        self.aircraftQueue = PriorityQueue()
        self.myAction = Action(0, 0)
        self.ads_bInt = ADS_BDriver()
        self.display = Display()
        self.loudSpeaker = LoudSpeaker()
        self.panelBtns = FrontPanelButtons()

    def refreshAircraftListFromADSB(self):
        adsData = self.ads_bInt.refresh()
        return ADS_BDataProcessor.getAircraftList(adsData)

    def buildAircraftPriorityQueue(self, aircraftList):
        self.aircraftQueue = PriorityQueue()
        for a in aircraftList:
            self.aircraftQueue.put(a)

    def updateDisplay(self, aircraftList, alertLevel, action):
        self.display.updateAircraftList(aircraftList)
        self.display.updateCurAlertLevel(alertLevel)
        self.display.updateCurAction(action)

    def updateLoudSpeaker(self, action):
        self.loudSpeaker.annunciate(action)

    def loopIter(self):
        aircraftList = self.refreshAircraftListFromADSB()

        if len(aircraftList) > 0:
            self.buildAircraftPriorityQueue(aircraftList)

            curAlertLevel = self.aircraftQueue.queue[0].getAlertLevel()
            curAction = self.determineAction

            self.updateDisplay(aircraftList, curAlertLevel, curAction)
            self.updateLoudSpeaker(curAction)

    def eventLoop(self):
        while True:
            self.loopIter()

    @property
    def determineAction(self):
        myAircraft = self.aircraftQueue.get()
        if (myAircraft.getAlertLevel() == AlertLevel.AL_PrevAdvisory):
            return Action(0, 1)
        elif (myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryLow):
            if (myAircraft.getZInFeet() > self.ownShip.getZInFeet()):
                return Action(-1, -1)
            elif (myAircraft.getZInFeet() < self.ownShip.getZInFeet()):
                return Action(1, -1)
            elif (myAircraft.getYInFeet > self.ownShip.getYInFeet()):
                return Action(-1, -1)
            elif (myAircraft.getYInFeet() < self.ownShip.getYInFeet()):
                return Action(1, -1)
            elif (myAircraft.getXInFeet > self.ownShip.getXInFeet()):
                return Action(-1, -1)
            elif (myAircraft.getXInFeet() < self.ownShip.getXInFeet()):
                return Action(1, -1)
        elif (myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryMed):
            if (myAircraft.getZInFeet() > self.ownShip.getZInFeet()):
                return Action(-1, 0)
            elif (myAircraft.getZInFeet() < self.ownShip.getZInFeet()):
                return Action(1, 0)
            elif (myAircraft.getYInFeet() > self.ownShip.getYInFeet()):
                return Action(-1, 0)
            elif (myAircraft.getYInFeet() < self.ownShip.getYInFeet()):
                return Action(1, 0)
            elif (myAircraft.getXInFeet() > self.ownShip.getXInFeet()):
                return Action(-1, 0)
            elif (myAircraft.getXInFeet() < self.ownShip.getXInFeet()):
                return Action(1, 0)
        elif (myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryHigh):
            if (myAircraft.getZInFeet() > self.ownShip.getZInFeet()):
                return Action(-1, 1)
            elif (myAircraft.getZInFeet() < self.ownShip.getZInFeet()):
                return Action(1, 1)
            elif (myAircraft.getYInFeet() > self.ownShip.getYInFeet()):
                return Action(-1, 1)
            elif (myAircraft.getYInFeet() < self.ownShip.getYInFeet()):
                return Action(1, 1)
            elif (myAircraft.getXInFeet() > self.ownShip.getXInFeet()):
                return Action(-1, 1)
            elif (myAircraft.getXInFeet() < self.ownShip.getXInFeet()):
                return Action(1, 1)
        else:
            return Action(0, -1)

    def setOwnShip(self, xInFeet: int, yInFeet: int, zInFeet: int,
                   heading: float, vSpeedFPS: int, gSpeedFPS: int,
                   alertLevel: AlertLevel, id: int):
        self.ownShip = Aircraft(xInFeet, yInFeet, zInFeet, heading, vSpeedFPS,
                                gSpeedFPS, alertLevel, id)

    def getAction(self):
        return self.myAction
Ejemplo n.º 6
0
class MainClass:
    def __init__(self):
        self.ownShip = Aircraft(0, 0, 0, 0, 0, 0, 0, 0)
        self.aircraftQueue = PriorityQueue()
        self.myAction = Action(0, 0)
        self.ads_bInt = ADS_BDriver()
        self.display = Display()
        self.loudSpeaker = LoudSpeaker()
        self.panelBtns = FrontPanelButtons()

    def refreshAircraftListFromADSB(self):
        adsData = self.ads_bInt.refresh()
        return ADS_BDataProcessor.getAircraftList(adsData)

    def buildAircraftPriorityQueue(self, aircraftList):
        self.aircraftQueue = PriorityQueue()
        for a in aircraftList:
            self.aircraftQueue.put(a)

    def updateDisplay(self, aircraftList, alertLevel, action):
        self.display.updateAircraftList(aircraftList)
        self.display.updateCurAlertLevel(alertLevel)
        self.display.updateCurAction(action)

    def updateLoudSpeaker(self, action):
        self.loudSpeaker.annunciate(action)

    def loopIter(self):
        aircraftList = self.refreshAircraftListFromADSB()

        if len(aircraftList) > 0:
            self.buildAircraftPriorityQueue(aircraftList)

            curAlertLevel = self.aircraftQueue.queue[0].getAlertLevel()
            curAction = self.determineAction

            self.updateDisplay(aircraftList, curAlertLevel, curAction)
            self.updateLoudSpeaker(curAction)

    def eventLoop(self):
        while True:
            self.loopIter()

    @property
    def determineAction(self):
        myAircraft = self.aircraftQueue.get()
        if myAircraft.getAlertLevel() == AlertLevel.AL_PrevAdvisory:
            return Action(0, 1)
        elif myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryLow:
            if myAircraft.getZInFeet() > self.ownShip.getZInFeet():
                return Action(-1, -1)
            elif myAircraft.getZInFeet() < self.ownShip.getZInFeet():
                return Action(1, -1)
            elif myAircraft.getYInFeet > self.ownShip.getYInFeet():
                return Action(-1, -1)
            elif myAircraft.getYInFeet() < self.ownShip.getYInFeet():
                return Action(1, -1)
            elif myAircraft.getXInFeet > self.ownShip.getXInFeet():
                return Action(-1, -1)
            elif myAircraft.getXInFeet() < self.ownShip.getXInFeet():
                return Action(1, -1)
        elif myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryMed:
            if myAircraft.getZInFeet() > self.ownShip.getZInFeet():
                return Action(-1, 0)
            elif myAircraft.getZInFeet() < self.ownShip.getZInFeet():
                return Action(1, 0)
            elif myAircraft.getYInFeet() > self.ownShip.getYInFeet():
                return Action(-1, 0)
            elif myAircraft.getYInFeet() < self.ownShip.getYInFeet():
                return Action(1, 0)
            elif myAircraft.getXInFeet() > self.ownShip.getXInFeet():
                return Action(-1, 0)
            elif myAircraft.getXInFeet() < self.ownShip.getXInFeet():
                return Action(1, 0)
        elif myAircraft.getAlertLevel() == AlertLevel.AL_ResolAdvisoryHigh:
            if myAircraft.getZInFeet() > self.ownShip.getZInFeet():
                return Action(-1, 1)
            elif myAircraft.getZInFeet() < self.ownShip.getZInFeet():
                return Action(1, 1)
            elif myAircraft.getYInFeet() > self.ownShip.getYInFeet():
                return Action(-1, 1)
            elif myAircraft.getYInFeet() < self.ownShip.getYInFeet():
                return Action(1, 1)
            elif myAircraft.getXInFeet() > self.ownShip.getXInFeet():
                return Action(-1, 1)
            elif myAircraft.getXInFeet() < self.ownShip.getXInFeet():
                return Action(1, 1)
        else:
            return Action(0, -1)

    def setOwnShip(
        self,
        xInFeet: int,
        yInFeet: int,
        zInFeet: int,
        heading: float,
        vSpeedFPS: int,
        gSpeedFPS: int,
        alertLevel: AlertLevel,
        id: int,
    ):
        self.ownShip = Aircraft(xInFeet, yInFeet, zInFeet, heading, vSpeedFPS, gSpeedFPS, alertLevel, id)

    def getAction(self):
        return self.myAction