Difference between revisions of "Image I/O & Framework"
Line 114: | Line 114: | ||
//Copy back the results to an host image named 'output' | //Copy back the results to an host image named 'output' | ||
gout->download(output->imageData,output->widthStep); | gout->download(output->imageData,output->widthStep); | ||
//Freeing GPU Memory | |||
delete gimg; | |||
delete gout; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 129: | Line 133: | ||
**imageStatistics | **imageStatistics | ||
**imageTransforms | **imageTransforms | ||
==Using CUVI with C== | ==Using CUVI with C== | ||
In C interface structure named CuviMat provides the same functionality as CuviImage. | |||
====I/O using CuviMat==== | |||
{| | |||
|style="font-size:125%;"| | |||
<syntaxhighlight lang="c"> | |||
//We start by assuming that user has an image named 'img' allocated on host | |||
//Size of the image | |||
CuviSize size = cuviSize(img->width,img->height); | |||
; | //Creating two empty CuviMat objects on device to hold input and output images | ||
CuviMat* gimg, *gout; | |||
cuviCreateMat(&gimg,size,img->depth,img->nChannels); | |||
cuviCreateMat(&gimg,size,img->depth,img->nChannels); | |||
//Populate input device image using the host image data | |||
cuviUploadData(gimg,img->imageData,img->widthStep,0); | |||
//Calling a CUVI function that takes negative of the input image | |||
cuviNOT(gimg,gout,0); | |||
//Shows the result on screen without copying the data to the host | |||
cuviShowMat("Negative",gout,0); | |||
//Copy back the results to an host image named 'output' | |||
cuviDownloadData(gout,output->imageData,output->widthStep,0); | |||
//Freeing GPU memory | |||
cuviDestroyMat(&gimg); | |||
cuviDestroyMat(&gout); | |||
</syntaxhighlight> | |||
|} |
Revision as of 15:43, 27 April 2012
CUVI sdlksljfdks;dlks kdsldks
Using CUVI with C++
CUVI C++ interface uses various features of C++ including classes, namespaces and default arguments to provide ease of use. User has the freedom to use C++ specifics as well as C features of CUVI while using C++ compiler however is restricted to C-only features if using a C compiler.
CuviImage
CuviImage is a C++ class to hold image data on the device. It has all the essential members to hold image information as well as methods to create and move image to and from device. All the C++ functions in CUVI take CuviImage as input/output image argument. CuviImage creates an image on the GPU so you do not need to cater for manually copying the image to the GPU and then back to the CPU, this is catered by CuviImage.
Members
Member name | Type | Description |
---|---|---|
data | void* | Data pointer containing the image pixel values on device |
width | Cuvi32u | Image width in pixels |
height | Cuvi32u | Image height in pixels |
pitch | size_t | Image pitch/widthstep in bytes |
depth | Cuvi32u | Defines the data container for the image. A depth of '8' creates CuviImage of type Cuvi8u |
dataBits | Cuvi32u | No. of bits containing image information. By default dataBits is equal to the depth of the image |
nChannels | Cuvi32u | Number of channels in image |
isSigned | bool | Specifies if the image also contains negative values. (float is an exception) |
isInitialized | bool | Specifies if the image has successfully been created on the device |
channelSequence | CuviChannelSeq | Specifies the arrangement of image channels like RGB and BGR |
CuviImage methods helps create, copy and show images. All methods return CuviStatus except constructors and destructor which throws an exception in case of failure.
Methods
Method | Description |
---|---|
CuviImage() | Default constructor. Initializes all members with 0 |
CuviImage(CuviSize size, Cuvi32u depth, Cuvi32u channels); | Creates a CuviImage of specified size, depth and channels. Throws exception if memory allocation on device fails. |
CuviImage(const CuviImage&); | Creates a copy of existing CuviImage |
CuviImage(const CuviMat&); | Creates a copy of existing CuviMat |
CuviStatus upload(void* pSrcHost, size_t srcPitch, CuviStream* stream = NULL); | Copy image data from host memory to CuviImage. This function also supports async operation |
CuviStatus download(void* pDstHost, size_t dstPitch, CuviStream* stream = NULL); | Copy image data from CuviImage to host memory. |
CuviStatus show(char* title = "CUVI Image",int milliseconds = 0); | Render CuviImage on screen for a specified amount of time |
~CuviImage(); | CuviImage destructor. Throws an exception in case of failure |
I/O using CuviImage
|
Namespaces
CUVI is divided in image processing modules based on functionality. These modules use separate namespace in CUVI C++ interface to increase readability and ease of use. The current CUVI version has following namespaces:
- cuvi
- arithmeticLogical
- colorOpertions
- computerVision
- dataExchange
- geometryTransforms
- imageFiltering
- imageStatistics
- imageTransforms
Using CUVI with C
In C interface structure named CuviMat provides the same functionality as CuviImage.
I/O using CuviMat
|