Code Monkey home page Code Monkey logo

Comments (7)

steven-varga avatar steven-varga commented on August 27, 2024

Thanks for the interest! Can you tell me the relationship between cv::Mat, cvMat_?

from h5cpp.

eudoxos avatar eudoxos commented on August 27, 2024

cv::Mat_ is a thin static-typed accessor for underlying cv::Mat (which can hold data of any type) for convenience. So e.g. cv::Mat with CV_F32 type (float) can be wrapped in cv::Mat_<float>, giving the compiler static knowledge about interpreting the underlying storage.

The type most the time is definitely cv::Mat, though.

from h5cpp.

eudoxos avatar eudoxos commented on August 27, 2024

To explain more, cv::Mat has publicly-accessible rows and cols data members (for array size), the array is stored always as row-major. Rank of cv::Mat is 2 (when cv::Mat::channels()==1, 1-channel per pixel) or 3 (with more channels).

Raw data can be accessed with the data pointer cv::Mat::ptr(), though cv::Mat does not guarantee being continuous — it can be, and often is, a region inside another, larger, cv::Mat, and only proxies access to the "parent" data. This can be checked with cv::Mat::isContinuous(). If not continuous, deep-copy (with continuous storage) can be obtained with cv::Mat::clone().

Type of data stored is accessed with cv::Mat::depth() (which returns the underlying datatype, CV_8U, CV_16U and so on).

from h5cpp.

steven-varga avatar steven-varga commented on August 27, 2024

Thanks, will take a look at it in a week or so -- I am up for a presentation, then a workshop.

A copy (you call it deep copy) may be prohibitively expensive with a large matrix, or in cases when the matrix is half the size of the available memory -- erroneous. The 'continuous' case is relatively easy to handle. I am interested in learning more about the cases where cv::Mat::isContinuous() returns false.
Is this have to do with sub matrices? If I may ask: How are you involved with OpenCV?

from h5cpp.

eudoxos avatar eudoxos commented on August 27, 2024

I am just a regular user of OpenCV. I store most data in Eigen arrays but for some (computer-vision related) algorithms, I map the data to cv::Mat. Dumping those directly to hdf5 would be elegant, but it is mostly a convenience for me.

Non-continuous matrix is a submatrix, yes. Algorithms operate on matrix or sub-matrix (they call it image and region, or region of interest or ROI) without necessarily making the distinction.

The non-continuous case could just fail for now, that would be fair enough. Maybe later some expert (don't think that is me) might write a routine converting ROI information obtained from cv::Mat::locateROI into HDF5 hyperslab specification.

from h5cpp.

steven-varga avatar steven-varga commented on August 27, 2024

An update: thanks for the input! Maybe we could have an online chat on suitable day? I live in Toronto -- time zone wise.
Here is the thing, as it appears OpenCV doesn't use templates to indicate the underlying type, which makes it different from other packages.
The next version H5CPP type system is reworked/upgraded, and can accommodate OpenCV with ease, but won't be available for another few weeks.

The alternative is to make it happen for the current version, and then forward propagate it to the new internal type system. Either way, for an efficient zero copy solution I need to have a good understanding of use case, and behaviour of OpenCV. And perhaps you could help me with that.

best: steve

from h5cpp.

eudoxos avatar eudoxos commented on August 27, 2024

No problem waiting a few weeks for the next type system. I will contact you for a chat, I am Europe-based but we will find some overlap for sure.

from h5cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.