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類型。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章