cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

cyndwith
Journeyman III

Problem with reading the .bmp format images in openCL

this is the code i have written to load an image (bmp) into openCL for basic image processisng operation but it give some errors like:

error LNK2019: unresolved external symbol "public: bool __thiscall streamsdk::SDKBitMap::write(char const *)" (?write@SDKBitMap@streamsdk@@QAE_NPBD@Z) referenced in function "int __cdecl writeOutputImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?writeOutputImage@@YAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

how can i remove it??

int readInputImage(std::string inputImageName)//, cl_uchar4 *inputImageData)

{

    /*load input bitmap image */

    inputBitmap.load(inputImageName.c_str());

   

    if(!inputBitmap.isLoaded())

    {

        cout<<"Failed to load input image!"<<endl;

        //return -1;

    }

    //get the height and width of the input image

    /*height*/H=inputBitmap.getHeight();

    /*width*/W=inputBitmap.getWidth();

    //allocate memory to the input image

    inputImageData=(cl_uchar4*)malloc(W*H*sizeof(cl_uchar4));

    //error check

    if(inputImageData=NULL)

    {

        cout<<"Failed to allocate the memory!( input IMAGE DATA)"<<endl;

    }

    //allocate memory for out put image data

    outputImageData=(cl_uchar4*)malloc(W*H*sizeof(cl_uchar4));

    //error check

    if(outputImageData=NULL)

    {

        cout<<"FAILED TO ALLOCATE MEMORY TO THE OUTPUT IMAGE!!!"<<endl;

        //return -1;

    }

   

    //initialize the image data to null

    memset(outputImageData,0,W*H*pixelSize);

    //get the pointer to the pixel data

    pixelData=inputBitmap.getPixels();

    //error check

    if(pixelData=NULL)

    {

        cout<<"FAILED TO READ PIXEL DATA!!"<<endl;

    }

    //copy pixel data into inputImageData

    memcpy(inputImageData,pixelData,W*H*pixelSize);

    //allocate memory for verification output

   

    verificationOutput=(cl_uchar*)malloc(W*H*pixelSize);

    //error check

    if(verificationOutput==NULL)

    {

        cout<<"allocation of memory to verification failed!!"<<endl;

    }

    //intialisation the data to NULL

    memset(verificationOutput,0,W*H*pixelSize);

    return SDK_SUCCESS;

}

0 Likes
6 Replies
nou
Exemplar

link SDKutil from SDK. look at example projects how do they do it.

0 Likes

i have followed an example program...made all these changes....but i was unable to figure out why dis error is occuring??

i tried to include all the SDKutil and header files required...

can you help me what to do , if possible with an example??

0 Likes

no you must add SDKutils.lib to linked libraries in project settings.

0 Likes
cyndwith
Journeyman III

Yeah i have done it....but still it gives an erro saying unable to link to SDKutil.lib

and when trying with other samples i tried to modify the sobel sample form AMD samples programs...i have got error intially which i was able to debug...but at the end the program is executed without any error (during compilation as well as run time...) but am the output image i get is completly black....

can any one help we with it?? why is it happening so?

i checked whether the input is reading the image properly by writting the read data into an intermediate check image...its working fine ...but the output has remained black even though i tried many changes...like assinging the input directly to output...just to have a simple replica of input image...even that is not working ...

0 Likes
cyndwith
Journeyman III

tHIS IS MY KERNEL

KERNEL:

__kernel void sobel_filter(__global uchar4* dest_data, __global uchar4* src_data)

{

    const int ix = get_global_id(0);

    const int iy = get_global_id(1);

    uint width = get_global_size(0);

    uint height = get_global_size(1);

    float cosTheta=1;

    float sinTheta=0;

    float xpos=((float)ix)*cosTheta+((float)iy)*sinTheta;

    float ypos= -1.0*((float)ix)*sinTheta + ((float)iy)*cosTheta;

       

    if(((int)xpos>=0)&&((int)xpos<=width)&&((int)ypos>=0)&&((int)ypos<=height))

    {

        dest_data[(int)(ypos*width+xpos)]=src_data[iy*width+ix];

    }

           

}

IMAGE WRITE FUNCTION:

int

SobelFilter::writeOutputImage(std::string outputImageName)

{

    /* copy output image data back to original pixel data */

    memcpy(pixelData, outputImageData, width * height * pixelSize);

    /* write the output bmp file */

    if(!inputBitmap.write(outputImageName.c_str()))

    {

        sampleCommon->error("Failed to write output image!");

        getchar();return SDK_FAILURE;

    }

    cout<<"Oupt is Written to pixel data :)"<<endl;

    getchar();return SDK_SUCCESS;;

}

am getting blank output...image...??

thanks in advance...

0 Likes

Hi cyndwith,

I have just used your kernel, and I have modified your kernel as following:

__kernel void sobel_filter(__global uchar4* src_data, __global uchar4* dest_data)

{
    const int ix = get_global_id(0);
    const int iy = get_global_id(1);

    uint width = get_global_size(0);
    uint height = get_global_size(1);

    float cosTheta=1;
    float sinTheta=0;

    float xpos=(float)ix;
    float ypos=(float)iy;

    dest_data[(int)(ypos*width+xpos)]=src_data[iy*width+ix];

}

I use the sobel sample. I don't modify other function. You have to check the arguments of the kernel much carefully, which is the output and which is the input, you must insure it.

Thank you.

0 Likes