opencv 3 私人coedbook

1.Mat对象的类型转化

//原本读入的是 UINT8类型的数据
cv::Mat imOriginal = cv::imread("005_L_2_3.bmp", 0);

//把imPadded转为32为float并赋值给新的Mat a
//这好像涉及到了容器(containers), 暂时不是很清楚
cv::Mat a = cv::Mat_<float>(imPadded);

2 取出Scalar类的元素
Scalar类用于初始化Mat类中的像素值, 这类用法用的不少, 但是当想去除Scalar类对象的一个值时, 却纠结了一下.
用最后用.val[ ]解决
Scalar类.val[ind],

        cv::Scalar nPoints;
        nPoints = cv::sum(patchSet[i]);//求和函数,返回的是一个Scalar类

        //取出nPoints 中第一个数值
        cout << nPoints.val[0]<< endl;

3 对原图像进行类型转化, 并不影响ROI的数据类型

    //对图像进行sobel滤波, 得到imGradient是 CV_32FC1类型
    cv::Sobel(im, imGradient, CV_32FC1, 0, 1);
    imGradient = abs(imGradient);//

    //将imGradient 分为上下两块, i.e.设置两个感兴趣区域(ROI), 
    //其实是得到两个信息头,分别指向imGradient 的上半部分和下半部分
    cv::Size imSize = imGradient.size();
    Mat upperGrad = imGradient(cv::Range(0, imSize.height / 2), cv::Range::all());
    Mat lowerGrad = imGradient(cv::Range(imSize.height / 2, imSize.height), cv::Range::all());

    //将imGradient转化为 CV_8UC1类型
    imGradient.convertTo(imGradient, CV_8UC1);

    /*
    ★此时 imGradient 为CV_8UC1类型, 但是upperGrad 和lowerGrad 依然为CV_32FC1类型
    */
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Paperback: 366 pages Publisher: Packt Publishing - ebooks Account (November 13, 2015) Language: English ISBN-10: 1784399752 ISBN-13: 978-1784399757 About This Book Build computer vision projects to capture high-quality image data, detect and track objects, process the actions of humans or animals, and much more Discover practical and interesting innovations in computer vision while building atop a mature open-source library, OpenCV 3 Familiarize yourself with multiple approaches and theories wherever critical decisions need to be made Who This Book Is For This book is ideal for you if you aspire to build computer vision systems that are smarter, faster, and more practical than the competition. This is an advanced book, intended for those who already have some experience in setting up an OpenCV development environment and building applications with OpenCV. What You Will Learn Select and configure camera systems to see invisible light, fast motion, and distant objects Build a "camera trap", as used by nature photographers, and process photos to create beautiful effects Develop a facial expression recognition system with various feature extraction techniques and machine learning methods Build an Android panorama application using the OpenCV stitching module in C++, with NDK support Optimize your object detection model, make it rotation invariant, and apply scene-specific constraints to make it faster and more robust Create a person identification and registration system based on the biometric properties of that person, such as their fingerprint, iris, and face Fuse data from videos and gyroscopes to stabilize videos shot from your mobile phone and create hyperlapse videos In Detail This book makes use of OpenCV 3 to tackle increasingly challenging computer vision problems. You begin by taking a critical look at inputs, in order to decide which types of light, lenses, and image formats are best suited for a given purpose. You then consider the finer aspects of computational photography as you build an automated camera to assist nature photographers. You will gain

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值