void cv::ogl::Texture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) const { #ifndef HAVE_OPENGL (void) arr; (void) ddepth; (void) autoRelease; throw_no_ogl(); #else const int kind = arr.kind(); const int cn = format_ == DEPTH_COMPONENT ? 1: format_ == RGB ? 3 : 4; const GLenum dstFormat = format_ == DEPTH_COMPONENT ? gl::DEPTH_COMPONENT : format_ == RGB ? gl::BGR : gl::BGRA; switch(kind) { case _InputArray::OPENGL_BUFFER: { ogl::Buffer& buf = arr.getOGlBufferRef(); buf.create(rows_, cols_, CV_MAKE_TYPE(ddepth, cn), ogl::Buffer::PIXEL_PACK_BUFFER, autoRelease); buf.bind(ogl::Buffer::PIXEL_PACK_BUFFER); impl_->copyTo(dstFormat, gl_types[ddepth], 0); ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER); break; } case _InputArray::GPU_MAT: { #ifndef HAVE_CUDA throw_no_cuda(); #else ogl::Buffer buf(rows_, cols_, CV_MAKE_TYPE(ddepth, cn), ogl::Buffer::PIXEL_PACK_BUFFER); buf.setAutoRelease(true); buf.bind(ogl::Buffer::PIXEL_PACK_BUFFER); impl_->copyTo(dstFormat, gl_types[ddepth], 0); ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER); buf.copyTo(arr); #endif break; } default: { arr.create(rows_, cols_, CV_MAKE_TYPE(ddepth, cn)); Mat mat = arr.getMat(); CV_Assert( mat.isContinuous() ); ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER); impl_->copyTo(dstFormat, gl_types[ddepth], mat.data); } } #endif }
void cv::ogl::Buffer::copyTo(OutputArray arr, Target target, bool autoRelease) const { #ifndef HAVE_OPENGL (void) arr; (void) target; (void) autoRelease; throw_nogl(); #else const int kind = arr.kind(); switch (kind) { case _InputArray::OPENGL_BUFFER: { arr.getOGlBufferRef().copyFrom(*this, target, autoRelease); break; } case _InputArray::OPENGL_TEXTURE: { arr.getOGlTexture2DRef().copyFrom(*this, autoRelease); break; } case _InputArray::GPU_MAT: { #if !defined HAVE_CUDA || defined(CUDA_DISABLER) throw_nocuda(); #else GpuMat& dmat = arr.getGpuMatRef(); dmat.create(rows_, cols_, type_); impl_->copyTo(dmat.data, dmat.step, dmat.cols * dmat.elemSize(), dmat.rows); #endif break; } default: { arr.create(rows_, cols_, type_); Mat mat = arr.getMat(); CV_Assert( mat.isContinuous() ); impl_->copyTo(mat.rows * mat.cols * mat.elemSize(), mat.data); } } #endif }
void cv::ogl::Buffer::copyTo(OutputArray arr) const { #ifndef HAVE_OPENGL (void) arr; throw_no_ogl(); #else const int kind = arr.kind(); switch (kind) { case _InputArray::OPENGL_BUFFER: { arr.getOGlBufferRef().copyFrom(*this); break; } case _InputArray::GPU_MAT: { #ifndef HAVE_CUDA throw_no_cuda(); #else GpuMat& dmat = arr.getGpuMatRef(); dmat.create(rows_, cols_, type_); impl_->copyTo(dmat.data, dmat.step, dmat.cols * dmat.elemSize(), dmat.rows); #endif break; } default: { arr.create(rows_, cols_, type_); Mat mat = arr.getMat(); CV_Assert( mat.isContinuous() ); impl_->copyTo(mat.rows * mat.cols * mat.elemSize(), mat.data); } } #endif }