Skip to content

soswow/PS3Eye-library

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PS3 Eye Driver (macOS + libusb)

This repo contains a small PS3 Eye camera library plus a CLI tool for capture/preview. It was made based on madalintat/PS3Eye-Driver-MacOS-Silicon work. The goal was to make it compile and function on latest MacOS.

Contents

  • include/ps3eye_lib.h: public API
  • src/ps3eye_lib.cpp: libusb-based camera implementation
  • src/ps3eye_cli.cpp: CLI wrapper (OpenCV preview, capture options)
  • scripts/: helper scripts

Requirements

  • CMake 3.16+
  • A C++17 compiler (clang++ or g++)
  • libusb-1.0 (via pkg-config)
  • OpenCV 4 (only if building the CLI)
  • Python 3 + pybind11 (only if building the Python module)
  • NumPy (required for Frame.to_numpy() and OpenCV usage)

Build

Default builds the library and the CLI:

cmake -S . -B build
cmake --build build

Library-only build (no OpenCV needed):

cmake -S . -B build -DBUILD_CAPTURE=OFF
cmake --build build

Python module build (requires pybind11):

python -m pip install pybind11 numpy
cmake -S . -B build -DBUILD_PYTHON=ON -DCMAKE_PREFIX_PATH="$(python -m pybind11 --cmakedir)"
# add following if using venv
# -DPython_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" 
cmake --build build

Run

On macOS, USB capture typically requires sudo (or a signed app with USB entitlements).

sudo ./build/ps3eye_cli --format raw

CLI options

--list-devices           List detected PS3 Eye devices
--format <raw|debayer>   Display mode (default: debayer)
--device <index>         Device index (default: 0)
--size <qvga|vga>        Frame size (default: qvga)
--fps <n>                Frame rate hint (default: 30)
--manual                 Disable auto gain/exposure/white balance
--gain <0-63>            Manual gain value (used with --manual)
--exposure <0-255>       Manual exposure value (used with --manual)
--ui-controls            Show UI sliders for gain/exposure
--no-fps-overlay         Disable FPS overlay
--save-raw <dir>         Save raw frames to directory
--duration <sec>         Duration for --save-raw (default: 5)
--no-save-config         Do not read/write saved settings
--help                   Show this help message

Notes

  • The library uses libusb bulk transfers and outputs RAW8 or BGR24 (debayered) frames.
  • The CLI is meant for testing and diagnostics; for integrations, use the library API.
  • The CLI saves settings to ~/.config/ps3eye_cli.json on exit unless --no-save-config is set.

Quick test

CLI device listing:

sudo ./build/ps3eye_cli --list-devices

Capture a single frame via Python and save to disk:

import ps3eye
import cv2

with ps3eye.Device(0) as dev:
    dev.configure(width=640, height=480, fps=30, format="bgr")
    dev.set_auto(True)
    dev.start_stream(queue_size=2)

    frame = dev.read(timeout_ms=1000)
    if frame is not None:
        img = frame.to_numpy(copy=False)
        cv2.imwrite("ps3eye_test.png", img)

    dev.stop_stream()

Python usage (OpenCV)

After building, ensure the module is on PYTHONPATH (for example, run from the build/ directory or add it to PYTHONPATH).

Example using OpenCV:

import ps3eye
import numpy as np
import cv2

with ps3eye.Device(0) as dev:
    dev.configure(width=640, height=480, fps=30, format="bgr")
    dev.set_auto(True)
    dev.start_stream(queue_size=2)

    while True:
        frame = dev.read(timeout_ms=1000)
        if frame is None:
            continue
        img = frame.to_numpy(copy=False)
        cv2.imshow("ps3eye", img)
        if cv2.waitKey(1) & 0xFF == 27:
            break

    dev.stop_stream()

About

PS3 Eye camera library and CLI for macOS using libusb, with RAW/debayered capture, configurable settings, and OpenCV preview.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 96.3%
  • C 1.6%
  • CMake 1.5%
  • Shell 0.6%