hopefully, fixed compile errors on Win & Linux; fixed getMatVector() so core & imgproc tests now pass; fixed doc builder errors

This commit is contained in:
Vadim Pisarevsky 2013-10-22 17:41:28 +04:00
parent d8c8339bec
commit d3076c5014
6 changed files with 87 additions and 82 deletions

View File

@ -378,7 +378,7 @@ Calculates the covariance matrix of a set of vectors.
.. ocv:function:: void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype=CV_64F) .. ocv:function:: void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype=CV_64F)
.. ocv:function:: void calcCovarMatrix( InputArray samples, OutputArray covar, OutputArray mean, int flags, int ctype=CV_64F) .. ocv:function:: void calcCovarMatrix( InputArray samples, OutputArray covar, InputOutputArray mean, int flags, int ctype=CV_64F)
.. ocv:pyfunction:: cv2.calcCovarMatrix(samples, flags[, covar[, mean[, ctype]]]) -> covar, mean .. ocv:pyfunction:: cv2.calcCovarMatrix(samples, flags[, covar[, mean[, ctype]]]) -> covar, mean

View File

@ -211,7 +211,6 @@ public:
bool create(int dtype); bool create(int dtype);
size_t ndevices() const; size_t ndevices() const;
const Device& device(size_t idx) const; const Device& device(size_t idx) const;
int dtype() const;
Program getProg(const ProgramSource& prog, Program getProg(const ProgramSource& prog,
const String& buildopt, String& errmsg); const String& buildopt, String& errmsg);

View File

@ -1276,6 +1276,17 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
return; return;
} }
if( k == STD_VECTOR_MAT )
{
const std::vector<Mat>& v = *(const std::vector<Mat>*)obj;
size_t i, n = v.size();
mv.resize(n);
for( i = 0; i < n; i++ )
mv[i] = v[i];
return;
}
if( k == STD_VECTOR_UMAT ) if( k == STD_VECTOR_UMAT )
{ {
const std::vector<UMat>& v = *(const std::vector<UMat>*)obj; const std::vector<UMat>& v = *(const std::vector<UMat>*)obj;

View File

@ -627,13 +627,13 @@ static void* initOpenCLAndLoad(const char* funcname)
{ {
handle = LoadLibraryA("OpenCL.dll"); handle = LoadLibraryA("OpenCL.dll");
initialized = true; initialized = true;
g_haveOpenCL = handle != 0 && GetProcAddressA(handle, oclFuncToCheck) != 0; g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0;
} }
if(!handle) if(!handle)
return 0; return 0;
} }
return funcname ? (void*)GetProcAddressA(handle, funcname) : 0; return funcname ? (void*)GetProcAddress(handle, funcname) : 0;
} }
#elif defined(__linux) #elif defined(__linux)
@ -649,9 +649,9 @@ static void* initOpenCLAndLoad(const char* funcname)
{ {
if(!initialized) if(!initialized)
{ {
handle = dlopen("libOpenCL.so"); handle = dlopen("libOpenCL.so", RTLD_LAZY);
if(!handle) if(!handle)
handle = dlopen("libCL.so"); handle = dlopen("libCL.so", RTLD_LAZY);
initialized = true; initialized = true;
g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0; g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0;
} }
@ -1107,7 +1107,7 @@ OCL_FUNC(cl_int, clEnqueueWriteBufferRect,
region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch,
host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event)) host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event))
OCL_FUNC(cl_int, clEnqueueFillBuffer, /*OCL_FUNC(cl_int, clEnqueueFillBuffer,
(cl_command_queue command_queue, (cl_command_queue command_queue,
cl_mem buffer, cl_mem buffer,
const void * pattern, const void * pattern,
@ -1118,7 +1118,7 @@ OCL_FUNC(cl_int, clEnqueueFillBuffer,
const cl_event * event_wait_list, const cl_event * event_wait_list,
cl_event * event), cl_event * event),
(command_queue, buffer, pattern, pattern_size, offset, size, (command_queue, buffer, pattern, pattern_size, offset, size,
num_events_in_wait_list, event_wait_list, event)) num_events_in_wait_list, event_wait_list, event))*/
OCL_FUNC(cl_int, clEnqueueCopyBuffer, OCL_FUNC(cl_int, clEnqueueCopyBuffer,
(cl_command_queue command_queue, (cl_command_queue command_queue,
@ -1737,7 +1737,6 @@ struct Context::Impl
cl_context handle; cl_context handle;
std::vector<Device> devices; std::vector<Device> devices;
int dtype;
bool initialized; bool initialized;
typedef ProgramSource::hash_t hash_t; typedef ProgramSource::hash_t hash_t;
@ -1766,11 +1765,6 @@ Context::Context(int dtype)
create(dtype); create(dtype);
} }
int Context::dtype() const
{
return p ? p->dtype : 0;
}
bool Context::create(int dtype0) bool Context::create(int dtype0)
{ {
if( !haveOpenCL() ) if( !haveOpenCL() )
@ -2113,9 +2107,8 @@ int Kernel::set(int i, const KernelArg& arg)
} }
else else
{ {
clSetKernelArg(p->handle, (cl_uint)(i+1), sizeof(size_t), &arg.m->offset); clSetKernelArg(p->handle, (cl_uint)(i+2), sizeof(size_t)*(dims-1), &arg.m->step.p[0]);
clSetKernelArg(p->handle, (cl_uint)(i+1), sizeof(size_t)*(dims-1), &arg.m->step.p[0]); clSetKernelArg(p->handle, (cl_uint)(i+3), sizeof(cl_int)*dims, &arg.m->size.p[0]);
clSetKernelArg(p->handle, (cl_uint)(i+2), sizeof(cl_int)*dims, &arg.m->size.p[0]);
return i + 4; return i + 4;
} }
} }
@ -2249,13 +2242,13 @@ struct Program::Impl
const Context& ctx = Context::getDefault(); const Context& ctx = Context::getDefault();
const Device& dev = Device::getDefault(); const Device& dev = Device::getDefault();
const char* pos0 = _buf.c_str(); const char* pos0 = _buf.c_str();
char* pos1 = strchr(pos0, '\n'); const char* pos1 = strchr(pos0, '\n');
if(!pos1) if(!pos1)
return; return;
char* pos2 = strchr(pos1+1, '\n'); const char* pos2 = strchr(pos1+1, '\n');
if(!pos2) if(!pos2)
return; return;
char* pos3 = strchr(pos2+1, '\n'); const char* pos3 = strchr(pos2+1, '\n');
if(!pos3) if(!pos3)
return; return;
size_t prefixlen = (pos3 - pos0)+1; size_t prefixlen = (pos3 - pos0)+1;
@ -2580,6 +2573,9 @@ public:
u->markHostCopyObsolete(false); u->markHostCopyObsolete(false);
clReleaseMemObject((cl_mem)u->handle); clReleaseMemObject((cl_mem)u->handle);
u->currAllocator = u->prevAllocator; u->currAllocator = u->prevAllocator;
if(u->data && u->copyOnMap())
fastFree(u->data);
u->data = u->origdata;
if(u->refcount == 0) if(u->refcount == 0)
u->currAllocator->deallocate(u); u->currAllocator->deallocate(u);
} }
@ -2898,4 +2894,3 @@ MatAllocator* getOpenCLAllocator()
} }
}} }}

