示例#1
0
inline bool BlobShape::equal(const BlobShape &other) const
{
    if (this->dims() != other.dims())
        return false;

    for (int i = 0; i < other.dims(); i++)
    {
        if (sz[i] != other.sz[i])
            return false;
    }

    return true;
}
示例#2
0
    void Blob::fill(const BlobShape &shape, int type, void *data, bool deepCopy)
    {
        CV_Assert(type == CV_32F || type == CV_64F);

        if (deepCopy)
        {
            m.create(shape.dims(), shape.ptr(), type);
            memcpy(m.data, data, m.total() * m.elemSize());
        }
        else
        {
            m = Mat(shape.dims(), shape.ptr(), type, data);
        }
    }
示例#3
0
    Blob::Blob(InputArray image, int dstCn)
    {
        CV_Assert(dstCn == -1 || dstCn > 0);
        std::vector<Mat> inMats = extractMatVector(image);
        BlobShape dstShape = getBlobShpae(inMats, dstCn);

        m.create(dstShape.dims(), dstShape.ptr(), CV_32F);

        std::vector<Mat> wrapBuf(dstShape[-3]);
        int elemSize = (int)m.elemSize();
        uchar *ptr = this->ptr();
        for (size_t i = 0; i < inMats.size(); i++)
        {
            Mat inMat = inMats[i];

            if (inMat.dims <= 2)
            {
                inMat.convertTo(inMat, m.type());

                wrapBuf.resize(0);
                for (int cn = 0; cn < inMat.channels(); cn++)
                {
                    wrapBuf.push_back(Mat(inMat.rows, inMat.cols, m.type(), ptr));
                    ptr += elemSize * inMat.total();
                }

                cv::split(inMat, wrapBuf);
            }
            else
            {
                inMat.convertTo(Mat(inMat.dims, inMat.size, m.type(), ptr), m.type());
                ptr += elemSize * inMat.total();
            }
        }
    }
示例#4
0
 void Blob::create(const BlobShape &shape, int type)
 {
     CV_Assert(type == CV_32F || type == CV_64F);
     m.create(shape.dims(), shape.ptr(), type);
 }