OpenCV----深度图读法及concertTo用法;

#include<iostream>
#include<opencv2/highgui.hpp>
#include<opencv2/core/core.hpp>

using namespace cv;
using namespace std;

int main(int argc,char**argv)
{
    cv::Mat color,depth;

    color=imread("/home/finer/Desktop/images/1.png",IMREAD_COLOR);
    depth=imread("/home/finer/Desktop/images/1_depth.png",-1);
    imshow("color image",color);
    imshow("depth image",depth);
    Mat depth1;
    depth.convertTo(depth1,CV_16U,1.0/500);

    waitKey(0);
    for(int i = 0; i<10;++i)
    {
        unsigned short*d =  depth1.ptr<unsigned short>(i+100);
        cout<<d[188]<<endl;
    }
}

上面是指针访问图像像素点的方法,相应的还有指针读取以及迭代器读取。

convertTo 用于将对象图像像素格式转换为指定像素格式。 第三个参数为缩放因子,即每对象图像像素每个值除以500,注意为double类型。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值