DRIVE OS Version: 6.0.6
Issue Description:
Dear Nvidia Support Team,
I’m trying to implement a “rotate image” function using DriveOS 6.0.6 and the Driveworks API, but I don’t quite get the expected results. Currently, a 90° rotation is sufficient, therefore I would the function to flip a FullHD image from 1920x1080px to 1080x1920px. As the rotate function of any image viewer would.
My current approach is to use the rectification pipeline for this, as it provides an interface for rotation via a homography matrix. As the output Camera Model, I just use the input model. This does rotate the image, but the resulting image is not as expected. The (FullHD) image is flipped, but the visible image appears as a square, i.e. it does not keep the original aspect ratio. If I try to assign the expected dimensions to teh imgProperties within the rotateImage function, the image is stretched vertically.
dwCameraModelHandle_t cameraModelIn = DW_NULL_HANDLE;
dwRigHandle_t rigConfig = DW_NULL_HANDLE;
dwRig_initializeFromFile(&rigConfig, sdk, argv\[2\]);
uint32_t cameraId = 0;
char cameraName[ ] = “camera:unpositioned:0”;
CHECK_DW_ERROR(dwRig_findSensorByName(&cameraId, cameraName, rigConfig));
CHECK_DW_ERROR(dwCameraModel_initialize(&cameraModelIn, cameraId, rigConfig));
CHECK_DW_ERROR(
dwRectifier_initialize(&rectifier, cameraModelIn, cameraModelIn, sdk));
dwImageHandle_t rotateImage(dwImageHandle_t inputImage, dwRectifierHandle_t rectifier, dwContextHandle_t sdk) {
dwImageProperties imgProperties{};
dwImageHandle_t rectifiedImage;
dwImage_getProperties(&imgProperties, inputImage);
dwRectifier_appendAllocationAttributes(&imgProperties, rectifier);
dwImage_create(&rectifiedImage, imgProperties, sdk);
dwImageCUDA *outputImageCuda;
dwImageCUDA *inputImageCuda;
CHECK_DW_ERROR(dwImage_getCUDA(&inputImageCuda, inputImage));
CHECK_DW_ERROR(dwImage_getCUDA(&outputImageCuda, rectifiedImage));
CHECK_DW_ERROR(
dwRectifier_setHomographyFromRotation(90.0, 0.0, 0.0, rectifier));
CHECK_DW_ERROR(
dwRectifier_warp(outputImageCuda, inputImageCuda, true, rectifier));
return rectifiedImage;
}
Original image:
Expected image:
current result without setting the dimensions:
current result when setting the dimensions:
You can ignore the different appearances of the images. They where recorded at different times of day.
In the function description of “dwRectifier_warp” you write:
NOTE: the coordinates of input/output images are implicitly adapted to match the input/output camera if the sizes of the images don’t match the cameras. This will result in stretching of the image and possible loss of aspect ratio.
What would be the correct way to rotate an image or what am I missing to correctly rotate an image using the rectifier pipeline? Is there any way to mitigate this loss of aspect ratio? Am I missing an API which does this easily?
Thanks in advance,
Johannes





