There are many ways to improve this little program and make it more general, such as using the ROS CV Bridge, but there is some value in showing just how simple it is to take images from some other framework (in this case, OpenCV), manually populate the sensor_msgs::Image fields, and publish messages to ROS. All using a standalone Makefile, thanks to the pkg-config files from the ROS packages.
Btw, the -l: issue that we're now working around has been known for a while to be a problem for people using ROS packages via pkg-config. Start reading here for a summary of where we stand now and why it's a tricky problem.
There are many ways to improve this little program and make it more general, such as using the ROS CV Bridge, but there is some value in showing just how simple it is to take images from some other framework (in this case, OpenCV), manually populate the sensor_msgs::Image fields, and publish messages to ROS. All using a standalone Makefile, thanks to the pkg-config files from the ROS packages.