返回首页

|视频如何转换成一个数组并显示它:嗨,我从TOF相机float数组,我想在一个窗口的形式显示。

相机提供了大量数据。重要的是描述符包含的行和列数(像素)的最大值是200行X 200列。
他们的相机给一些大小相同的浮动阵列:距离,强度(灰度图像),振幅,X,Y和Z每个像素coordenates的。还有包含每个像素falgs的一个无符号数组。
建立图像阵列是一个quot;浮法强度[200 * 200] quot;按行排序(0-199拳头行,第二行200-299 ...)。每个像素的值从0到32000不等,是我用一个建立图像。
我已经这个数组转换为BMP,转换为BMP我用的功能是:

bool CameraClass::GreyImage(float *Array,float max,float min, int width, int height,LPCTSTR bmpfile){

	//Mediante la recta y=Ax+B donde x es un valor de Array

	//Variando min y max se logra modificar el contraste



	float B=min*255/(min-max);

	float A=(255-B)/max;

 



	//BYTE *Buffer;

	//Buffer= new BYTE [3*width*height];

	BYTE Buffer[3*200*200]; //deberia asignarse dinamicamente pero da error! 



	for (int i=0;i<height;i++){

		for(int j=0;j<width;j++){

		Buffer[3*(width*((height-1)-i)+j)]=(BYTE)(A*Array[width*i+j]+B);

		Buffer[3*(width*((height-1)-i)+j)+1]=(BYTE)(A*Array[width*i+j]+B);

		Buffer[3*(width*((height-1)-i)+j)+2]=(BYTE)(A*Array[width*i+j]+B);

		}

	}

	

	long paddedsize=width*height*3;

 

	// declare bmp structures 

	BITMAPFILEHEADER bmfh;

	BITMAPINFOHEADER info;

	

	// andinitialize them to zero

	memset ( &bmfh, 0, sizeof (BITMAPFILEHEADER ) );

	memset ( &info, 0, sizeof (BITMAPINFOHEADER ) );

	

	// fill the fileheader with data

	bmfh.bfType = 0x4d42;       // 0x4d42 = 'BM'

	bmfh.bfReserved1 = 0;

	bmfh.bfReserved2 = 0;

	bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;

	bmfh.bfOffBits = 0x36;		// number of bytes to start of bitmap bits

	

	// fill the infoheader



	info.biSize = sizeof(BITMAPINFOHEADER);

	info.biWidth = width;

	info.biHeight = height;

	info.biPlanes = 1;			// we only have one bitplane

	info.biBitCount = 24;		// RGB mode is 24 bits

	info.biCompression = BI_RGB;	

	info.biSizeImage = 0;		// can be 0 for 24 bit images

	info.biXPelsPerMeter = 0x0ec4;     // paint and PSP use this values

	info.biYPelsPerMeter = 0x0ec4;     

	info.biClrUsed = 0;			// we are in RGB mode and have no palette

	info.biClrImportant = 0;    // all colors are important



	// now we open the file to write to

	HANDLE file = CreateFile ( bmpfile , GENERIC_WRITE, FILE_SHARE_READ,

		 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

	if ( file == NULL )

	{

		CloseHandle ( file );

		return false;

	}

	

	// write file header

	unsigned long bwritten;

	if ( WriteFile ( file, &bmfh, sizeof ( BITMAPFILEHEADER ), &bwritten, NULL ) == false )

	{	

		CloseHandle ( file );

		return false;

	}

	// write infoheader

	if ( WriteFile ( file, &info, sizeof ( BITMAPINFOHEADER ), &bwritten, NULL ) == false )

	{	

		CloseHandle ( file );

		return false;

	}

	// write image data

	if ( WriteFile ( file, Buffer, paddedsize, &bwritten, NULL ) == false )

	{	

		CloseHandle ( file );

		return false;

	}

	

	// and close file

	CloseHandle ( file );

 

	//delete [] Buffer;



	return true;

}//OK

其warks伟大的,但现在我要显示的数据,避免了bmp,Driectly一个视频窗口。

最简单的方法是什么?
感谢您的帮助! LT ;/ b| ddsco

回答