pseyepy is a lightweight, cross-platform, and open-source Python interface to the Playstation PS3Eye USB camera. Its core is a wrapper of a C API that derives from the excellent PS3EYEDriver project.
At this point, the dependencies for the project are:
The important features are:
Contributions are greatly appreciated!
Installation has not yet been thoroughly tested on all platforms. Eventually I will get around to enabling a pip install. For now:
sudo python setup.py install
If that does not work, it's likely a libusb issue. Try adjusting paths such that libusb paths are included by default.
Basic usage:
from pseyepy import Camera
# initialize all connected cameras
c = Camera()
# read from the camera/s
frame, timestamp = c.read()
# when finished, close the camera
c.end()
You may specify specific camera/s:
c = Camera(0) # camera at index 0
c = Camera([0,1]) # cameras at indices 0 and 1
Set initialization parameters for your camera/s:
c = Camera([0,1], fps=60, resolution=Camera.RES_LARGE, colour=False)
Note that frame rate, resolution, and colour are the 3 parameters that cannot be changed after initializing.
Set initialization parameters for each camera independently:
c = Camera([0,1], fps=[30, 60], resolution=[Camera.RES_LARGE, Camera.RES_SMALL], colour=[True, False])
Set mutable image acquisition parameters upon initialization:
c = Camera(fps=30, colour=[False,True], gain=50, vflip=[True, False])
The mutable parameters include gain, exposure, whitebalance, vflip, hflip. See docstring for full details.
Set parameters after initialization:
c.exposure = 23
For each camera independently:
c.exposure[0] = 23
c.exposure[1] = 45
Read from all cameras:
frames, timestamps = c.read()
Read from a specific camera:
frame1, timestamp1 = c.read(1) # read from camera at index 1
Live display of camera feed with parameter controls:
from pseyepy import Camera, Display
c = Camera() # initialize a camera
d = Display(c) # begin the display
Stream camera data to a file using ffmpeg:
from pseyepy import Camera, Stream
c = Camera() # initialize a camera
s = Stream(c, file_name='example_movie.avi', codec='png') # begin saving data to files
# when finished, close the stream
s.end()
Stream to file while also displaying (beta):
s = Stream(c, file_name='example_movie.avi', display=True)
# when finished, close the stream
s.end()
sudo apt-get install libusb-1.0-0-dev
or, if in a conda environment, with conda install -c conda-forge libusb