Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

blackfly-gige-viewer

A minimal C++ example that streams live video from a FLIR Blackfly GigE camera using the Spinnaker SDK and displays it with OpenCV.

Tested Environment

Ubuntu GCC CMake OpenCV Spinnaker spdlog fmt C++17 License

Features

  • Auto-discovery and connection of GigE Vision cameras via Spinnaker SDK
  • Automatic detection of color (BGR8) and mono (Mono8) cameras
  • Real-time FPS measurement and logging
  • Persistent IP configuration (--set-ip)
  • Camera selection by serial number

Requirements

Dependency Tested Version Notes
OS Ubuntu 22.04 (x86_64) Other Linux distros may work if Spinnaker SDK supports them
CMake 3.30.5 Minimum 3.16 (per CMakeLists.txt)
C++ Compiler GCC 11.4.0 C++17 required
Spinnaker SDK 4.3.0.189 Download from FLIR/Teledyne website
OpenCV 4.5.4 apt install libopencv-dev
spdlog 1.10.0 Source build or apt install libspdlog-dev
fmt 8.1.1 apt install libfmt-dev

1. Install Dependencies

Spinnaker SDK

Download Spinnaker SDK for Linux from the FLIR website: https://www.flir.com/products/spinnaker-sdk/

# Install downloaded .deb package (example)
sudo dpkg -i spinnaker-<version>_amd64.deb
sudo apt-get install -f

# Or extract tar.gz to /opt/spinnaker
# Default expected path: /opt/spinnaker

Note: After installation, /opt/spinnaker/include/Spinnaker.h must exist.

OpenCV, spdlog, fmt

sudo apt update
sudo apt install -y libopencv-dev libfmt-dev libspdlog-dev

If building spdlog from source:

git clone https://github.com/gabime/spdlog.git
cd spdlog && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/spdlog
make -j$(nproc) && sudo make install

GigE Camera Network Setup

Jumbo frames are recommended for GigE Vision cameras:

# Check your network interface name
ip link show

# Enable jumbo frames (e.g., for eno1)
sudo ip link set eno1 mtu 9000

# Make it persistent (add mtu 9000 in /etc/netplan/ or /etc/network/interfaces)

Increase the receive buffer size:

sudo sysctl -w net.core.rmem_max=10485760
sudo sysctl -w net.core.rmem_default=10485760

# Make it persistent
echo "net.core.rmem_max=10485760" | sudo tee -a /etc/sysctl.conf
echo "net.core.rmem_default=10485760" | sudo tee -a /etc/sysctl.conf

2. Build

git clone https://github.com/warhammer50K/blackfly-gige-viewer.git
cd blackfly-gige-viewer
mkdir build && cd build

# Default build (Spinnaker: /opt/spinnaker, spdlog: /opt/spdlog)
cmake ..
make -j$(nproc)

# Specify custom spdlog path
cmake -DSPDLOG_INCLUDE_DIR=/path/to/spdlog/include ..
make -j$(nproc)

3. Run

# Use the first detected camera
./bfly_test

# Select a specific camera by serial number
./bfly_test 12345678

# Set persistent IP on the camera (192.168.1.30)
./bfly_test --set-ip

# Set persistent IP on a specific camera
./bfly_test --set-ip 12345678

Controls

Key Action
q / ESC Quit
Ctrl+C Quit (signal)

4. Changing the Persistent IP

Edit the default values in set_persistent_ip() in main.cpp:

constexpr int64_t NEW_IP   = ip_to_int(192, 168, 1, 30);
constexpr int64_t NEW_MASK = ip_to_int(255, 255, 255, 0);
constexpr int64_t NEW_GW   = ip_to_int(192, 168, 1, 1);

Project Structure

bfly_test/
├── CMakeLists.txt   # Build configuration
├── main.cpp         # Main source code
└── README.md        # This file

Troubleshooting

  • "No cameras found": Ensure the camera and PC are on the same subnet. Test with SpinView first.
  • Frame drops / Incomplete image: Check jumbo frame (MTU 9000) and receive buffer size settings.
  • Permission errors: To run without sudo, copy the udev rules provided by the Spinnaker installer to /etc/udev/rules.d/.

License

This project's source code is licensed under the MIT License.

This project depends on the following libraries, each with its own license:

Library License
Spinnaker SDK FLIR/Teledyne proprietary (must be downloaded separately)
OpenCV Apache 2.0
spdlog MIT
fmt MIT (with optional exception)

About

FLIR Blackfly GigE camera viewer using Spinnaker SDK, OpenCV, and spdlog (C++17)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages