Added files for implementation of operations SetTo()

This commit is contained in:
Andrey Morozov
2010-07-17 11:17:29 +00:00
parent 08cba33f9d
commit 1d93ca00de
5 changed files with 147 additions and 36 deletions

View File

@@ -41,23 +41,23 @@
//M*/
#include "precomp.hpp"
#include "opencv2/gpu/stream_access.hpp"
//#include "opencv2/gpu/stream_access.hpp"
using namespace cv;
using namespace cv::gpu;
cv::gpu::CudaStream::CudaStream() : impl( (Impl*)fastMalloc(sizeof(Impl)) )
cv::gpu::CudaStream::CudaStream() //: impl( (Impl*)fastMalloc(sizeof(Impl)) )
{
//cudaSafeCall( cudaStreamCreate( &impl->stream) );
}
cv::gpu::CudaStream::~CudaStream()
{
cv::gpu::CudaStream::~CudaStream()
{
if (impl)
{
cudaSafeCall( cudaStreamDestroy( *(cudaStream_t*)impl ) );
cv::fastFree( impl );
}
}
}
bool cv::gpu::CudaStream::queryIfComplete()
@@ -70,8 +70,8 @@ bool cv::gpu::CudaStream::queryIfComplete()
//if (err == cudaErrorNotReady)
// return false;
////cudaErrorInvalidResourceHandle
//cudaSafeCall( err );
////cudaErrorInvalidResourceHandle
//cudaSafeCall( err );
return true;
}
void cv::gpu::CudaStream::waitForCompletion()
@@ -81,7 +81,7 @@ void cv::gpu::CudaStream::waitForCompletion()
void cv::gpu::CudaStream::enqueueDownload(const GpuMat& src, Mat& dst)
{
// cudaMemcpy2DAsync(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost,
// cudaMemcpy2DAsync(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost,
}
void cv::gpu::CudaStream::enqueueUpload(const Mat& src, GpuMat& dst)
{
@@ -109,4 +109,4 @@ void cv::gpu::CudaStream::enqueueConvert(const GpuMat& src, GpuMat& dst, int typ
//struct cudaStream_t& cv::gpu::CudaStream::getStream() { return stream; }

View File

@@ -68,26 +68,42 @@ void GpuMat::copyTo( GpuMat& m ) const
cudaSafeCall( cudaMemcpy2D(m.data, m.step, data, step, cols * elemSize(), rows, cudaMemcpyDeviceToDevice) );
cudaSafeCall( cudaThreadSynchronize() );
}
void GpuMat::copyTo( GpuMat& /*m*/, const GpuMat&/* mask */) const
{
{
CV_Assert(!"Not implemented");
}
void GpuMat::convertTo( GpuMat& /*m*/, int /*rtype*/, double /*alpha*/, double /*beta*/ ) const
{
CV_Assert(!"Not implemented");
}
GpuMat& GpuMat::operator = (const Scalar& /*s*/)
GpuMat& GpuMat::operator = (const Scalar& s)
{
CV_Assert(!"Not implemented");
CV_Assert(!"Not implemented");
cv::gpu::impl::set_to_without_mask(*this, s.val, this->depth(), this->channels());
return *this;
}
GpuMat& GpuMat::setTo(const Scalar& /*s*/, const GpuMat& /*mask*/)
GpuMat& GpuMat::setTo(const Scalar& s, const GpuMat& mask)
{
CV_Assert(!"Not implemented");
CV_Assert(!"Not implemented");
CV_DbgAssert(!this->empty());
this->channels();
this->depth();
if (mask.empty())
{
cv::gpu::impl::set_to_without_mask(*this, s.val, this->depth(), this->channels());
}
else
{
cv::gpu::impl::set_to_with_mask(*this, s.val, mask, this->depth(), this->channels());
}
return *this;
}
@@ -147,8 +163,8 @@ void GpuMat::create(int _rows, int _cols, int _type)
rows = _rows;
cols = _cols;
size_t esz = elemSize();
size_t esz = elemSize();
void *dev_ptr;
cudaSafeCall( cudaMallocPitch(&dev_ptr, &step, esz * cols, rows) );
@@ -157,10 +173,10 @@ void GpuMat::create(int _rows, int _cols, int _type)
int64 _nettosize = (int64)step*rows;
size_t nettosize = (size_t)_nettosize;
datastart = data = (uchar*)dev_ptr;
dataend = data + nettosize;
dataend = data + nettosize;
refcount = (int*)fastMalloc(sizeof(*refcount));
*refcount = 1;
}
@@ -171,7 +187,7 @@ void GpuMat::release()
if( refcount && CV_XADD(refcount, -1) == 1 )
{
fastFree(refcount);
cudaSafeCall( cudaFree(datastart) );
cudaSafeCall( cudaFree(datastart) );
}
data = datastart = dataend = 0;
step = rows = cols = 0;