Hi,
The archetiecture of our project has been created around the jetson utilities libraries and the video capture method:
* @param[out] image output pointer that will be set to the memory containing the image.
* If this interface has it's videoOptions::zeroCopy flag set to true,
* the memory was allocated in mapped CPU/GPU memory and is be accessible
* from both CPU and CUDA. Otherwise, it's accessible only from CUDA.
*
* @param[out] status optional status code returned (@see videoSource::Status).
* -2 on ERROR, -1 on EOS, 0 on TIMEOUT, 1 on OK.
*
* @returns `true` if a frame was captured, `false` if there was an error or a timeout occurred.
*/
template<typename T> bool Capture( T** image, int* status ) { return Capture((void**)image, imageFormatFromType<T>(), DEFAULT_TIMEOUT, status); }
/**
* Capture the next image from the video stream.
*
* The image formats supported by this templated version of Capture() include the following:
*
* - uchar3 (`IMAGE_RGB8`)
* - uchar4 (`IMAGE_RGBA8`)
* - float3 (`IMAGE_RGB32F`)
* - float4 (`IMAGE_RGBA32F`)
This method returns an RBG array in a uchar3 format. I would now like to capture certain frames from this using the nvjpeg hardware (we are using a Xavier NX). What’s the best way to do this? The multimedia library only accepts yuv as an input, so I tried using colorConvert in the utilities library. This seems to work and I get output, but occationally I am getting a segfault from the nvjpeg library, as well as the following in the nvjpeg library when attempting to resize:
[502680.069054] nvidia_smmu_context_fault_bank: 3 callbacks suppressed
[502680.069105] arm-smmu 12000000.iommu: Unhandled context fault: fsr=0x80000402, iova=0x3ff2760000, fsynr=0x220003, cbfrsynra=0x438, cb=9
[502680.069693] arm-smmu 12000000.iommu: Unhandled context fault: fsr=0x80000402, iova=0x3ff2761000, fsynr=0xe0003, cbfrsynra=0x438, cb=9
I also see this in the documentation:
<img src="https://github.com/dusty-nv/jetson-inference/raw/master/docs/images/deep-vision-header.jpg" width="100%">
<p align="right"><sup><a href="aux-streaming.md">Back</a> | <a href="https://github.com/dusty-nv/ros_deep_learning">Next</a> | </sup><a href="../README.md#hello-ai-world"><sup>Contents</sup></a>
<br/>
<sup>Appendix</sup></p>
# Image Manipulation with CUDA
This page covers a number of image format, conversion, and pre/post-processing functions implemented by jetson-utils with CUDA:
**Image Management**
* [Image Formats](#image-formats)
* [Image Allocation](#image-allocation)
* [Copying Images](#copying-images)
* [Image Capsules in Python](#image-capsules-in-python)
* [Array Interfaces](#array-interfaces)
* [Accessing Image Data in Python](#accessing-image-data-in-python)
* [Accessing as a Numpy Array](#accessing-as-a-numpy-array)
* [CUDA Array Interface](#cuda-array-interface)
* [Sharing the Memory Pointer](#sharing-the-memory-pointer)
This file has been truncated. show original
YUV NV12, YUYV, YVYU, and UYVY can only be converted to RGB/RGBA (not from)
Does this still hold true that you cannot go from RGB->YUV? I seems like the code is there to do this:
else if( outputFormat == IMAGE_BGR32F )
return CUDA(cudaRGB8ToRGB32((uchar3*)input, (float3*)output, width, height, true));
else if( outputFormat == IMAGE_BGRA32F )
return CUDA(cudaRGB8ToRGBA32((uchar3*)input, (float4*)output, width, height, true));
else if( outputFormat == IMAGE_GRAY8 )
return CUDA(cudaRGB8ToGray8((uchar3*)input, (uint8_t*)output, width, height));
else if( outputFormat == IMAGE_GRAY32F )
return CUDA(cudaRGB8ToGray32((uchar3*)input, (float*)output, width, height));
else if( outputFormat == IMAGE_I420 )
return CUDA(cudaRGBToI420((uchar3*)input, output, width, height));
else if( outputFormat == IMAGE_YV12 )
return CUDA(cudaRGBToYV12((uchar3*)input, output, width, height));
}
else if( inputFormat == IMAGE_RGBA8 )
{
if( outputFormat == IMAGE_RGB8 )
return CUDA(cudaRGBA8ToRGB8((uchar4*)input, (uchar3*)output, width, height));
else if( outputFormat == IMAGE_RGBA8 )
return CUDA(cudaMemcpy(output, input, imageFormatSize(inputFormat, width, height), cudaMemcpyDeviceToDevice));
else if( outputFormat == IMAGE_RGB32F )
return CUDA(cudaRGBA8ToRGB32((uchar4*)input, (float3*)output, width, height));
If this does work, what size/type should the memory allocation be for output?
Anyhow, if someone could point me to the best way from uchar3 RGB to nvjpeg encoding that would be helpful.
Hi @catch22 , looks like you are correct and I have some kernels for limited conversion from RGB->YUV formats in there for I420 / NV12. Those are 12 bits per pixel iirc, you would allocate them as a void pointer and calculate the size.
system
Closed
July 3, 2024, 5:04am
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.