Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 47 lines (35 sloc) 0.975 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/usr/bin/python

import Image, ImageDraw, ImageFont
import opencv
from opencv import highgui
import pygame
from datetime import datetime
import time
import os
import sys

outfile = "/home/agrover/Desktop/camera.jpg"
prevent_file = "/home/agrover/cam_ok"
warning_sound = "/home/agrover/git/pysnapper/4321.wav"
scp_path = "ca-server1:public_html"

font = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
font_size = 24

try:
    os.stat(prevent_file)
except OSError:
    sys.exit(-1)

pygame.init()
sound = pygame.mixer.Sound(warning_sound)
sound.set_volume(0.4)
sound.play()
time.sleep(4)

camera = highgui.cvCreateCameraCapture(0)
ipl = highgui.cvQueryFrame(camera)
im = opencv.adaptors.Ipl2PIL(ipl)

now = datetime.now()
date_str = now.ctime()

draw = ImageDraw.Draw(im)
draw_font = ImageFont.truetype(font, font_size)
draw.text((10,10), date_str, font=draw_font)

im.save(outfile, "JPEG")

highgui.cvReleaseCapture(camera)

os.system("scp %s %s" % (outfile, scp_path))
Something went wrong with that request. Please try again.