コード例 #1
0
def captureImage(live):
    #Capture the image
    
    ledborg.setColour(ledborg.WHITE)
    camera.release()
    camera.open(0)
            
    #Set image dimensions. v4l and your webcam must support this
    camera.set(cv.CV_CAP_PROP_FRAME_WIDTH, 320)
    camera.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 240)
            
    status, image = camera.read()
    
    ledborg.setColour(ledborg.OFF)
    
    if (live):            
        text = "PiPurr " + datetime.now().strftime("%H:%M:%S %a %d %b")
    else:
        text = "A woo! " + datetime.now().strftime("%H:%M:%S %a %d %b")
        
    textcolour = (150, 150, 200)
            
    cv2.putText(image, text, (2,20), cv2.FONT_HERSHEY_PLAIN, 1.0, textcolour)
    st, imagebuffer = cv2.imencode(".jpg", image)
    
    return (status, imagebuffer)
コード例 #2
0
# PiPurrServer.py - PiPurr server module.
#
#   Allows remote interaction with your cats.
#
#   Contains code from piborg.org
#
#   Tris Linnell
#       http://canthack.org

import ledborg
import RPi.GPIO as GPIO
GPIO.setwarnings(False)

if __name__ == "__main__":
    print "Initialising..."
    ledborg.setColour(ledborg.YELLOW)

import cv2
import cv
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import os
from datetime import datetime
import time
import pygame
import feeder

GPIO.setmode(GPIO.BCM)
PIR_PIN = 14
GPIO.setup(PIR_PIN, GPIO.IN)

PORT_NUMBER = 8081