images and structures? How can I pass an image struct to CUDA?

This could be a silly question but here goes…
I get an image which is of the form: image[y].pixel_r image[y].pixel_g & image[y].pixel_b
So right now I’m running a cpu loop to copy this into a matrix… image[y][rgb]
which I can then copy to device and work on.

This would seem to be a fairly standard image format though so surely I can copy directly to cuda without needing the cpu loop to make it into a matrix??

It would also be nice to be able to stream a camera image direct to the device, it seems this is possible but I don’t really understand how, is there a simple example code out there somewhere?

Cheers

I have found the easiest pixel formats to work with (memory copy-wise) are single dimensions. Then you can access the (x,y) pixel you want by doing the following.

image[x + yimageWidth + 0]; // red
image[x + y
imageWidth + 1]; // green
image[x + y*imageWidth + 2]; // blue

2D arrays are not impossible to use, but its usually easier/saner to make a single dimension and make an index to a 2D location within it.