Jan-31-2018, 05:31 PM
I was trying to show a live video recording someone with a effect that shows, all the time, the silhouettes in different colors and the background in black.
-I'm using a raspberry pi 2
-using a USB camera
-as plus i wanna use buttons to change the color of the silhouettes
i get to show the video but i dont know what can i do to get the effect, i am new using python, may be u find extra lines or maybe u can tell me if it is better to use the picamera instead the usb camera and which.
[Image: ?kh=-1&uddg=http%3A%2F%2Fshmector.com%2F...715168.png]
-I'm using a raspberry pi 2
-using a USB camera
-as plus i wanna use buttons to change the color of the silhouettes
i get to show the video but i dont know what can i do to get the effect, i am new using python, may be u find extra lines or maybe u can tell me if it is better to use the picamera instead the usb camera and which.
#!/usr/bin/env python # encoding: latin1 import pygame, sys, time import pygame.camera from pygame.locals import * pygame.init() pygame.camera.init() dw=1318 dh=736 colortexto=(0,12,0) blanco = (255,255,255) black= (0,0,0) rojo = (250, 0, 0) rojox =(255, 77, 77) azul = (0, 255, 255) azulx =(128, 255, 255) verde= (0, 255, 0) verdex=(102, 255, 102) amarillo=(255, 255, 0) amarillox=(255, 255, 128) morado=(153, 51, 255) moradox=(255, 102, 171) rosa=(255, 0, 85) rosax=(255, 102, 153) gameDisplay = pygame.display.set_mode((dw, dh)) screen = pygame.display.set_mode((dw, dh)) pygame.display.set_caption("CEM'S\'") clock = pygame.time.Clock() cam= pygame.camera.Camera("/dev/video0",(1250,600)) cam.start() def text_objects(text, font): textSurface = font.render(text, True, colortexto) return textSurface, textSurface.get_rect() def button(msg,x,y,w,h,ic,ac,action=None): mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() #print(click) if x+w > mouse[0] > x and y+h > mouse[1] > y: pygame.draw.rect(gameDisplay, ac,(x,y,w,h)) if click[0] == 1 and action != None: action() else: pygame.draw.rect(gameDisplay, ic,(x,y,w,h)) smallText = pygame.font.SysFont("comicsansms",20) textSurf, textRect = text_objects(msg, smallText) textRect.center = ( (x+(w/2)), (y+(h/2)) ) gameDisplay.blit(textSurf, textRect) def main(): while 1: image = cam.get_image() screen.blit(image,(20,0)) #### pygame.display.update() button("Rosa", 104,626,150,50, rosa,rosax) button("Morado", 264,626,150,50, morado,moradox) button("Blanco", 424,626,150,50, blanco,blanco) button("Amarillo", 584,626,150,50, amarillo,amarillox) button("Rojo", 744,626,150,50, rojo,rojox) button("Azul", 904,626,150,50, azul,azulx) button("verde", 1064,626,150,50, verde,verdex) for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() pygame.display.update() clock.tick(15) main() pygame.quit() quit()i want something like this
[Image: ?kh=-1&uddg=http%3A%2F%2Fshmector.com%2F...715168.png]