"laser graffiti" ist die (mir nicht eigene) Idee, die Projektion eines Projektors mit einer Videokamera zu erfassen und darauf erfasste Laserreflexionen in Pinselstriche umzuwandeln (und zu projizieren). So kann man mit einem Laserpointer auf Hauswänden "malen". (Es gibt ein paar schöne Videos bei DuRohr.com)
Eine "Billigversion" in Python mit der Hilfe von "motion":
Das Programm "motion" (http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome) kann in erfassten Bildern Pixeländerungen erkennen. Mit den folgenden Angaben (in ~/motion.conf)
Code: Alles auswählen
# Target base directory for pictures and films
# Recommended to use absolute path. (Default: current working directory)
target_dir /home/....../pics/
# Output pictures with only the pixels moving object (ghost images) (default: off)
output_motion on
# %K and %L = X and Y coordinates of motion center
jpeg_filename motionCaps%H%M%S_%q__%K_%L
Ich habe folgendes zusammengefrickelt, um die Positionen auszulesen und per pygame zu "malen":
Code: Alles auswählen
import pygame
from glob import glob
from os import system
picturePath="./pics/motionCap*.jpg"
def drawMyCircle(window,center):
"""draws a white circle on 'window' at position 'center' with size 3"""
pygame.draw.circle(window, (255, 255, 255),center,3)
pygame.display.flip()
def calcCenterList(filelist):
"""receives positions of movement by parsing all filenames in 'filelist'
returns a list of positions
ATTENTION: removes all files in 'filelist' from disc!!!"""
centers=[]
if (filelist!=[]):
for i in filelist:
newx=int(i.split("_")[3])
newy=int(i.split("_")[4].split("m")[0])
centers.append((newx,newy))
system("rm "+i+" &")
return centers
if __name__=="__main__":
pygame.init()
window = pygame.display.set_mode((640, 480))
while True:
filelist=glob(picturePath)
centers=calcCenterList(filelist)
for i in centers:
drawMyCircle(window,i)
Vielleicht hat ja einer von Euch Lust, das Programm zu testen.
Obwohl "rm" nur ausgeführt wird, wenn filelist nicht leer ist, meldet das Betriebssystem manchmal: "rm: kann file nicht löschen, da nicht vorhanden". Das verstehe ich nicht, wie das sein kann.
Irgendwelche Kommentare zum Code?
Liebe Grüße, Nko