Little hack for C++ function replacement in OpenCV

This is a small post on using shared library preloading for replacing a C++ function by another for filtering the OpenCV behavior. In particular we are disabling imshow.

The trick is based on LD_PRELOAD plus dlsym, and it needs to be customized by function lookup due to C++ mangling


#include <opencv2/opencv.hpp>

int main(int argc, char const *argv[])
 auto p = cv::imread(argv[1],0);
 return 0;

The source code can be found:

Note that for building this example uses cmakego


Popular posts from this blog

Docker for our ROS robotic overlords

cmakego: Simpler access to external libraries in CMake

Algebrical Data Types in C++