View File

@ -877,14 +877,14 @@ TLSData::TLSData()
{ {
if( tlsKey == TLS_OUT_OF_INDEXES ) if( tlsKey == TLS_OUT_OF_INDEXES )
{ {
tlsRNGKey = TlsAlloc(); tlsKey = TlsAlloc();
CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES); CV_Assert(tlsKey != TLS_OUT_OF_INDEXES);
} }
TLSData* d = (TLSData*)TlsGetValue( tlsKey ); TLSData* d = (TLSData*)TlsGetValue( tlsKey );
if( !d ) if( !d )
{ {
d = new TLSData; d = new TLSData;
TlsSetValue( tlsRNGKey, d ); TlsSetValue( tlsKey, d );
} }
return d; return d;
} }

View File

@ -548,7 +548,7 @@ Mat UMat::getMat(int accessFlags) const
Mat hdr(dims, size.p, type(), u->data + offset, step.p); Mat hdr(dims, size.p, type(), u->data + offset, step.p);
hdr.refcount = &u->refcount; hdr.refcount = &u->refcount;
hdr.u = u; hdr.u = u;
hdr.datastart = u->data; hdr.datastart = hdr.data = u->data;
hdr.datalimit = hdr.dataend = u->data + u->size; hdr.datalimit = hdr.dataend = u->data + u->size;
CV_XADD(hdr.refcount, 1); CV_XADD(hdr.refcount, 1);
return hdr; return hdr;
@ -565,24 +565,24 @@ void* UMat::handle(int accessFlags) const
CV_Assert(u->refcount == 0); CV_Assert(u->refcount == 0);
u->currAllocator->unmap(u); u->currAllocator->unmap(u);
} }
else if( u->refcount > 0 && (accessFlags & ACCESS_WRITE) ) /*else if( u->refcount > 0 && (accessFlags & ACCESS_WRITE) )
{ {
CV_Error(Error::StsError, CV_Error(Error::StsError,
"it's not allowed to access UMat handle for writing " "it's not allowed to access UMat handle for writing "
"while it's mapped; call Mat::release() first for all its mappings"); "while it's mapped; call Mat::release() first for all its mappings");
} }*/
return u->handle; return u->handle;
} }
void UMat::ndoffset(size_t* ofs) const void UMat::ndoffset(size_t* ofs) const
{ {
// offset = step[0]*ofs[0] + step[1]*ofs[1] + step[2]*ofs[2] + ...; // offset = step[0]*ofs[0] + step[1]*ofs[1] + step[2]*ofs[2] + ...;
size_t t = offset; size_t val = offset;
for( int i = 0; i < dims; i++ ) for( int i = 0; i < dims; i++ )
{ {
size_t s = step.p[i]; size_t s = step.p[i];
ofs[i] = t / s; ofs[i] = val / s;
t -= ofs[i]*s; val -= ofs[i]*s;
} }
} }