Beispiel #1
0
    def draw_detection_region(frame: Frame, mask):
        """
        Rysuje na klatce obszar czułości kamery.

        :param Frame frame: Klatka obrazu.
        :return: Klatka obrazu z oznaczonym obszarem.
        :rtype: Frame
        """

        height, width = frame.size()
        horizontal_border = Configuration.horizontal_border()
        vertical_border = Configuration.vertical_border()
        lup = (int(horizontal_border), int(vertical_border))
        rup = (int(width-horizontal_border), int(vertical_border))
        llp = (int(horizontal_border), int(height-vertical_border))
        rlp = (int(width-horizontal_border), int(height-vertical_border))
        frame.img = cv2.line(frame.img, llp, lup, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, llp, rlp, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, rlp, rup, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, lup, rup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, llp, lup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, llp, rlp, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, rlp, rup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, lup, rup, (0, 0, 255), thickness=3)

        return frame, mask
Beispiel #2
0
    def draw_detection_region(frame: Frame, mask):
        """
        Rysuje na klatce obszar czułości kamery.

        :param Frame frame: Klatka obrazu.
        :return: Klatka obrazu z oznaczonym obszarem.
        :rtype: Frame
        """

        height, width = frame.size()
        horizontal_border = Configuration.horizontal_border()
        vertical_border = Configuration.vertical_border()
        lup = (int(horizontal_border), int(vertical_border))
        rup = (int(width - horizontal_border), int(vertical_border))
        llp = (int(horizontal_border), int(height - vertical_border))
        rlp = (int(width - horizontal_border), int(height - vertical_border))
        frame.img = cv2.line(frame.img, llp, lup, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, llp, rlp, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, rlp, rup, (0, 0, 255), thickness=3)
        frame.img = cv2.line(frame.img, lup, rup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, llp, lup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, llp, rlp, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, rlp, rup, (0, 0, 255), thickness=3)
        mask = cv2.line(mask, lup, rup, (0, 0, 255), thickness=3)

        return frame, mask
Beispiel #3
0
    def resize(frame: Frame):
        """
        Zmienia rozmiar obrazu na (720, 480).

        :return: Klatka obrazu o zmienionym rozmiarze.
        :rtype: Frame
        """

        frame.img = cv2.resize(frame.img, (720, 480))
        frame.orginal_img = cv2.resize(frame.orginal_img, (720, 480))

        return frame
Beispiel #4
0
    def draw_vehicles(frame: Frame, mask, vehicles: list):
        """
        Oznacza na obrazie pojazdy wraz ze środkami ciężkości.

        :param Frame frame: Klatka obrazu.
        :param list vehicles: Lista pojazdów.
        :return: Obraz z oznaczonymi pojazdami.
        :rtype: numpy.array
        """

        for veh in vehicles:
            x, y, w, h = veh.get_coordinates()
            cx = veh.centerx
            cy = veh.centery
            frame.img = cv2.rectangle(frame.img, (x, y), (x+w, y+h), (0, 255, 0), thickness=4)
            frame.img = cv2.line(frame.img, (cx, cy-10), (cx, cy+10), (0, 255, 0), thickness=4)
            frame.img = cv2.line(frame.img, (cx-10, cy), (cx+10, cy), (0, 255, 0), thickness=4)
            mask = cv2.rectangle(mask, (x, y), (x+w, y+h), (0, 255, 0), thickness=4)
            mask = cv2.line(mask, (cx, cy-10), (cx, cy+10), (0, 255, 0), thickness=4)
            mask = cv2.line(mask, (cx-10, cy), (cx+10, cy), (0, 255, 0), thickness=4)
        return frame, mask
Beispiel #5
0
    def draw_vehicles(frame: Frame, mask, vehicles: list):
        """
        Oznacza na obrazie pojazdy wraz ze środkami ciężkości.

        :param Frame frame: Klatka obrazu.
        :param list vehicles: Lista pojazdów.
        :return: Obraz z oznaczonymi pojazdami.
        :rtype: numpy.array
        """

        for veh in vehicles:
            x, y, w, h = veh.get_coordinates()
            cx = veh.centerx
            cy = veh.centery
            frame.img = cv2.rectangle(frame.img, (x, y), (x + w, y + h), (0, 255, 0), thickness=4)
            frame.img = cv2.line(frame.img, (cx, cy - 10), (cx, cy + 10), (0, 255, 0), thickness=4)
            frame.img = cv2.line(frame.img, (cx - 10, cy), (cx + 10, cy), (0, 255, 0), thickness=4)
            mask = cv2.rectangle(mask, (x, y), (x + w, y + h), (0, 255, 0), thickness=4)
            mask = cv2.line(mask, (cx, cy - 10), (cx, cy + 10), (0, 255, 0), thickness=4)
            mask = cv2.line(mask, (cx - 10, cy), (cx + 10, cy), (0, 255, 0), thickness=4)
        return frame, mask