opencv从txt文本读取像素点并显示
文本储存格式为每行一个像素点,排列为RGB。每帧图像的帧头为65535. 如下图所示
65535 24 28 16 24 28 16 32 32 24 32 32 32 32 32 32 40 40 40 56 60 56 88 88 88 112 112 112 112 120 112 112 124 120
废话不多说,代码如下:
// #include <iostream> #include <opencv2opencv.hpp> #include <fstream> #include <string> #include <WINSOCK2.H> #include <STDIO.H> #define MAX 32 using namespace cv; using namespace std; Vec3b GetPoint( void ) { Vec3b pixels; //声明像素点储存变量//static int64 count = 0;cout<<count++<<endl; char Buf[MAX];//声明一个buf,用来储存一行 //声明三个空格,用于分割像素点 int firstspace = 0; int secondspace = 0; int thirdspace = 0; //读取一行数据 cin.getline(Buf,MAX); //如果读到的是个回车或者换行,则继续读 while(Buf[0] == '