Looking at the code, you are trying to provide a callback by specifying
serializerParams.onData = save; // original code this is a nullptr
The main problem is, you are not calling
dwSensorSerializer_initialize(&serializer, &serializerParams, cameraSensor);
therefore, the callback is not going to be registered.
However, for the purpose of saving an image, what you can do is the following as well which is further down in the same file (~/camera_gmsl/main.cpp)
// take screenshot if requested
if (NvMediaImageLock(rgbaImage->img, NVMEDIA_IMAGE_ACCESS_READ, &surfaceMap) == NVMEDIA_STATUS_OK)
sprintf(fname, “screenshot_%04d.png”, gScreenshotCount++);
lodepng_encode32_file(fname, (unsigned char*)surfaceMap.surface.mapping, rgbaImage->prop.width, rgbaImage->prop.height);
gTakeScreenshot = false;
std::cout << "SCREENSHOT TAKEN to " << fname << “\n”;
std::cout << “CANNOT LOCK NVMEDIA IMAGE - NO SCREENSHOT\n”;
This saves the RGBA image that is from NvMedia space. Thanks.