Ejemplo n.º 1
0
void cv::GlTexture::copyFrom(InputArray mat_, bool bgra)
{
#ifndef HAVE_OPENGL
    (void)mat_;
    (void)bgra;
    throw_nogl;
#else
    int kind = mat_.kind();
    Size _size = mat_.size();
    int _type = mat_.type();

    create(_size, _type);

    switch(kind)
    {
    case _InputArray::OPENGL_TEXTURE:
        {
            GlTexture tex = mat_.getGlTexture();
            *this = tex;
            break;
        }
    case _InputArray::OPENGL_BUFFER:
        {
            GlBuffer buf = mat_.getGlBuffer();
            impl_->copyFrom(buf, bgra);
            break;
        }
    case _InputArray::GPU_MAT:
        {
            #if !defined HAVE_CUDA || defined(CUDA_DISABLER)
                throw_nocuda;
            #else
                GpuMat d_mat = mat_.getGpuMat();
                buf_.copyFrom(d_mat);
                impl_->copyFrom(buf_, bgra);
            #endif

            break;
        }
    default:
        {
            Mat mat = mat_.getMat();
            impl_->copyFrom(mat, bgra);
        }
    }
#endif
}
Ejemplo n.º 2
0
cv::GlTexture::GlTexture(InputArray mat_, bool bgra) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
    (void)mat_;
    (void)bgra;
    throw_nogl;
#else
    int kind = mat_.kind();
    Size _size = mat_.size();
    int _type = mat_.type();

    switch (kind)
    {
    case _InputArray::OPENGL_BUFFER:
        {
            GlBuffer buf = mat_.getGlBuffer();
            impl_ = new Impl(buf, bgra);
            break;
        }
    case _InputArray::GPU_MAT:
        {
            #if !defined HAVE_CUDA || defined(CUDA_DISABLER)
                throw_nocuda;
            #else
                GpuMat d_mat = mat_.getGpuMat();
                GlBuffer buf(d_mat, GlBuffer::TEXTURE_BUFFER);
                impl_ = new Impl(buf, bgra);
            #endif

            break;
        }
    default:
        {
            Mat mat = mat_.getMat();
            impl_ = new Impl(mat, bgra);
            break;
        }
    }

    rows_ = _size.height;
    cols_ = _size.width;
    type_ = _type;
#endif
}
Ejemplo n.º 3
0
void cv::GlBuffer::copyFrom(InputArray mat_)
{
#ifndef HAVE_OPENGL
    (void)mat_;
    throw_nogl;
#else
    int kind = mat_.kind();
    Size _size = mat_.size();
    int _type = mat_.type();

    create(_size, _type);

    switch (kind)
    {
    case _InputArray::OPENGL_BUFFER:
        {
            GlBuffer buf = mat_.getGlBuffer();
            *this = buf;
            break;
        }
    case _InputArray::GPU_MAT:
        {
            #if !defined HAVE_CUDA || defined(CUDA_DISABLER)
                throw_nocuda;
            #else
                GpuMat d_mat = mat_.getGpuMat();
                impl_->copyFrom(d_mat);
            #endif

            break;
        }
    default:
        {
            Mat mat = mat_.getMat();
            impl_->copyFrom(mat, usage_);
        }
    }
#endif
}