cudaDrawLine line thickness different on lines with same thickness setting

I modified the cuda-examples.py code from jetson-inference/build/aarch64/bin to include these 4lines of code:

draw 2 vertical lines on left side

jetson.utils.cudaDrawLine(color_img, (0,color_img.height), (0,0), (0,0,0,255), 3) # Black vertical line
jetson.utils.cudaDrawLine(color_img, (10,color_img.height), (10,0), (255,255,153,255), 3) # Yellow vertical line

draw 2 vertical lines on right side

jetson.utils.cudaDrawLine(color_img, (color_img.width,color_img.height), (color_img.width,0), (0,0,0,255), 3) # Black vertical line
jetson.utils.cudaDrawLine(color_img, (color_img.width-10,color_img.height), (color_img.width-10,0), (255,255,153,255), 3) # Yellow vertical line

I commented out the original 3 lines under “draw some shapes”.

The yellow lines seem thicker by ~40%. Don’t know if this expected or a graphics issue. To me they would appear the same. I’m using an MSI display.

Not a high priority with me right now but would be interested if anyone has the same problem. My work around is to lower the yellow lines’ thickness setting to compensate.

An additional question: I looked for a palette guide for RGB8 on the internet and couldn’t find one. What is the 4th code value for in the color codes. I set it to 255 and it seems ok. Any clues?

Thanks all
cuda-example

Hi @steven.sparks, the CUDA-based line drawing I’ve implemented is rather rudimentary (for simplicity and speed), so as you have found I’m not entirely surprised that it’s not exactly correct. I would continue using your workaround for now - the line thickness is a floating-point value, so it can accept values like 2.5 to compensate.

Alternatively, you can try modifying the source here: https://github.com/dusty-nv/jetson-utils/blob/0d3f59f5c0967a108ec1cd58a518ee5ad817d35b/cuda/cudaDraw.cu#L138

I have a feeling that line_width may need divided by 2 before it gets squared, because the way I determine if a pixel should be filled in this routine is by calculating the distance from each pixel to the line. So it may be that line_width=3 actually yields a width of 6.

It’s the alpha value, where 255 is fully opaque and 0 is fully transparent.

Will look at your code and response, but first I thought I should communicate what i found when i continued my investigation.

From an experiment, the outer bounds of the picture seem to have a 3 position no mans land where a portion of the line is consumed. When I push the line over by 3, the full width shows.

draw 2 vertical lines on left side

jetson.utils.cudaDrawLine(color_img, (3,color_img.height), (3,0), (0,0,0,255), 3) # Black vertical line
jetson.utils.cudaDrawLine(color_img, (14,color_img.height), (14,0), (255,255,153,255), 3) # Yellow vertical line

draw 2 vewrtical lines on right side

jetson.utils.cudaDrawLine(color_img, (color_img.width**-4**,color_img.height), (color_img.width**-4**,0), (0,0,0,255), 3) # Black vertical line
jetson.utils.cudaDrawLine(color_img, (color_img.width-14,color_img.height), (color_img.width-14,0), (255,255,153,255), 3) # Yellow vertical line

Just wanted to surface all of this. As you said the program provided was rudimentary. I have no need to continue but if I find more as I complete my final product, I will comunicate to all if it seems of value.

Thanks for you quick response. Have a great holiday!
cuda-example_2