What is right for ColorConversionCode in CVCUDA

Hi all,

Now I am testing cvtcolor() function of Python API of CVCUDA lib. However, I do not know how to select an exact code for converting from RGB to BGR image. The below is my test code:

from nvidia import nvimgcodec
import cvcuda

nvimg = decoder.read(<path_to_image>)
nvtensor = cvcuda.as_tensor(nvimg, "HWC")
nvimg = cvcuda.cvtcolor(nvimg, cvcuda.NVCV_COLOR_RBG2BGR)

My error message is:

AttributeError: type object 'cvcuda' has no attribute 'NVCV_COLOR_RGB2BGR'

Can you help me to show the right way to use this function?
Thank you so much.

Based on this for RGB2BGR I would try using:

nvimg = cvcuda.cvtcolor(nvimg, cvcuda.ColorConversion.RGB2BGR)

Thanks. I tried your suggestion and it seems working right. However, there occur a syntax error that is


Could you help me solve it?

Sorry I won’t be able to work with screenshots. I need to copy text out of your screenshot and I can’t do that. I’m not going to try typing it. Please make it easier for others to help you by posting text as text on this forum, not as screenshots.

In a nutshell, I would say that the first argument in your call is a nv image codec object, and cvcuda is expecting something else there. You created nvtensor right before this line of code. Why are you passing nvimg instead of nvtensor ?

Try this:

cc = cvcuda.cvtcolor(nvtensor, cvcuda.ColorConversion.RGB2BGR)
1 Like

Oh. Sorry. I missed it. Pushing a cvcuda tensor to cvtcolor() function will solve this problem.
Thanks so much.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.