dVRK endoscope setup (SurGLab) - gkgkgk1215/else GitHub Wiki

  • Model: Decklink Mini Recorder 4K (Blackmagicdesign)
  • Model: Decklink Duo 2, S/N=14595831
  • Official Webpage: https://www.blackmagicdesign.com/
  • The driver 12.4 was tested in Ubuntu 20.04
  • The latest driver 16.0 was tested in Ubuntu 24.04 (Kernel 6.17)

Install Linux Driver

  • Support--Capture and Playback--Type model(DeckLink Mini Recorder 4K, S/N=13179157, 13178882)
  • Download the driver and extract (Blackmagic_Desktop_Video_Linux_12.4.tar)
sudo apt update
sudo apt install dkms linux-headers-$(uname -r) build-essential
cd ~/Downloads/Blackmagic_Desktop_Video_Linux_12.4/deb/x86_64
cd ~/Downloads/Blackmagic_Desktop_Video_Linux_16.0/deb/x86_64
sudo dpkg -i *

Update the software (if needed)

  • Checking if the update is required
sudo DesktopVideoUpdateTool -l
  • Update all devices
sudo DesktopVideoUpdateTool --update --all

Desktop Video Setup (for Decklink Duo 2 only)

  • Start-up menu -- Blackmagic Desktop Video Setup
  • For each DeckLink Duo(i), Menu--Connectors--SDI(i) (not SDI1&SDI2 or SDI3&SDI4)

Check Video Streaming

  • Start-up menu -- MediaExpress
  • Check device numbers that is matched with the source

Install SDK (just for simple tests)

  • (IMPORTANT) "SDK Version" should be same as "Driver Version"
  • Developer--Desktop--SDK and Software--SDK--Download
  • Download the driver and extract (Blackmagic_DeckLink_SDK_12.4.2.zip or Blackmagic_DeckLink_SDK_16.0.zip)
  • Compile and check the list of device:
cd ~/Downloads/Blackmagic_DeckLink_SDK_12.4.2/Blackmagic\ DeckLink\ SDK\ 12.4.2/Linux/Samples/
cd ~/Downloads/Blackmagic_DeckLink_SDK_16.0/Blackmagic\ DeckLink\ SDK\ 16.0/Linux/Samples/
make
  • Test Device
cd ~/Downloads/Blackmagic_DeckLink_SDK_12.4.2/Blackmagic\ DeckLink\ SDK\ 12.4.2/Linux/Samples/bin/x86_64
cd ~/Downloads/Blackmagic_DeckLink_SDK_16.0/Blackmagic\ DeckLink\ SDK\ 16.0/Linux/Samples/bin/x86_64
./DeviceList
./Capture -d 0 -m -1
./CaptureStills -d 0 -m -1 -n 10 -i 60 ~/Pictures/

or

dmesg | grep -i black
ls /dev/blackmagic
  • You can quickly test the frame grabber using MediaExpress which should be installed along the drivers. You can also select the video input using BlackmagicDesktopVideoSetup (also installed along drivers).

  • Check in the "MediaExpress" that you see the image streaming. Change the source and check the images are properly showing.

  • If only one source is working, debug using ffmpeg. In my case, the issue was fixed while installing 'nasm' and the following dependencies: (debugging with GPT was really helpful)

sudo apt update
sudo apt install nasm

and

sudo apt install yasm pkg-config libavdevice-dev libavfilter-dev libavformat-dev \
libswscale-dev libavcodec-dev libavutil-dev libfreetype6-dev

gstreamer

  • To test if the drivers are working and the cards are working, use gstreamer 1.0 or greater. You will also need the proper gstreamer plugins installed:
sudo apt install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
  • Once gstreamer is installed, you can use a few command lines to test the drivers:

gst-inspect-1.0 decklinkvideosrc will show you the different parameters for the DeckLink gstreamer plugin

gst-launch-1.0 can be used to launch the streamer and pipe it to see the video live on the computer.

For example, we used gst-launch-1.0 -v decklinkvideosrc mode=0 connection=sdi device-number=0 ! videoconvert ! autovideosink.

mode=0 is for auto-detection and is optional

connection=sdi is to force to use an SDI input if your card has different types of inputs. This is optional.

device-number=0 is to select which input to use if you have multiple inputs

On a DeckLink Duo, we found that one can see the stereo video using two text terminals:

gst-launch-1.0 decklinkvideosrc device-number=0 ! videoconvert ! autovideosink
gst-launch-1.0 decklinkvideosrc device-number=2 ! videoconvert ! autovideosink

ROS package: gscam

  • Install packages:
sudo apt update
sudo apt install ros-noetic-image-transport ros-noetic-camera-info-manager gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
  • Clone gscam from repo:
cd ~/catkin_ws/src
git clone https://github.com/hap1961/gscam.git
cd ~/catkin_ws/src/gscam
git checkout noetic-devel

cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -r -y
catkin build
  • Run using dvrk_video package
source ~/catkin_ws/devel/setup.bash
roslaunch dvrk_video gscam_decklink.launch
or
roslaunch dvrk_video gscam_decklink_stereo.launch stereo_rig_name:=dvrk
or
roslaunch dvrk_video decklink_stereo_goovis.launch stereo_rig_name:=dvrk

In another terminal you can check the image using:

rosrun image_view image_view image:=/dvrk/left/image_raw
or
rosrun rqt_image_view rqt_image_view

ROS2 package: gscam is not working

  • You will need to make your own ROS2 GStreamer node.