This project provides a C++ library for interfacing with the MI48 thermal imaging sensor, processing thermal data, and visualizing it. The library can be built as both static and shared libraries for easy integration into other applications.
This is a C++ alternative to Python MeridianInnovation PySenxor
- Hardware:
- MI48 thermal imaging sensor
- Optional: USB webcam for visual input
- Software:
- C++ compiler (g++ with C++17 support)
- OpenCV 4.x
- libserialport
- POSIX-compliant system for serial port operations
# Build the library (creates DEBUG build by default)
./build.sh
# Or build in RELEASE mode
./build.sh RELEASE
# Install to $HOME/.local
./install.sh
# Uninstall if needed
./uninstall.shmkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
make
make installAfter building, you'll find in build/bin/:
libmi48.a- Static librarylibmi48.so- Shared library
After installation (default: $HOME/.local):
- Libraries:
$HOME/.local/lib/libmi48.{a,so} - Headers:
$HOME/.local/include/{serial_mi48.hpp,thermal_visualization.hpp,version.hpp} - CMake config:
$HOME/.local/lib/cmake/mi48/
# Find the installed mi48 library
find_package(mi48 REQUIRED PATHS $ENV{HOME}/.local/lib/cmake/mi48)
add_executable(your_app your_app.cpp)
# Link against the static library
target_link_libraries(your_app PRIVATE mi48::mi48_static serialport)
# Or link against the shared library
# target_link_libraries(your_app PRIVATE mi48::mi48_shared serialport)# Compile with static library
g++ -std=c++17 your_app.cpp \
-I$HOME/.local/include \
-L$HOME/.local/lib \
-lmi48 -lserialport \
`pkg-config --cflags --libs opencv4` \
-o your_app#include "serial_mi48.hpp"
#include <iostream>
int main() {
SerialCommandSender camera;
// Register callback for frame data
camera.register_frame_callback([](const std::vector<float>& temps, uint16_t rows, uint16_t cols) {
std::cout << "Received frame: " << rows << "x" << cols << std::endl;
// Process temperature data here
});
// Open connection
if (!camera.open_port("/dev/ttyACM0")) {
std::cerr << "Failed to open port" << std::endl;
return 1;
}
// Start streaming
if (camera.start_stream(true)) {
std::cout << "Streaming started..." << std::endl;
camera.loop_on_read(); // Blocks until stop_loop() is called
}
return 0;
}-
Clone the repository:
git clone https://github.com/HefnySco/mi48dx-serial-driver.git cd mi48dx-serial-driver -
Build and install:
./build.sh # Build the library ./install.sh # Install to $HOME/.local
If you want to install to a different location:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/your/custom/path ..
make
make installTo remove the installed library:
./uninstall.shSee examples/README.md for detailed example programs.
The library provides the following main classes and functions:
SerialCommandSender- Main class for camera communication- Frame callback mechanism for real-time data processing
- Register read/write functions for camera configuration
- Streaming control functions
- Version: 2.0.0
- Use
SerialCommandSender::get_version()to get runtime version info.
- The library installs to
$HOME/.localby default (no sudo required) - Make sure
$HOME/.local/libis in your library path - CMake will automatically find the library if installed to
$HOME/.local - Dependencies: OpenCV 4.x and libserialport must be installed on your system
