zoukankan      html  css  js  c++  java
  • mat 和IPIImage之间的转换

    opencv2.3.1

    Mat::operator IplImage
    Creates the IplImage header for the matrix.
    C++: Mat::operator IplImage() const
    The operator creates the IplImage header for the matrix without copying the underlying data. You should make sure
    than the original matrix is not deallocated while the IplImage header is used. Similarly to Mat::operator CvMat ,
    the operator is useful for intermixing the new and the old OpenCV API’s.

    imread
    Loads an image from a file.
    C++: Mat imread(const string& filename, int flags=1 )
    Python: cv2.imread(filename[, flags ]) !retval
    C: IplImage* cvLoadImage(const char* filename, int flags=CV_LOAD_IMAGE_COLOR )
    C: CvMat* cvLoadImageM(const char* filename, int flags=CV_LOAD_IMAGE_COLOR )
    Python: cv.LoadImage(filename, flags=CV_LOAD_IMAGE_COLOR)! None
    Python: cv.LoadImageM(filename, flags=CV_LOAD_IMAGE_COLOR)! None
    Parameters
    filename – Name of file to be loaded.
    flags – Flags specifying the color type of a loaded image

    – >0 Return a 3-channel color image
    – =0 Return a grayscale image
    – <0 Return the loaded image as is. Note that in the current implementation the alpha
    channel, if any, is stripped from the output image. For example, a 4-channel RGBA
    image is loaded as RGB if flags  0 .

    Backward conversion from Mat to CvMat or IplImage is provided via cast operators Mat::operator
    CvMat() const and Mat::operator IplImage(). The operators do NOT copy the data.
    IplImage* img = cvLoadImage("greatwave.jpg", 1);
    Mat mtx(img); // convert IplImage* -> Mat
    CvMat oldmat = mtx; // convert Mat -> CvMat
    CV_Assert(oldmat.cols == img->width && oldmat.rows == img->height &&
    oldmat.data.ptr == (uchar*)img->imageData && oldmat.step == img->widthStep);

    是时候好好总结下自己走过的路。
  • 相关阅读:
    虚拟内存分页机制的页面置换
    wait函数的作用
    Kubernetes中Pod生命周期
    ufw 禁用端口未生效
    Kubernetes各个组件的概念
    Kubernetes存储卷的使用
    虚拟内存分页机制的地址映射
    GUNgettext 无效
    响应HTTP服务的shell脚本
    yaml语法
  • 原文地址:https://www.cnblogs.com/haoxing990/p/4574681.html
Copyright © 2011-2022 走看看