#include "include.h"
void image_send(uint8 *imageData)
{
uint32 i,j;
LPLD_UART_PutChar(UART4,0x01);
LPLD_UART_PutChar(UART4,0xfe);
for (i=0;i<H;i++)
{
for(j=0;j<V;j++)
{
LPLD_UART_PutChar(UART4, *(imageData+i*V+j));
}
}
LPLD_UART_PutChar(UART4,0xfe);
LPLD_UART_PutChar(UART4,0x01);
}
void three(uint16 num)
{
uint8 d=num/1000;
uint8 c=num/100-d*10;
uint8 b=num/10-10*c-d*100;
uint8 a=num%10;
LPLD_UART_PutChar(UART4,0x09);
LPLD_UART_PutChar(UART4,d+0x30);
LPLD_UART_PutChar(UART4,c+0x30);
LPLD_UART_PutChar(UART4,b+0x30);
LPLD_UART_PutChar(UART4,a+0x30);
LPLD_UART_PutChar(UART4,',');
}
void image_fix(uint8 *Image,int16 h,int16 v)
{
uint16 i=0,j=0;
for(i=0;i<10;i++) //分隔符 发送前九个数字
{
LPLD_UART_PutChar(UART4,i+0x30);
for(j=0;j<9;j++)
LPLD_UART_PutChar(UART4,0x20);
}
for(i=0;i<10;i++)//发送后面8个数字
{
LPLD_UART_PutChar(UART4,i+0x30);//发送数字
for(j=0;j<9;j++)
LPLD_UART_PutChar(UART4,0x20);
}
LPLD_UART_PutChar(UART4,0x0d);//回车键
LPLD_UART_PutChar(UART4,0x0a);//换行键
for(i=0;i<10;i++) //列数符
{
for(j=0;j<10;j++)
LPLD_UART_PutChar(UART4,j+0x30);
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
LPLD_UART_PutChar(UART4,j+0x30);
}
LPLD_UART_PutChar(UART4,0x0d);
LPLD_UART_PutChar(UART4,0x0a);
for(i=0;i<h;i++) //发图像
{
for(j=0;j<v;j++)
{
if(!*(Image+v*i+j))
LPLD_UART_PutChar(UART4,0x31);//黑点
else
LPLD_UART_PutChar(UART4,0x20);
}
three(i);
LPLD_UART_PutChar(UART4,0x0d);
LPLD_UART_PutChar(UART4,0x0a);
}
LPLD_UART_PutChar(UART4,0x0d);
LPLD_UART_PutChar(UART4,0x0a);
}
void img_extract(uint8 * dst,uint8 * src,uint32 srclen)
{
uint8 colour[2]={1,0}; //0 和 1 分别对应的颜色
//注:野火的摄像头 0 表示 白色,1表示 黑色
uint8 tmpsrc;
while(srclen --)
{
tmpsrc = *src++;
*dst++ = colour[ (tmpsrc >> 7 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 6 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 5 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 4 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 3 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 2 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 1 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 0 ) & 0x01 ];
}
}
uint16 SampleRow[ROW] = {9,10,11,12,13,14,15,16,17,18,
19,20,21,22,23,24,25,26,27,29,31,33,35,37,39,41,43,45,
47,50,52,54,57,59,62,65,69,72,75,79,83,87,92,96,102
,107,113,118,125,132,139,146,155,163,173,182,192,202,213,224};
void image_select(uint8 *dst,uint8 *src)
{
int16 line=0;
uint8 colour[2]={1,0}; //0 和 1 分别对应的颜色
int16 i=0,j=0;
uint8 tmpsrc=0;
for(i=0;i<H;i++)
{
if(i==SampleRow[line])
{
line++;
for(j=1;j<=V/8;j++)
{
tmpsrc = *(src+i*V/8+j);
*dst++ = colour[ (tmpsrc >> 6 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 4 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 2 ) & 0x01 ];
*dst++ = colour[ (tmpsrc >> 0 ) & 0x01 ];
}
}
}
}
int line[60]={0};
void line_select()
{
int count=0;
for(int i=H-1;i>10;i--)
{
if(imageData[i][160]&&!imageData[i-1][160]&&!imageData[i-2][160])
{
line[count]=i;
count++;
}
if(!imageData[i][160]&&imageData[i-1][160]&&imageData[i-2][160])
{
line[count]=i;
count++;
}
if(count>58)
break;
}
}