Exemple #1
0
 def _draw_indicator(self,
                     src,
                     center,
                     color=(255, 0, 0),
                     shape='circle',
                     size=4,
                     thickness=-1):
     """
         convenience function for drawing indicators
     """
     if isinstance(center, tuple):
         center = new_point(*center)
     r = size
     if shape == 'rect':
         draw_rectangle(src,
                        center.x - r / 2.,
                        center.y - r / 2.,
                        r,
                        r,
                        color=color,
                        thickness=thickness)
     elif shape == 'crosshairs':
         draw_lines(src, [[(center.x - size, center.y),
                           (center.x + size, center.y)],
                          [(center.x, center.y - size),
                           (center.x, center.y + size)]],
                    color=color,
                    thickness=1)
     else:
         draw_circle(src, center[0], center[1], r, color=color)
Exemple #2
0
    def _draw_targets(self, src, targets, dim):
        '''
            draw a crosshairs indicator
        '''

        wh = get_size(src)
        for ta in targets:
            pt = new_point(*ta.centroid)
            self._draw_indicator(src,
                                 pt,
                                 color=(0, 255, 0),
                                 size=10,
                                 shape='crosshairs')
            draw_circle(
                src,
                pt,
                radius=int(dim)
                #                         color=color,
                #                         thickness=1
            )
            #             im = zeros(wh)
            #             points = asarray(ta.poly_points)
            #
            #             rr, cc = polygon(*points.T)
            #             im[cc, rr] = 255
            #
            #             cx, cy = center_of_mass(im)
            #             pt = new_point(cy, cx)
            #             self._draw_indicator(pychron, pt,
            #                                  color=(0, 255, 255),
            #                                  size=10,
            #                                  shape='crosshairs')
            draw_polygons(src, [ta.poly_points])
Exemple #3
0
    def _draw_targets(self, src, targets, dim):
        '''
            draw a crosshairs indicator
        '''

        wh = get_size(src)
        for ta in targets:
            pt = new_point(*ta.centroid)
            self._draw_indicator(src, pt,
                                 color=(0, 255, 0),
                                 size=10,
                                 shape='crosshairs')
            draw_circle(src, pt,
                        radius=int(dim)
#                         color=color,
#                         thickness=1
                        )
#             im = zeros(wh)
#             points = asarray(ta.poly_points)
#
#             rr, cc = polygon(*points.T)
#             im[cc, rr] = 255
#
#             cx, cy = center_of_mass(im)
#             pt = new_point(cy, cx)
#             self._draw_indicator(pychron, pt,
#                                  color=(0, 255, 255),
#                                  size=10,
#                                  shape='crosshairs')
            draw_polygons(src, [ta.poly_points])
Exemple #4
0
 def _draw_center_indicator(self, src, color=(0, 0, 255), shape='crosshairs',
                            size=10, radius=1):
     """
         draw indicator at center of frame
     """
     cpt = self._get_frame_center(src)
     self._draw_indicator(src, new_point(*cpt),
                          #                             shape='crosshairs',
                          shape=shape,
                          color=color,
                          size=size)
Exemple #5
0
    def _draw_center_indicator(self, src, color=(0, 0, 255), shape='crosshairs',
                               size=10, radius=1):
        '''
            draw indicator at center of frame
        '''
        cpt = self._get_frame_center(src)
        self._draw_indicator(src, new_point(*cpt),
#                             shape='crosshairs',
                             shape=shape,
                             color=color,
                             size=size)

        draw_circle(src, cpt, radius, color=color, thickness=1)
Exemple #6
0
    def _draw_targets(self, src, targets, dim):
        """
            draw a crosshairs indicator
        """

        for ta in targets:
            pt = new_point(*ta.centroid)
            self._draw_indicator(src, pt,
                                 color=(0, 255, 0),
                                 size=10,
                                 shape='crosshairs')
            # draw_circle(src, pt,
            #             color=(0,255,0),
            #             radius=int(dim))

            draw_polygons(src, [ta.poly_points], color=(255, 255, 255))
Exemple #7
0
 def _draw_center_indicator(self,
                            src,
                            color=(0, 0, 255),
                            shape='crosshairs',
                            size=10,
                            radius=1):
     """
         draw indicator at center of frame
     """
     cpt = self._get_frame_center(src)
     self._draw_indicator(
         src,
         new_point(*cpt),
         #                             shape='crosshairs',
         shape=shape,
         color=color,
         size=size)
Exemple #8
0
    def _draw_targets(self, src, targets):
        """
            draw a crosshairs indicator
        """
        if targets:
            for ta in targets:
                pt = new_point(*ta.centroid)
                self._draw_indicator(src,
                                     pt,
                                     color=(0, 255, 0),
                                     size=10,
                                     shape='crosshairs')
                # draw_circle(src, pt,
                #             color=(0,255,0),
                #             radius=int(dim))

                draw_polygons(src, [ta.poly_points], color=(255, 255, 255))
Exemple #9
0
    def _draw_center_indicator(self,
                               src,
                               color=(0, 0, 255),
                               shape='crosshairs',
                               size=10,
                               radius=1):
        '''
            draw indicator at center of frame
        '''
        cpt = self._get_frame_center(src)
        self._draw_indicator(
            src,
            new_point(*cpt),
            #                             shape='crosshairs',
            shape=shape,
            color=color,
            size=size)

        draw_circle(src, cpt, radius, color=color, thickness=1)
Exemple #10
0
 def _draw_indicator(self, src, center, color=(255, 0, 0), shape='circle',
                     size=4, thickness=-1):
     """
         convenience function for drawing indicators
     """
     if isinstance(center, tuple):
         center = new_point(*center)
     r = size
     if shape == 'rect':
         draw_rectangle(src, center.x - r / 2., center.y - r / 2., r, r,
                        color=color,
                        thickness=thickness)
     elif shape == 'crosshairs':
         draw_lines(src,
                    [[(center.x - size, center.y),
                      (center.x + size, center.y)],
                     [(center.x, center.y - size),
                      (center.x, center.y + size)]],
                    color=color,
                    thickness=1)
     else:
         draw_circle(src, center[0], center[1], r, color=color)