Ejemplo n.º 1
0
    def detect_objects(self, s: Settings) -> None:
        """
        Uses the in Settings specified method to detect the object
        :param s: Settings object used to store thresholds and camera used data
        :type s: Settings
        :return: None
        """
        m = Markers(s)
        self.frame = self._get_video(s, self._cap)
        marker_frame, warped_frame = m.remove_warp(s, self.frame)
        self.grayscale = self._convert_to_grayscale(warped_frame)
        width, height = self.frame.shape[0:2]

        if s.edge_detection_type == 1:  # Only threshold detection
            self.thrash = self._edge_threshold(s, self.grayscale)
            self.video_output = self._draw_contour(
                s, self.frame, self._edge_contour(self.thrash))
        elif s.edge_detection_type == 2:  # Threshold + Canny shape detection
            gausian_blur = cv.GaussianBlur(self.grayscale, (5, 5), sigmaX=0)
            self.thrash = self._edge_threshold(s, gausian_blur)
            self.canny = self._edge_canny(s, self.thrash)
            self.dilate = self._dilate_edges(self.canny,
                                             iterations=s.dilate_iterations)
            self.erode = self._erode_edges(self.dilate,
                                           iterations=s.erode_iterations)
            self.blur = self._blur_edges(s, self.erode)
            contours = self._edge_contour(self.blur)
            self.video_output = self._draw_contour(s, warped_frame, contours)
            cv.imwrite('./output.bmp', self.video_output)
        elif s.edge_detection_type == 3:  # Blob + Canny shape detection
            self.blob = self._edge_blob(self.grayscale)
            self.canny = self._edge_canny(s, self.blob)
        else:  # Simple Canny method
            self._edge_canny(s, self.grayscale)
 def __init__(self):
     # noinspection PyArgumentList
     self.cap = cv2.VideoCapture(0)
     self.cap.set(15, -7)
     self.frames_to_display = {}
     self.display = Display()
     self.markers = Markers()
     self.markers_cache = None
Ejemplo n.º 3
0
    def __init__(self):
        # initialise markers
        self.markers = Markers()

        # initialise textures
        self.marker_one_textures, self.marker_two_textures = self._load_textures()

        # initialise video
        self.video_capture = cv2.VideoCapture()
Ejemplo n.º 4
0
    def align(self, options):
        """Create MSA from marker genes."""

        check_dir_exists(options.identify_dir)
        make_sure_path_exists(options.out_dir)

        if not hasattr(options, 'outgroup_taxon'):
            options.outgroup_taxon = None

        markers = Markers(options.cpus)
        markers.align(options.identify_dir, options.taxa_filter,
                      options.min_perc_aa, options.custom_msa_filters,
                      options.consensus, options.min_perc_taxa,
                      options.out_dir, options.prefix, options.outgroup_taxon)

        self.logger.info('Done.')
Ejemplo n.º 5
0
    def identify(self, options):
        """Identify marker genes in genomes."""

        if options.genome_dir:
            check_dir_exists(options.genome_dir)

        if options.batchfile:
            check_file_exists(options.batchfile)

        make_sure_path_exists(options.out_dir)

        genomes = self._genomes_to_process(options.genome_dir,
                                           options.batchfile,
                                           options.extension)

        markers = Markers(options.cpus)
        markers.identify(genomes, options.out_dir, options.prefix)

        self.logger.info('Done.')
Ejemplo n.º 6
0
def loop():

    frame = capture.get_frame()
    if frame is None:
        return

    (cap_height, cap_width, cap_channels) = frame.shape
    # print(width, height, channels)

    global markerDict
    (corners, ids, rejects) = aruco.detectMarkers(frame, markerDict)
    # print(corners)
    frame = aruco.drawDetectedMarkers(frame, corners, ids)

    detected_markers = np.array([]).reshape(0, 3)
    for i in range(len(corners)):
        corner = corners[i][0]
        p1 = corner[0]
        p2 = corner[1]
        p3 = corner[2]
        p4 = corner[3]
        x = p1[0] - ((p1[0] - p3[0]) / 2)
        y = p1[1] - ((p1[1] - p3[1]) / 2)

        x = int(x)
        y = int(y)

        # print(x, y, cap_width, cap_height)
        detected_markers = np.vstack(
            (detected_markers,
             np.array([ids[i][0], x / cap_width, y / cap_height])))
        cv2.circle(frame, (x, y), 10, (255, 255, 255), 2)

    global sock
    if not sock.is_available():
        sock.connect()
    else:
        send_data = Markers()
        for row in detected_markers:
            marker = Marker(int(row[0]), row[1], row[2])
            send_data.append(marker)
        sock.send(str(send_data))
Ejemplo n.º 7
0
    def __init__(self):
        # initialise config
        self.config_provider = ConfigProvider()

        # initialise robots
        self.rocky_robot = RockyRobot()
        self.sporty_robot = SportyRobot()

        # initialise webcam
        self.webcam = Webcam()

        # initialise markers
        self.markers = Markers()
        self.markers_cache = None

        # initialise features
        self.features = Features(self.config_provider)

        # initialise texture
        self.texture_background = None