Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

data transfer between ocl matrix of type CV_32FC1 and CV_8UC1

I have created to ocl matrix of same size (rows and columns) bu different types. In my opencl code I am trying to transfer the data from CV_8UC1 matrix to CV_32FC1 matrix. I can see the values are correct when I used printf from kernel. But when I downloaded the output ocl matrix and printed the values in file I got wrong values. Here is my kernel:

`"__kernel void " " v2_integral_cols_sum(__global uchar *src,\n" "int rows,int cols,__global int *lm_sum, int pixels,int steps,int o_steps)\n" "{\n"

                "int gid=get_global_id(0);\n"
                "if(gid>=pixels)"
                "return;\n"
                "else \n"
                "{"
                "int x = gid % steps;\n"
                "int y = gid / steps;\n"
                "int sum=0;\n"


                "for (int i=0;i<=x;i++)"
                "{\n"


                    "sum=sum+src[y * steps + i];\n"
                "}\n"


                "lm_sum[y * o_steps + x]=sum;\n"

                "}"

            "}\n"

`

Here is the host code:

`ocl::oclMat lm_sum_mem; lm_sum_mem.create(src.rows,src.cols, CV_32FC1); args.push_back( make_pair( sizeof(cl_mem) , (void *)&src.data )); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows )); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols )); args.push_back( make_pair( sizeof(cl_mem) , (void *)&lm_sum_mem.data)); args.push_back( make_pair( sizeof(cl_int) , (void *)&npixels)); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.step )); args.push_back( make_pair( sizeof(cl_int) , (void *)&lm_sum_mem.step ));

            size_t gt[3] = {1728, 1, 1}, lt[3] = {32, 1, 1};

            if(calTime)
            {
                //double dtKERNL1=get_wall_timelbp();
                gettime_tocalc2[0]=get_wall_timelbp();
            }

            //ocl::openCLExecuteKernel(clCxt, &lbpobjectdetect, "v2_integral_cols", gt, lt, args, -1, -1,build_options);
            ocl::openCLExecuteKernel(clCxt, &lbpobjectdetect, "v2_integral_cols_sum", gt, lt, args, -1, -1,build_options);`

Here is the file printing: `Mat t_sumhost; lm_sum_mem.download(t_sumhost); std::stringstream strFname3; printf("loop count %d",loopCount); strFname3 << "Integral_Cols"<<loopcount&lt;&lt;".txt"; const="" char*="" filenames="strFname3.str().c_str();" file="" *fp="fopen(filenames," "w");<="" p="">

            fprintf(fp,"Columnn %2d Rows: %d\n: ", t_sumhost.cols,t_sumhost.rows);
            for (int i = 0; i < t_sumhost.rows; i++)
            {
                fprintf(fp,"\nrow %2d: ", i);
                for (int j = 0; j < t_sumhost.cols; j++)
                {
                    fprintf(fp," %5d ", t_sumhost.at<int>(i,j));
                }
            }
            fclose(fp);`