opencv read_csv

遇到opencv没有CSV文件读取

自己写了个灰度16bit CSV文件的读取

 

#include "opencv.hpp"
#include 
#include 

using namespace std;
using namespace cv;

//one channel
Mat read_csv(char *filepath, Size img_size, int img_type)
{
    Mat image;
    image.create(img_size,img_type);
    string pixel;
    ifstream file(filepath, ifstream::in);
    if (!file) cout << "CSV read fail" << endl;

    int nl= image.rows; // number of lines   
    int nc= image.cols ; // number of columns   

    if (image.isContinuous())
    {  
        // then no padded pixels   
        nc= nc*nl;   
        nl= 1;  // it is now a 1D array   
    }  
    for (int j=0; j(j);  
        for (int i=0; i




 

你可能感兴趣的:(OpenCV)