• 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);

    是时候好好总结下自己走过的路。
  • 相关阅读:
    C# List的深复制(转)
    asp.net core控制台项目运行
    进度条界面控件
    给窗体做遮罩(另类做法)
    显示列表控件(引用SourceGrid)
    TimeExit 界面无点击定时退出类
    TimeHelp 获取时间戳转换类
    复旦大学2016--2017学年第一学期高等代数I期末考试情况分析
    复旦大学高等代数历届每周一题汇总
    复旦高等代数 I(16级)每周一题
  • 原文地址:https://www.cnblogs.com/haoxing990/p/4574681.html
Copyright © 2020-2023  润新知