|
|
|
@ -46,6 +46,8 @@ |
|
|
|
|
#include "precomp.hpp" |
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
|
#include "opencv2/imgproc/types_c.h" |
|
|
|
|
#include "opencv2/imgproc/imgproc_c.h" |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
@ -53,7 +55,6 @@ namespace ocl |
|
|
|
|
{ |
|
|
|
|
extern const char *moments; |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
// The function calculates center of gravity and the central second order moments
|
|
|
|
|
static void icvCompleteMomentState( CvMoments* moments ) |
|
|
|
|
{ |
|
|
|
@ -145,7 +146,7 @@ static void icvContourMoments( CvSeq* contour, CvMoments* mom ) |
|
|
|
|
cl_int dst_step = (cl_int)dst_a.step; |
|
|
|
|
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_step )); |
|
|
|
|
|
|
|
|
|
openCLExecuteKernel(dst_a.clCxt, &moments, "icvContourMoments", globalThreads, localThreads, args, -1, -1); |
|
|
|
|
openCLExecuteKernel2(dst_a.clCxt, &moments, "icvContourMoments", globalThreads, localThreads, args, -1, -1); |
|
|
|
|
|
|
|
|
|
cv::Mat dst(dst_a); |
|
|
|
|
a00 = a10 = a01 = a20 = a11 = a02 = a30 = a21 = a12 = a03 = 0.0; |
|
|
|
@ -300,7 +301,7 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary ) |
|
|
|
|
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&coi )); |
|
|
|
|
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&binary )); |
|
|
|
|
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE )); |
|
|
|
|
openCLExecuteKernel(Context::getContext(), &moments, "CvMoments", globalThreads, localThreads, args, -1, depth); |
|
|
|
|
openCLExecuteKernel2(Context::getContext(), &moments, "CvMoments", globalThreads, localThreads, args, -1, depth); |
|
|
|
|
|
|
|
|
|
size_t localThreadss[3] = { 128, 1, 1}; |
|
|
|
|
size_t globalThreadss[3] = { 128, 1, 1}; |
|
|
|
@ -309,41 +310,34 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary ) |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&tile_height )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&tile_width )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum.data )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data )); |
|
|
|
|
args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step )); |
|
|
|
|
openCLExecuteKernel(Context::getContext(), &moments, "dst_sum", globalThreadss, localThreadss, args_sum, -1, -1); |
|
|
|
|
openCLExecuteKernel2(Context::getContext(), &moments, "dst_sum", globalThreadss, localThreadss, args_sum, -1, -1); |
|
|
|
|
|
|
|
|
|
Mat dstsum(sum); |
|
|
|
|
mom->m00 = dstsum[0]; |
|
|
|
|
mom->m10 = dstsum[1]; |
|
|
|
|
mom->m01 = dstsum[2]; |
|
|
|
|
mom->m20 = dstsum[3]; |
|
|
|
|
mom->m11 = dstsum[4]; |
|
|
|
|
mom->m02 = dstsum[5]; |
|
|
|
|
mom->m30 = dstsum[6]; |
|
|
|
|
mom->m21 = dstsum[7]; |
|
|
|
|
mom->m12 = dstsum[8]; |
|
|
|
|
mom->m03 = dstsum[9]; |
|
|
|
|
mom->m00 = dstsum.at<double>(0, 0); |
|
|
|
|
mom->m10 = dstsum.at<double>(0, 1); |
|
|
|
|
mom->m01 = dstsum.at<double>(0, 2); |
|
|
|
|
mom->m20 = dstsum.at<double>(0, 3); |
|
|
|
|
mom->m11 = dstsum.at<double>(0, 4); |
|
|
|
|
mom->m02 = dstsum.at<double>(0, 5); |
|
|
|
|
mom->m30 = dstsum.at<double>(0, 6); |
|
|
|
|
mom->m21 = dstsum.at<double>(0, 7); |
|
|
|
|
mom->m12 = dstsum.at<double>(0, 8); |
|
|
|
|
mom->m03 = dstsum.at<double>(0, 9); |
|
|
|
|
|
|
|
|
|
icvCompleteMomentState( mom ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
Moments ocl_moments( InputArray _array, bool binaryImage ) |
|
|
|
|
{ |
|
|
|
|
#if 0 |
|
|
|
|
CvMoments om; |
|
|
|
|
Mat arr = _array.getMat(); |
|
|
|
|
CvMat c_array = arr; |
|
|
|
|
ocl_cvMoments(&c_array, &om, binaryImage); |
|
|
|
|
return om; |
|
|
|
|
#endif |
|
|
|
|
CV_Error(Error::StsNotImplemented, "ocl_moments is not implemented"); |
|
|
|
|
(void)_array; |
|
|
|
|
(void)binaryImage; |
|
|
|
|
return Moments(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|