the C++ version of sim2video_matlab