def get_pixels_array(pixels_bytes, height, width, k):
    pixels = np.empty((height, width), dtype=np.uint8)
    image = np.empty((height, width, 3), dtype=np.uint8)
    pixels_bw = np.empty((height, width, 3), dtype=np.uint8)
    max_pixels = []

    i = 0
    for row_index in range(height):
        pixels_sum = 0
        for column_index in range(width):
            image[height - row_index - 1, column_index] = rgb(pixels_bytes[i])
            pixels[height - row_index - 1,
                   column_index] = pixel_avg(rgb(pixels_bytes[i]))
            i += 1
        max_pixels.append(max(pixels[height - row_index - 1]))
        i -= width

        row_max = max_pixels[row_index]
        for column_index in range(width):
            pixel = pixel_avg(rgb(pixels_bytes[i]))

            value = PIXEL_BLACK
            if pixels_sum >= k * row_max:
                value = PIXEL_WHITE
                pixels_sum -= k * row_max
            pixels_sum += pixel

            pixels_bw[height - row_index - 1, column_index] = value
            i += 1

    return pixels_bw, image
示例#2
0
    def testParseOneColor(self):
        assert len(self.gif.images) == 1
        assert self.gif.width == 40
        assert self.gif.height == 40

        image_block = self.gif.images[0]
        assert image_block.width == 40
        assert image_block.height == 40
        print rgb(image_block.pallete_bytes)
        assert rgb(image_block.pallete_bytes) == (
            (255, 0, 0),
            (0, 0, 0)
            )
