Skip to content

Latest commit

 

History

History
133 lines (121 loc) · 4.45 KB

README.md

File metadata and controls

133 lines (121 loc) · 4.45 KB

campy

  • Python package for streaming video from multiple cameras to disk.
  • Features real-time hardware-accelerated video compression and debayering using FFmpeg.

Hardware/software

Installation

  1. Update graphics drivers
  2. Create and activate a new Python 3.7 Anaconda environment:
conda create -n campy python=3.7 imageio-ffmpeg matplotlib -c conda-forge
conda activate campy
pip install -U setuptools
  1. Install camera software
  • If using Basler cameras, install Pylon software:

    • Install Basler Pylon with Developer options
    • Install pypylon: Windows:
    pip install pypylon
    

    Linux:

    conda install swig
    git clone https://github.com/basler/pypylon.git
    python ./pypylon/setup.py install
    
  • If using FLIR cameras:

    pip3 install <wheel>
    
  1. Clone or download campy to local folder:
git clone https://github.com/ksseverson57/campy.git
  1. Finally, install campy and its dependencies (see setup.py) by navigating to campy folder:
pip install -e .

Usage

Configuration

  • For Basler cameras, use the Pylon Viewer to save your '.pfs' camera settings file. Examples are included in campy/cameras/basler/settings.
  • Edit the config.yaml file to fit your system and recording configuration.
  • Several example config files are located in campy/configs.
  • For help setting config parameters:
campy-acquire --help

Camera Triggering

Campy's trigger module supports Arduino and Teensy microcontrollers:

  1. Download Arduino IDE (https://www.arduino.cc/en/software). If using Teensy, install Teensyduino (https://www.pjrc.com/teensy/teensyduino.html).
  2. Connect your microcontroller and note its port number (e.g. "COM3" on Windows or "/dev/ttyACM0" on Linux).
  3. In your config.yaml, configure:
startArduino: True 
digitalPins: [<pin IDs>] # e.g. [0,1,2]
serialPort: "<port>" # e.g. "COM3" or "/dev/ttyACM0"
  1. Open and upload "trigger.ino" file (in campy/trigger folder) to your board. Make sure serial monitor is closed while using pyserial connection.
  2. Campy will synchronously trigger the cameras once acquisition begins.

Start Recording:

campy-acquire ./configs/campy_config.yaml

Stop Recording:

  • Campy will stop automatically after set recording time (e.g. 1 hour):
recTimeInSeconds: 3600
  • To manually end, press Ctrl^C. Wait until campy exits.
  • Three files, "frametimes.mat", "frametimes.npy", and "metadata.csv", will be saved along with the video file in each camera folder containing timestamps, frame numbers, and other recording metadata.

Helpful tips

  • To debug broken pipe error, include this in config.yaml:
ffmpegLogLevel: "warning"
  • Use the command "ffmpeg" to check enabled packages
  • On Linux, you may need to compile your own ffmpeg binary to enable encoders:
  • Nvidia:
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
  • Intel:
sudo apt-get install libva-dev libmfx-dev libx264-dev libx264-dev libnuma-dev
  • AMD:
git clone https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git
sudo cp -r ./AMF/amf/public/include/core /usr/include/AMF
sudo cp -r ./AMF/amf/public/include/components /usr/include/AMF
  • Compile ffmpeg:
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
sudo ./configure \
--enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc --enable-nonfree --enable-libnpp \
--extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 \
--enable-gpl --enable-libx264 --enable-libx265 --enable-libmfx \
--enable-amf
sudo make -j -s
sudo cp -r ./ffmpeg /usr/bin
  • Include in config.yaml:
ffmpegPath: "/usr/bin/ffmpeg"

Authors

Written by Kyle Severson with contributions from Diego Aldarondo and Iris Odstrcil (2019-2021).

Credits

Special thanks to Tim Dunn, David Hildebrand, Vincent Prevosto, Manuel Levy, and Paul Thompson for helpful comments.

License

MIT License