valrik
Posts: 28
Joined: Mon May 26, 2014 1:55 pm

faster camera

Fri Sep 19, 2014 4:12 pm

hi

I have use the picamera python library with SimpleCV and used it like this:

Code: Select all

import time
import io
import picamera
import picamera.array
import cv2
from SimpleCV import Image, Display, Color

with picamera.PiCamera() as camera:
        my_stream = io.BytesIO()
        camera.resolution = (320,240)
        camera.start_preview()
        d = Display()
        
        while not d.isDone():
                with picamera.array.PiRGBArray(camera) as stream:
                        camera.capture(stream, format='rgb')

                        img = Image( stream.array ).rotate90()
                        faces = img.findHaarFeatures('face')
                        if faces is not None:
                                
                                faces = faces.sortArea()
                                bigFace = faces[-1]
                                bigFace.draw(width=1)

                        img.save(d)
This was faster than saving to an image then reloading it. Needed to rotate it so it was the right way round though. Anyway, at this resolution it still seems rather slow. I know the face detection is slowing it down of course but i was wondering if anyone knew a way i can speed any of this up?

Return to “Python”