示例#3
0
 def set_source_rgb(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         step_size = 1.0 / (len(colour) - 1)
         step = 0.0
         for c in colour:
             rgb_col = utils.rgb(c)
             if len(rgb_col) < 4:
                 rgb_col[3] = 1
             linear.add_color_stop_rgba(step, *rgb_col)
             step += step_size
         self.ctx.set_source(linear)
     else:
         self.ctx.set_source_rgba(*utils.rgb(colour))
示例#4
0
文件: drawer.py 项目: Echota/qtile
 def set_source_rgb(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         c1 = utils.rgb(colour[0])
         c2 = utils.rgb(colour[1])
         if len(c1) < 4:
             c1[3] = 1
         if len(c2) < 4:
             c2[3] = 1
         linear.add_color_stop_rgba(0.0, c1[0], c1[1], c1[2], c1[3])
         linear.add_color_stop_rgba(1.0, c2[0], c2[1], c2[2], c2[3])
         self.ctx.set_source(linear)
     else:
         self.ctx.set_source_rgba(*utils.rgb(colour))
示例#5
0
文件: drawer.py 项目: ratanraj/qtile
 def set_source_rgb(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         step_size = 1.0 / (len(colour) - 1)
         step = 0.0
         for c in colour:
             rgb_col = utils.rgb(c)
             if len(rgb_col) < 4:
                 rgb_col[3] = 1
             linear.add_color_stop_rgba(step, *rgb_col)
             step += step_size
         self.ctx.set_source(linear)
     else:
         self.ctx.set_source_rgba(*utils.rgb(colour))
示例#6
0
 def set_source_rgb(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         c1 = utils.rgb(colour[0])
         c2 = utils.rgb(colour[1])
         if len(c1) < 4:
             c1[3] = 1
         if len(c2) < 4:
             c2[3] = 1
         linear.add_color_stop_rgba(0.0, c1[0], c1[1], c1[2], c1[3])
         linear.add_color_stop_rgba(1.0, c2[0], c2[1], c2[2], c2[3])
         self.ctx.set_source(linear)
     else:
         self.ctx.set_source_rgba(*utils.rgb(colour))
示例#7
0
 def __call__(self, img, show_plots=False):
     hits = self.get_hits(img)
     heat = make_heatmap(img.shape[0:2], hits)
     if self._last_heatmap is None:
         self._last_heatmap = heat
     filtered_heat = (1-self._alpha) * self._last_heatmap + self._alpha * heat
     self._last_heatmap = filtered_heat
     binary = filtered_heat >= self._threshold
     labels = label_image(binary)
     boxes = []
     for i in range(labels[1]):
         y_points, x_points = np.where(labels[0] == i+1)
         box = ((np.min(x_points), np.min(y_points)),
                (np.max(x_points), np.max(y_points)))
         width = box[1][0] - box[0][0]
         height = box[1][1] - box[0][1]
         if width >= 32 and height >= 32:
             boxes.append(box)
     if show_plots:
         f, ((a0, a1), (a2, a3)) = plt.subplots(2, 2)
         a0.set_title('Raw Hits')
         a0.imshow(draw_boxes(rgb(img, self._cspace), hits))
         a1.set_title('Heatmap')
         a1.imshow(heat.astype(np.float32)/np.max(heat), cmap='gray')
         a2.set_title('Thresholded Heatmap')
         a2.imshow(binary, cmap='gray')
         a3.set_title('Label Image')
         a3.imshow(labels[0], cmap='gray')
         plt.show()
     return boxes
示例#8
0
    def dibujar(self):
        glPushMatrix()

        glTranslatef(self.p[0], self.p[1], 0.0)

        #Punta flecha
        triangulos = [
            [[0, 15], [15, 0], [0, -15]],
        ]

        glColor3fv(rgb(0, 0, 0))
        glBegin(GL_TRIANGLES)
        for triangulo in triangulos:
            for vertice in triangulo:
                glVertex2fv(vertice)

        glEnd()

        glBegin(GL_QUADS)
        cuadrados = [[[-50, -5], [-50, 5], [0, 5], [0, -5]]]

        for cuadrado in cuadrados:
            for vertice in cuadrado:
                glVertex2fv(vertice)
        glEnd()

        glPopMatrix()
示例#9
0
def open3Dheatmap(aligned_cloud_path, gt_path):

    with open(aligned_cloud_path, "r") as ac:
        lines = ac.readlines()

        pointsAC = []
        for line in lines:
            pointsAC.append(Point3D.Point3D(line))

    with open(gt_path, 'r') as gt:
        gt_lines = gt.readlines()
        pointsGT = []
        for gt_line in gt_lines:
            pointsGT.append(Point3D.Point3D(gt_line))

    mins = []
    for pt_ac in pointsAC:
        mins.append(min([pt_ac.distance(pt_gt) for pt_gt in pointsGT]))

    max_mins = max(mins)
    min_mins = min(mins)

    if min_mins > 0.5:
        min_mins = 0

    points = np.zeros((len(lines), 3))
    colours = np.zeros((len(lines), 3))

    i = 0
    for line in lines:
        coords = line.split(sep=" ")

        points[i, 0] = float(coords[0])
        points[i, 1] = float(coords[1])
        points[i, 2] = float(coords[2])

        r, g, b = rgb(val=mins[i], minval=min_mins, maxval=max_mins)

        colours[i, 0] = r / 255
        colours[i, 1] = g / 255
        colours[i, 2] = b / 255

        i += 1

    print("Red --> " + str(min_mins))
    print("Orange -- > " + str((max_mins + min_mins) * 2 / 8))
    print("Yellow -- > " + str((max_mins + min_mins) * 3 / 8))
    print("Green -- > " + str((max_mins + min_mins) * 4 / 8))
    print("Light Blue -- > " + str((max_mins + min_mins) * 5 / 8))
    print("Blue -- > " + str((max_mins + min_mins) * 6 / 8))
    print("Purple -- > " + str((max_mins + min_mins) * 7 / 8))
    print("Violet --> " + str(max_mins))

    pcd = o3d.geometry.PointCloud()

    pcd.points = o3d.utility.Vector3dVector(points)
    pcd.colors = o3d.utility.Vector3dVector(colours)

    o3d.visualization.draw_geometries([pcd])
示例#10
0
文件: drawer.py 项目: Echota/qtile
 def clear(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         c1 = utils.rgb(colour[0])
         c2 = utils.rgb(colour[1])
         if len(c1) < 4:
             c1[3] = 1
         if len(c2) < 4:
             c2[3] = 1
         linear.add_color_stop_rgba(0.0, c1[0], c1[1], c1[2], c1[3])
         linear.add_color_stop_rgba(1.0, c2[0], c2[1], c2[2], c2[3])
         self.ctx.set_source(linear)
     else:
         self.set_source_rgb(colour)
     self.ctx.rectangle(0, 0, self.width, self.height)
     self.ctx.fill()
     self.ctx.stroke()
示例#11
0
 def clear(self, colour):
     if type(colour) == list:
         linear = cairo.LinearGradient(0.0, 0.0, 0.0, self.height)
         c1 = utils.rgb(colour[0])
         c2 = utils.rgb(colour[1])
         if len(c1) < 4:
             c1[3] = 1
         if len(c2) < 4:
             c2[3] = 1
         linear.add_color_stop_rgba(0.0, c1[0], c1[1], c1[2], c1[3])
         linear.add_color_stop_rgba(1.0, c2[0], c2[1], c2[2], c2[3])
         self.ctx.set_source(linear)
     else:
         self.set_source_rgb(colour)
     self.ctx.rectangle(0, 0, self.width, self.height)
     self.ctx.fill()
     self.ctx.stroke()
示例#12
0
文件: game.py 项目: maleix/mazeweaver
    def render_once(self):
        self.screen.fill(rgb("black"))
        for wall in self.walls:
            self.screen.blit(self.wall_image, wall.rect)
        self.screen.blit(self.end_image, self.end_rect)
        draw_grid(self.screen, len(self.labyrinth[0]), len(self.labyrinth),
                  "darkgray")

        pygame.display.update()
示例#13
0
 def draw(self):
     if self.y >= self.size:
         self.y = 0
         self.d = self.d // 4
     if self.d >= 1:
         for x in range(0, self.size, self.d):
             u = 2 * float(x + self.d / 2) / self.size - 1.0
             v = 2 * float(self.y + self.d / 2) / self.size - 1.0
             (r, g, b) = self.art.eval(u, v)
             self.drawing.point((x, self.y), rgb(r, g, b))
         self.y += self.d
         print("\r" + str((self.y * 100) / self.size) + "%", end='')
     else:
         print("\nDone with seed '%s' (Size %s)" % (self.x, self.size))
         filename = "randimg_%s_%s" % ("".join(
             [_ for _ in self.x if _ in string.ascii_letters]), self.size)
         self.image1.save(filename + ".jpg")  # Export da shit out
         self.write_seed_name(filename)
         print("Total seconds elapsed : %s" %
               (datetime.datetime.now() - self.start).total_seconds())
         return {'seed': self.x, 'size': self.size, 'filename': filename}
示例#14
0
 def testParsePLTE(self):
     assert utils.rgb(self.png.pallete_bytes) == (
         (0, 0, 1),
         (4, 4, 10),
         (26, 26, 28),
         (32, 31, 37),
         (16, 15, 20),
         (6, 4, 16),
         (86, 86, 90),
         (157, 157, 162),
         (206, 206, 209),
         (197, 197, 201),
         (191, 192, 196),
         (179, 179, 180),
         (186, 186, 188),
         (195, 195, 195),
         (91, 91, 92),
         (21, 21, 25),
         (40, 39, 44),
         (56, 55, 62),
         (23, 21, 32),
         (7, 8, 11),
         (62, 64, 63),
         (123, 123, 124),
         (239, 240, 243),
         (254, 254, 254),
         (223, 224, 226),
         (104, 103, 108),
         (80, 79, 84),
         (76, 76, 77),
         (43, 43, 44),
         (63, 63, 65),
         (227, 227, 229),
         (176, 175, 181),
         (102, 101, 105),
         (230, 230, 234),
         (246, 246, 249),
         (223, 222, 226),
         (151, 150, 155),
         (35, 35, 37),
         (93, 91, 105),
         (248, 247, 252),
         (117, 117, 122),
         (216, 215, 220),
         (249, 249, 247),
         (246, 248, 247),
         (211, 211, 212),
         (131, 131, 132),
         (108, 109, 113),
         (166, 166, 169),
         (107, 107, 108),
         (236, 236, 237),
         (125, 125, 130),
         (59, 59, 60),
         (219, 219, 220),
         (45, 45, 49),
         (88, 87, 92),
         (99, 99, 100),
         (204, 204, 204),
         (79, 80, 84),
         (167, 168, 170),
         (147, 147, 148),
         (10, 10, 13),
         (103, 105, 104),
         (189, 189, 194),
         (171, 172, 172),
         (68, 68, 69),
         (140, 140, 140),
         (163, 162, 164),
         (115, 115, 116),
         (155, 155, 156),
         (81, 81, 79),
         (8, 7, 12),
         (212, 212, 217),
         (136, 136, 134),
         (184, 184, 182),
         (72, 72, 70),
         (238, 237, 242),
         (19, 19, 21),
         (166, 164, 177),
         (77, 76, 83),
         (69, 69, 73),
         (132, 131, 136),
         (92, 92, 97),
         (182, 181, 186),
         (29, 28, 33),
         (136, 135, 140),
         (174, 174, 177),
         (244, 244, 245),
         (50, 50, 51),
         (143, 144, 146),
         (142, 141, 147),
         (208, 207, 212),
         (240, 239, 244),
         (83, 83, 84),
         (35, 35, 41),
         (161, 159, 170),
         (152, 151, 157),
         (13, 11, 25),
         (53, 52, 58),
         (199, 197, 208),
     )
示例#15
0
文件: drawer.py 项目: AdamG/qtile
 def set_source_rgb(self, colour):
     self.ctx.set_source_rgba(*utils.rgb(colour))
示例#16
0
 def set_source_rgb(self, colour):
     self.ctx.set_source_rgba(*utils.rgb(colour))
示例#17
0
 def testParsePLTE(self):
     assert utils.rgb(self.png.pallete_bytes) == (
         (0, 0, 1),
         (4, 4, 10),
         (26, 26, 28),
         (32, 31, 37),
         (16, 15, 20),
         (6, 4, 16),
         (86, 86, 90),
         (157, 157, 162),
         (206, 206, 209),
         (197, 197, 201),
         (191, 192, 196),
         (179, 179, 180),
         (186, 186, 188),
         (195, 195, 195),
         (91, 91, 92),
         (21, 21, 25),
         (40, 39, 44),
         (56, 55, 62),
         (23, 21, 32),
         (7, 8, 11),
         (62, 64, 63),
         (123, 123, 124),
         (239, 240, 243),
         (254, 254, 254),
         (223, 224, 226),
         (104, 103, 108),
         (80, 79, 84),
         (76, 76, 77),
         (43, 43, 44),
         (63, 63, 65),
         (227, 227, 229),
         (176, 175, 181),
         (102, 101, 105),
         (230, 230, 234),
         (246, 246, 249),
         (223, 222, 226),
         (151, 150, 155),
         (35, 35, 37),
         (93, 91, 105),
         (248, 247, 252),
         (117, 117, 122),
         (216, 215, 220),
         (249, 249, 247),
         (246, 248, 247),
         (211, 211, 212),
         (131, 131, 132),
         (108, 109, 113),
         (166, 166, 169),
         (107, 107, 108),
         (236, 236, 237),
         (125, 125, 130),
         (59, 59, 60),
         (219, 219, 220),
         (45, 45, 49),
         (88, 87, 92),
         (99, 99, 100),
         (204, 204, 204),
         (79, 80, 84),
         (167, 168, 170),
         (147, 147, 148),
         (10, 10, 13),
         (103, 105, 104),
         (189, 189, 194),
         (171, 172, 172),
         (68, 68, 69),
         (140, 140, 140),
         (163, 162, 164),
         (115, 115, 116),
         (155, 155, 156),
         (81, 81, 79),
         (8, 7, 12),
         (212, 212, 217),
         (136, 136, 134),
         (184, 184, 182),
         (72, 72, 70),
         (238, 237, 242),
         (19, 19, 21),
         (166, 164, 177),
         (77, 76, 83),
         (69, 69, 73),
         (132, 131, 136),
         (92, 92, 97),
         (182, 181, 186),
         (29, 28, 33),
         (136, 135, 140),
         (174, 174, 177),
         (244, 244, 245),
         (50, 50, 51),
         (143, 144, 146),
         (142, 141, 147),
         (208, 207, 212),
         (240, 239, 244),
         (83, 83, 84),
         (35, 35, 41),
         (161, 159, 170),
         (152, 151, 157),
         (13, 11, 25),
         (53, 52, 58),
         (199, 197, 208),
     )
示例#18
0
文件: game.py 项目: maleix/mazeweaver
    def render(self):
        if not self.rendered_once:
            self.render_once()
            self.rendered_once = True

        rects_to_draw = []

        for block in self.old_blocks:
            rects_to_draw.append(
                pygame.draw.rect(self.screen, rgb("black"), block.rect))

        draw_grid(self.screen, len(self.labyrinth[0]), len(self.labyrinth),
                  "darkgray")

        for i, block in enumerate(self.blocks):
            if i == self.selected_block:
                if block.new_direction == "left":
                    selected_rect = self.screen.blit(self.block_left,
                                                     block.rect)
                elif block.new_direction == "right":
                    selected_rect = self.screen.blit(self.block_right,
                                                     block.rect)
                elif block.new_direction == "down":
                    selected_rect = self.screen.blit(self.block_down,
                                                     block.rect)
                elif block.new_direction == "up":
                    selected_rect = self.screen.blit(self.block_up, block.rect)
                else:
                    selected_rect = self.screen.blit(self.block_standing,
                                                     block.rect)
            else:
                if block.new_direction == "left":
                    selected_rect = self.screen.blit(
                        self.block_unselected_left, block.rect)
                elif block.new_direction == "right":
                    selected_rect = self.screen.blit(
                        self.block_unselected_right, block.rect)
                elif block.new_direction == "down":
                    selected_rect = self.screen.blit(
                        self.block_unselected_down, block.rect)
                elif block.new_direction == "up":
                    selected_rect = self.screen.blit(self.block_unselected_up,
                                                     block.rect)
                else:
                    selected_rect = self.screen.blit(
                        self.block_unselected_standing, block.rect)

            rects_to_draw.append(selected_rect)

            number = self.number_font.render(str(block.number_id), 0,
                                             rgb("lightgreen"))
            # This rect should be inside the Userblock rect
            # so there is no need to put it in the rects to draw
            self.screen.blit(
                number,
                (
                    block.rect.x +
                    (self.block_size[0] / 2 - number.get_width() / 2),
                    block.rect.y +
                    (self.block_size[1] / 2 - number.get_height() / 2),
                ),
            )

        bottom_left_wall = Wall(
            (0, SCREEN_HEIGTH - self.block_size[1]),
            self.block_size[0],
            self.block_size[1],
        )
        rects_to_draw.append(
            self.screen.blit(self.wall_image, bottom_left_wall.rect))

        timer = self.timer_font.render(str(self.seconds_left), 0,
                                       rgb("yellow"))
        rects_to_draw.append(
            self.screen.blit(
                timer,
                (
                    self.block_size[0] / 2 - (timer.get_width() / 2),
                    SCREEN_HEIGTH - self.block_size[1] +
                    timer.get_height() / 2,
                ),
            ))

        pygame.display.update(rects_to_draw)
示例#19
0
 def testParseColorPallete(self):
     image_block = self.gif.images[0]
     assert rgb(image_block.pallete_bytes) == (
         ( 43, 80,121),
         ( 68, 68, 68),
         ( 75, 75, 75),
         ( 83, 83, 83),
         ( 89, 89, 89),
         ( 65, 85,127),
         ( 98, 98, 98),
         (107,107,107),
         (116,116,116),
         (125,125,125),
         (142,117,117),
         ( 90,148,119),
         ( 55, 93,149),
         ( 54,100,147),
         ( 50,108,167),
         ( 80,109,159),
         ( 71,110,173),
         ( 86,119,186),
         ( 61, 61,220),
         ( 61, 61,228),
         ( 60, 60,237),
         ( 58, 58,244),
         ( 53, 53,251),
         ( 60, 60,251),
         ( 64, 63,233),
         ( 58, 73,247),
         ( 59,118,236),
         ( 81, 81,203),
         ( 76, 76,211),
         ( 83, 83,212),
         ( 89, 89,216),
         ( 82,122,203),
         (112,109,209),
         (120,120,217),
         ( 68, 67,235),
         ( 89, 89,232),
         ( 65, 65,244),
         ( 67, 67,251),
         ( 75, 75,250),
         ( 76, 85,249),
         ( 88, 89,245),
         ( 84, 84,249),
         ( 92, 92,249),
         ( 98, 95,239),
         ( 89, 98,248),
         ( 82,118,247),
         (100,100,233),
         (107,115,235),
         (124,124,227),
         (124,125,234),
         (104,106,245),
         (100,100,249),
         (108,108,250),
         (113,111,248),
         (101,118,249),
         (116,115,250),
         (117,119,248),
         (123,123,249),
         (131,124,203),
         (134,120,234),
         (111,147,142),
         ( 96,145,151),
         (107,155,147),
         (107,164,154),
         (118,166,154),
         (112,178,145),
         ( 83,133,185),
         (121,177,169),
         (122,180,170),
         (125,201,163),
         ( 47,128,211),
         ( 52,134,216),
         ( 56,137,235),
         ( 86,140,207),
         (106,148,209),
         (118,166,217),
         (115,178,215),
         ( 82,147,234),
         (105,153,252),
         (114,146,243),
         ( 88,164,241),
         (112,172,240),
         (121,165,253),
         (130,130,130),
         (138,138,138),
         (142,142,142),
         (147,147,147),
         (155,155,155),
         (174,146,146),
         (138,175,160),
         (132,184,172),
         (134,188,179),
         (148,177,177),
         (164,164,164),
         (172,172,172),
         (174,177,178),
         (177,177,177),
         (186,186,186),
         (204,173,174),
         (215,183,184),
         (226,188,188),
         (133,197,186),
         (141,196,187),
         (146,202,181),
         (162,204,183),
         (236,212,189),
         (133,132,218),
         (147,149,211),
         (171,152,215),
         (144,175,217),
         (175,176,213),
         (132,132,228),
         (138,138,228),
         (132,131,237),
         (139,139,237),
         (144,142,235),
         (150,148,234),
         (132,131,244),
         (139,140,244),
         (131,131,249),
         (139,139,249),
         (136,149,247),
         (147,148,245),
         (148,148,251),
         (156,156,250),
         (162,158,245),
         (141,176,232),
         (134,170,251),
         (150,167,248),
         (136,184,248),
         (152,184,250),
         (175,176,230),
         (164,163,249),
         (164,170,249),
         (171,171,249),
         (165,182,247),
         (180,180,251),
         (187,187,250),
         (211,183,204),
         (196,186,239),
         (139,203,206),
         (152,203,197),
         (133,215,202),
         (153,212,202),
         (138,216,212),
         (150,220,212),
         (167,200,199),
         (165,214,203),
         (177,203,210),
         (169,217,214),
         (183,217,215),
         (141,226,211),
         (148,226,213),
         (154,231,219),
         (178,228,202),
         (166,230,219),
         (162,234,222),
         (183,229,219),
         (147,204,230),
         (139,195,251),
         (151,197,251),
         (154,204,255),
         (169,200,233),
         (176,206,234),
         (185,216,232),
         (167,201,251),
         (180,203,252),
         (168,212,252),
         (183,216,252),
         (152,234,228),
         (165,235,228),
         (172,237,226),
         (179,237,227),
         (186,233,229),
         (169,243,231),
         (182,245,235),
         (188,243,234),
         (168,234,243),
         (182,233,245),
         (184,248,243),
         (189,253,243),
         (195,195,195),
         (196,200,205),
         (203,203,203),
         (217,210,203),
         (208,204,211),
         (211,211,211),
         (217,213,217),
         (220,220,220),
         (230,199,200),
         (236,214,196),
         (239,216,193),
         (232,218,204),
         (242,220,197),
         (245,222,201),
         (230,201,211),
         (234,214,214),
         (244,217,218),
         (199,234,219),
         (213,225,223),
         (246,227,205),
         (239,227,217),
         (244,228,212),
         (248,231,209),
         (248,233,213),
         (243,231,219),
         (249,235,219),
         (199,199,231),
         (208,211,231),
         (195,195,249),
         (201,204,249),
         (198,215,250),
         (195,219,253),
         (203,220,253),
         (218,218,249),
         (233,217,230),
         (245,220,227),
         (199,234,231),
         (213,233,233),
         (195,245,236),
         (203,244,237),
         (195,249,239),
         (215,243,236),
         (200,230,251),
         (210,227,254),
         (211,234,254),
         (217,234,250),
         (203,245,245),
         (196,252,243),
         (204,253,245),
         (215,244,246),
         (211,253,246),
         (218,251,245),
         (212,254,248),
         (220,254,249),
         (227,227,227),
         (234,229,231),
         (237,237,237),
         (253,228,229),
         (245,232,229),
         (250,238,227),
         (254,235,235),
         (250,240,230),
         (250,241,234),
         (230,232,250),
         (241,238,241),
         (231,246,250),
         (228,253,252),
         (235,253,253),
         (244,244,244),
         (253,244,242),
         (251,249,246),
         (242,244,253),
         (243,252,253),
         (255,255,254),
         (  0,  0,  0))
示例#20
0
    def dibujar(self):
        glPushMatrix()

        glTranslatef(self.p[0], self.p[1], 0.0)

        #Cuerpo1
        glColor3fv(rgb(181, 18, 7))

        glBegin(GL_TRIANGLE_FAN)

        glVertex2f(0, 0)
        radio_a = 100
        radio_b = 150
        ang = 2 * np.pi / 20
        for i in range(21):
            ang_i = ang * i
            glVertex2f(np.cos(ang_i) * radio_a,  np.sin(ang_i) * radio_b)

        glEnd()

        # Cuerpo2
        glColor3fv(rgb(226, 221, 145))

        glBegin(GL_TRIANGLE_FAN)

        glVertex2f(-40, 0)
        radio_a = 70
        radio_b = 100
        ang = 2 * np.pi / 20
        for i in range(21):
            ang_i = ang * i
            glVertex2f(-40 + np.cos(ang_i) * radio_a, np.sin(ang_i) * radio_b)

        glEnd()

        #Cabeza1
        glColor3fv(rgb(181, 18, 7))

        glBegin(GL_TRIANGLE_FAN)

        glVertex2f(0, 200)
        radio = 50
        ang = 2 * np.pi / 20
        for i in range(21):
            ang_i = ang * i
            glVertex2f(np.cos(ang_i) * radio, 200 + np.sin(ang_i) * radio)

        glEnd()


        #Cabeza2
        cuadrados = [
            [[-100, 150], [-100, 180], [0, 180], [0, 150]],
            [[-100, 190], [-100, 220], [0, 220], [0, 190]]
        ]

        glBegin(GL_QUADS)
        for cuadrado in cuadrados:
            for vertice in cuadrado:
                glVertex2fv(vertice)

        glEnd()

        # Alitas2
        glColor3fv(rgb(181, 18, 7))
        glBegin(GL_TRIANGLES)
        triangulos = [
            [[40, 0], [160, 0], [100, 110]]
        ]
        for triangulo in triangulos:
            for vertice in triangulo:
                glVertex2fv(vertice)
        glEnd()

        # Alitas
        glColor3fv(rgb(226, 221, 145))
        glBegin(GL_TRIANGLES)
        triangulos = [
            [[50, 0], [150, 0], [100, 100]]
        ]
        for triangulo in triangulos:
            for vertice in triangulo:
                glVertex2fv(vertice)
        glEnd()

        glPopMatrix()
示例#21
0
    def dibujar(self):
        glPushMatrix()

        glTranslatef(self.p[0], self.p[1], 0.0)

        # Cuerpo
        glColor3fv(rgb(0,255,0))
        glBegin(GL_QUADS)
        glVertex2fv([-10, -10])
        glVertex2fv([10, -10])
        glVertex2fv([10, -40])
        glVertex2fv([-10, -40])
        glEnd()

        # Piernas
        glColor3fv(rgb(56, 32, 3))
        glBegin(GL_QUADS)
        glVertex2fv([-5, -40])
        glVertex2fv([0, -40])
        glVertex2fv([0, -60])
        glVertex2fv([-5, -60])

        glVertex2fv([3, -40])
        glVertex2fv([8, -40])
        glVertex2fv([8, -60])
        glVertex2fv([3, -60])
        glEnd()

        #Cabeza
        glColor3fv(rgb(229, 178, 117))

        glBegin(GL_TRIANGLE_FAN)

        glVertex2f(0,0)
        radio = 20
        ang = 2 * np.pi / 20
        for i in range(21):
            ang_i = ang * i
            glVertex2f( np.cos(ang_i) * radio,  np.sin(ang_i) * radio)

        glEnd()

        #Sombrero
        triangulos = [
            [[0,25], [-10,30], [-40,0]],
            [[-10,30], [-25, 25], [-40,0]],
            [[-25,25], [-50,-10], [-40,0]],
            [[0,25], [-40,0], [-20, -10]]
        ]

        glColor3fv(rgb(0,255,0))
        glBegin(GL_TRIANGLES)
        for triangulo in triangulos:
            for vertice in triangulo:
                glVertex2fv(vertice)

        glEnd()



        glPopMatrix()
示例#22
0
    if file_extension in ['jpg', 'png']:
        # process image
        # Instantiate detector
        vehicle_detector = Vehicle_pipeline(classifier, feature_parameters,
                                            window_shape, scaler,
                                            heat_threshold)

        print('Loading ' + input_file + ' as a ' +
              feature_parameters['cspace'] + ' image')
        img = read_image(input_file, feature_parameters['cspace'])
        output_to_file = output_file and len(output_file)

        print('Detecting vehicles')
        boxes = vehicle_detector(img, show_plots=False)
        print(boxes)
        output = draw_boxes(rgb(img, feature_parameters['cspace']), boxes)

        if output_to_file:
            print('Writing output to ' + output_file)
            write_image(output_file, output, 'RGB')
        else:
            plt.figure()
            plt.title(input_file)
            plt.imshow(output)
            plt.show()
    elif file_extension in ['mp4']:
        # process video
        vehicle_detector = Vehicle_pipeline(classifier,
                                            feature_parameters,
                                            window_shape,
                                            scaler,
示例#23
0
文件: main.py 项目: SilviuDinu/tfam
import shutil
import csv
import time
import math
import sys
from PIL import Image
import cv2
from os.path import abspath
from utils import build_scaled, crop, rgb, dbc

curr = os.path.dirname(__file__)

images_in = os.path.join(curr, r'data/image-data/imagini')
images_out = os.path.join(curr, r'data/image-data/images/resized')

build_scaled(images_in, images_out)

# ---------------------------------------------------------------------

images_in = images_out
images_out = os.path.join(curr, r'data/image-data/images/cropped')

crop(images_in, images_out)

# ---------------------------------------------------------------------

images_in = images_out
images_out = os.path.join(curr, r'data/image-data/images/rgb/')

rgb(images_in, images_out)