Hi
I found, that NVXCU_INTERPOLATION_TYPE_AREA doesn’t work with nvxcuWarpPerspective. It provide broken image on my laptop and black image on jetson tx2. But NVXCU_INTERPOLATION_TYPE_NEAREST_NEIGHBOR and NVXCU_INTERPOLATION_TYPE_BILINEAR works fine.
Code sample:
nvxcu_pitch_linear_image_t mat2nvxcu(const cv::cuda::GpuMat &mat)
{
nvxcu_pitch_linear_image_t image;
if(mat.type() == CV_8UC4)
{
image.base.format = NVXCU_DF_IMAGE_RGBX;
}
else if(mat.type() == CV_8UC3)
{
image.base.format = NVXCU_DF_IMAGE_RGB;
}
else
{
image.base.format = NVXCU_DF_IMAGE_U8;
}
image.base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
image.base.width = mat.cols;
image.base.height = mat.rows;
image.planes[0].dev_ptr = mat.data;
image.planes[0].pitch_in_bytes = mat.step;
return image;
}
int main()
{
nvxcu_stream_exec_target_t target;
target.base.exec_target_type = NVXCU_STREAM_EXEC_TARGET;
target.stream = 0;
cudaGetDeviceProperties(&target.dev_prop, 0);
nvxcu_border_t border;
border.mode = NVXCU_BORDER_MODE_CONSTANT;
cv::Mat src = cv::imread("/home/pavel/lena.png");
cv::Mat dst;
cv::cvtColor(src, src, cv::COLOR_BGR2RGBA);
cv::cuda::GpuMat srcGpu(src), dstGpu(src.size(), src.type());
auto cuSrc = mat2nvxcu(srcGpu);
auto cuDst = mat2nvxcu(dstGpu);
float hcpu[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
float *hgpu = nullptr;
cudaMalloc((void**)&hgpu, 9 * sizeof(float));
cudaMemcpy(hgpu, &hcpu, 9 * sizeof(float), cudaMemcpyHostToDevice);
nvxcuWarpPerspective(&cuSrc.base, hgpu, NVXCU_INTERPOLATION_TYPE_AREA, &cuDst.base, &border, &target.base);;
cudaStreamSynchronize(target.stream);
dstGpu.download(dst);
cv::cvtColor(dst, dst, cv::COLOR_RGBA2BGR);
cv::imwrite("/home/pavel/lena_warp.jpg", dst);
return 0;
}