Dtt
A C++ header-only for data transfer between linear algebra libraries (Eigen, Armadillo, OpenCV, ArrayFire, LibTorch).
Install / Use
/learn @andrewssobral/DttREADME
Data Transfer Tools for C++ Linear Algebra Libraries.
dtt is a lightweight, header-only C++ library designed to seamlessly transfer matrix and array data between major linear-algebra libraries. It supports Eigen, Armadillo, OpenCV (cv::Mat), ArrayFire, and LibTorch (PyTorch C++), offering simple one-call conversion functions in every direction (e.g., eigen2arma, cv2af, libtorch2eigen, etc.). The library requires only C++17 and no build step—just include dtt.h. It’s primarily a convenience layer that removes the need for manual data-format juggling when working across heterogeneous numerical libraries, and includes tests and example usage in the test/ directory.
Currently, it supports data transfer between the following libraries:
- Eigen (>=3.3.x)
- Armadillo (>=9.x)
- OpenCV (cv::Mat) (2.x, 3.x, 4.x)
- ArrayFire (>=3.x)
- LibTorch (PyTorch C++) (>=1.x)
Current status:
Last page update: 25/08/2019
| From/To | Eigen | Armadillo | OpenCV | ArrayFire | LibTorch | |-----------|:-----:|:---------:|:------:|:---------:|:--------:| | Eigen | - | X | X | X | X | | Armadillo | X | - | X | X | X | | OpenCV | X | X | - | X | X | | ArrayFire | X | X | X | - | X | | LibTorch | X | X | X | X | - |
Tested on:
- MacBook Pro (13-inch, 2017)
- Mac OS X Mojave (10.14.5), Clang 10 (clang-1000.11.45.5), Xcode 10.1 with the following libraries:
-
- OpenCV 4.1.1 (stable, built from source)
-
- Eigen 3.3.7 (stable)
-
- Armadillo 9.600.5 (stable)
-
- ArrayFire 3.6.4 (stable)
-
- LibTorch (1.3.0.dev20190820)
Install dependencies:
brew install eigen
brew install armadillo
# download and install ArrayFire: https://arrayfire.com/download/
# download and install LibTorch: https://pytorch.org/get-started/locally/
# download adn install OpenCV: https://opencv.org/releases/
How to compile and run:
git clone https://github.com/andrewssobral/dtt.git
cd dtt && mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=$LIBTORCH_HOME ..
./dtt_test
How to use:
#include <dtt.h>
using namespace dtt;
// that's all!
List of available functions:
-
From Eigen:
-
- eigen2arma
-
- eigen2cv
-
- eigen2af
-
- eigen2libtorch
-
From Armadillo:
-
- arma2eigen
-
- arma2cv
-
- arma2af
-
- arma2libtorch
-
From OpenCV:
-
- cv2eigen
-
- cv2arma
-
- cv2af
-
- cv2libtorch
-
From ArrayFire:
-
- af2eigen
-
- af2arma
-
- af2cv
-
- af2libtorch
-
From LibTorch:
-
- libtorch2eigen
-
- libtorch2arma
-
- libtorch2cv
-
- libtorch2af
See test/dtt_test.h and test/dtt_test.cpp for usage examples.
Related Skills
node-connect
339.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
