1. fix logic bug
2. add frame ending signal
This commit is contained in:
parent
8c780c8867
commit
1849b598d7
@ -20,8 +20,7 @@ void peakCentering(
|
|||||||
ap_uint<12> WinNum = 0;
|
ap_uint<12> WinNum = 0;
|
||||||
RgnPix InData;
|
RgnPix InData;
|
||||||
InData = InRgnPnt.read();
|
InData = InRgnPnt.read();
|
||||||
ap_uint<1> VSync = InData.Sync.range(1,1);
|
if(0b10 != InData.Sync) //wait for syncFirst
|
||||||
if(0b0 == VSync) //wait for syncFirst
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//1st: frameNo
|
//1st: frameNo
|
||||||
@ -87,6 +86,7 @@ void peakCentering(
|
|||||||
ap_uint<1> evenFlag = 0;
|
ap_uint<1> evenFlag = 0;
|
||||||
ap_uint<5> pkRng_S, pkRng_E;
|
ap_uint<5> pkRng_S, pkRng_E;
|
||||||
ap_uint<1> outFlag = 0;
|
ap_uint<1> outFlag = 0;
|
||||||
|
ap_uint<1> lastSync = 0;
|
||||||
for(int n = 0; n <= WinNum; n ++)
|
for(int n = 0; n <= WinNum; n ++)
|
||||||
{
|
{
|
||||||
#pragma HLS LOOP_TRIPCOUNT min=3072 max=3072
|
#pragma HLS LOOP_TRIPCOUNT min=3072 max=3072
|
||||||
@ -95,24 +95,33 @@ void peakCentering(
|
|||||||
#pragma HLS PIPELINE II=1
|
#pragma HLS PIPELINE II=1
|
||||||
|
|
||||||
RgnPix InData;
|
RgnPix InData;
|
||||||
if(n < WinNum)
|
if(0 == lastSync)
|
||||||
InData = InRgnPnt.read();
|
InData = InRgnPnt.read();
|
||||||
else
|
else
|
||||||
InData = zeroData;
|
InData = zeroData;
|
||||||
|
|
||||||
if(InData.LazerWinY == 0x07ac)
|
if(InData.Sync == 0b11)
|
||||||
|
lastSync = 1;
|
||||||
|
|
||||||
|
if(InData.LazerWinY == 510)
|
||||||
int kkk = 1; //debug point
|
int kkk = 1; //debug point
|
||||||
|
|
||||||
if(0 == i) //HSync
|
if(0 == i) //HSync
|
||||||
{
|
{
|
||||||
evenFlag = n%2;
|
evenFlag = n%2;
|
||||||
|
|
||||||
if(0 == linePk.len)
|
if(0 == linePk.len)
|
||||||
pkCenter = RGN_DATA_WIN_SIZE/2;
|
{
|
||||||
|
if(linePk.value >= 240)
|
||||||
|
pkCenter = RGN_DATA_WIN_SIZE/2;
|
||||||
|
else
|
||||||
|
pkCenter = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pkCenter = linePk.start + (linePk.len >> 1);
|
pkCenter = linePk.start + (linePk.len >> 1);
|
||||||
HSyncData_d1.LazerWinX = LazerWinX_d1 + pkCenter;
|
HSyncData_d1.LazerWinX = LazerWinX_d1 + pkCenter;
|
||||||
|
|
||||||
if ((n > 0) &&( linePk.len>0))
|
if ((n > 0) && ( pkCenter > 0))
|
||||||
{
|
{
|
||||||
OutCenteringPnt.write(HSyncData_d1);
|
OutCenteringPnt.write(HSyncData_d1);
|
||||||
outFlag = 1;
|
outFlag = 1;
|
||||||
@ -172,14 +181,91 @@ void peakCentering(
|
|||||||
currPeak.len = 1;
|
currPeak.len = 1;
|
||||||
currPeak.value = data_1;
|
currPeak.value = data_1;
|
||||||
SM = 0b01;
|
SM = 0b01;
|
||||||
|
linePk.value = data_1; //record initial value
|
||||||
}
|
}
|
||||||
else if(data_0 > data_1) //falling
|
else if(data_0 > data_1) //falling
|
||||||
|
{
|
||||||
SM = 0b10;
|
SM = 0b10;
|
||||||
|
currPeak.value = data_0;
|
||||||
|
linePk.value = data_0; //record initial value
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currPeak.start = wrPos_1;
|
||||||
|
currPeak.len = 1;
|
||||||
|
currPeak.value = data_1;
|
||||||
|
SM = 0b11;
|
||||||
|
linePk.value = data_0; //record initial value
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0b11: //wait state
|
||||||
|
if(lastData < data_0)
|
||||||
|
{
|
||||||
|
if(data_0 < data_1) //rising
|
||||||
|
{
|
||||||
|
currPeak.start = wrPos_1;
|
||||||
|
currPeak.len = 1;
|
||||||
|
currPeak.value = data_1;
|
||||||
|
SM = 0b01;
|
||||||
|
}
|
||||||
|
else if(data_0 > data_1) //falling
|
||||||
|
{
|
||||||
|
if( (wrPos_0 >= pkRng_S) && (wrPos_0 <= pkRng_E) )
|
||||||
|
{
|
||||||
|
linePk.start = wrPos_0;
|
||||||
|
linePk.len = 1;
|
||||||
|
linePk.value = data_0;
|
||||||
|
}
|
||||||
|
SM = 0b10;
|
||||||
|
}
|
||||||
|
else //data_0 == data_1
|
||||||
|
{
|
||||||
|
currPeak.start = wrPos_0;
|
||||||
|
currPeak.len = 2;
|
||||||
|
currPeak.value = data_0;
|
||||||
|
SM = 0b01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(lastData > data_0)
|
||||||
|
{
|
||||||
|
if(data_0 < data_1) //peak is at edge (pos:0,1,2...), invalid
|
||||||
|
{
|
||||||
|
if( (lastData > data_0)&& (wrPos_0 > pkRng_S))
|
||||||
|
{
|
||||||
|
linePk = currPeak;
|
||||||
|
}
|
||||||
|
currPeak.start = wrPos_1;
|
||||||
|
currPeak.len = 1;
|
||||||
|
currPeak.value = data_1;
|
||||||
|
SM = 0b01;
|
||||||
|
}
|
||||||
|
else if(data_0 >= data_1)//falling
|
||||||
|
{
|
||||||
|
SM = 0b10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //lastData == data_0
|
||||||
|
{
|
||||||
|
if(data_0 < data_1) //rising
|
||||||
|
{
|
||||||
|
currPeak.start = wrPos_1;
|
||||||
|
currPeak.len = 1;
|
||||||
|
currPeak.value = data_1;
|
||||||
|
SM = 0b01;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(data_0 > data_1) //falling
|
||||||
|
{
|
||||||
|
SM = 0b10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
currPeak.len += 2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0b01: //rising
|
case 0b01: //rising
|
||||||
if(lastData < data_0)
|
if(lastData < data_0)
|
||||||
{
|
{
|
||||||
if(data_0 < data_1)
|
if(data_0 <= data_1)
|
||||||
{
|
{
|
||||||
currPeak.start = wrPos_1;
|
currPeak.start = wrPos_1;
|
||||||
currPeak.len = 1;
|
currPeak.len = 1;
|
||||||
@ -201,7 +287,6 @@ void peakCentering(
|
|||||||
currPeak.len = 2;
|
currPeak.len = 2;
|
||||||
currPeak.value = data_0;
|
currPeak.value = data_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(lastData > data_0)
|
else if(lastData > data_0)
|
||||||
{
|
{
|
||||||
@ -238,7 +323,16 @@ void peakCentering(
|
|||||||
SM = 0b10; //change to falling
|
SM = 0b10; //change to falling
|
||||||
}
|
}
|
||||||
else //data_0 == dta_1
|
else //data_0 == dta_1
|
||||||
|
{
|
||||||
currPeak.len += 2;
|
currPeak.len += 2;
|
||||||
|
if(i == 8) //last one
|
||||||
|
{
|
||||||
|
if( (currPeak.start <= pkRng_E) && (currPeak.value > linePk.value))
|
||||||
|
{
|
||||||
|
linePk = currPeak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0b10: //falling
|
case 0b10: //falling
|
||||||
@ -290,12 +384,21 @@ void peakCentering(
|
|||||||
stmOut.Sync = 0b00;
|
stmOut.Sync = 0b00;
|
||||||
stmOut.LazerWinX(7,0) = out_0;
|
stmOut.LazerWinX(7,0) = out_0;
|
||||||
stmOut.LazerWinY(7,0) = out_1;
|
stmOut.LazerWinY(7,0) = out_1;
|
||||||
if( (n > 0 ) && (pkCenter > 0) &&(outFlag == 1))
|
if( outFlag == 1)
|
||||||
{
|
{
|
||||||
OutCenteringPnt.write(stmOut);
|
OutCenteringPnt.write(stmOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//add Last sync data
|
||||||
|
RgnPix VSync;
|
||||||
|
VSync.LazerWinFlag = 0;
|
||||||
|
VSync.LazerWinRid = 0;
|
||||||
|
VSync.LazerWinRsv = 0;
|
||||||
|
VSync.LazerWinX = 0;
|
||||||
|
VSync.LazerWinY = 0;
|
||||||
|
VSync.RltvRdx = 0;
|
||||||
|
VSync.Sync = 0b11;
|
||||||
|
OutCenteringPnt.write(VSync);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,17 +18,17 @@ void save_bmp_2(
|
|||||||
fopen_s(&file, filename, "wb");
|
fopen_s(&file, filename, "wb");
|
||||||
#endif
|
#endif
|
||||||
if (!file) {
|
if (!file) {
|
||||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> %s\n", filename);
|
printf("锟睫凤拷锟斤拷锟侥硷拷 %s\n", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD>
|
// 锟斤拷锟斤拷每锟斤拷锟斤拷锟斤拷纸锟斤拷锟<EFBFBD>
|
||||||
int bytes_per_row = RGN_DATA_WIN_SIZE * 3; // ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD>ֽڣ<EFBFBD>BGR<EFBFBD><EFBFBD>
|
int bytes_per_row = RGN_DATA_WIN_SIZE * 3; // 每锟斤拷锟斤拷锟斤拷3锟街节o拷BGR锟斤拷
|
||||||
int padding = (4 - (bytes_per_row % 4)) % 4;
|
int padding = (4 - (bytes_per_row % 4)) % 4;
|
||||||
int row_size = bytes_per_row + padding;
|
int row_size = bytes_per_row + padding;
|
||||||
int height = testSamples.size();
|
int height = testSamples.size();
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ͷ
|
// 锟斤拷始锟斤拷锟侥硷拷头
|
||||||
BMPFileHeader file_header = {
|
BMPFileHeader file_header = {
|
||||||
.file_type = 0x4D42, // 'BM'
|
.file_type = 0x4D42, // 'BM'
|
||||||
.file_size = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + row_size * height,
|
.file_size = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + row_size * height,
|
||||||
@ -36,11 +36,11 @@ void save_bmp_2(
|
|||||||
.reserved2 = 0,
|
.reserved2 = 0,
|
||||||
.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader)
|
.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader)
|
||||||
};
|
};
|
||||||
// <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣͷ
|
// 锟斤拷始锟斤拷锟斤拷息头
|
||||||
BMPInfoHeader info_header = {
|
BMPInfoHeader info_header = {
|
||||||
.size = sizeof(BMPInfoHeader),
|
.size = sizeof(BMPInfoHeader),
|
||||||
.width = RGN_DATA_WIN_SIZE,
|
.width = RGN_DATA_WIN_SIZE,
|
||||||
.height = height, // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
.height = height, // 锟斤拷锟斤拷锟斤拷示锟斤拷锟斤拷锟斤拷锟捷达拷锟铰碉拷锟斤拷锟斤拷锟斤拷
|
||||||
.planes = 1,
|
.planes = 1,
|
||||||
.bit_count = 24,
|
.bit_count = 24,
|
||||||
.compression = 0,
|
.compression = 0,
|
||||||
@ -51,21 +51,21 @@ void save_bmp_2(
|
|||||||
.colors_important = 0
|
.colors_important = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// д<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>Ϣ
|
// 写锟斤拷头锟斤拷息
|
||||||
fwrite(&file_header, 1, sizeof(BMPFileHeader), file);
|
fwrite(&file_header, 1, sizeof(BMPFileHeader), file);
|
||||||
fwrite(&info_header, 1, sizeof(BMPInfoHeader), file);
|
fwrite(&info_header, 1, sizeof(BMPInfoHeader), file);
|
||||||
|
|
||||||
// д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>п<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
// 写锟斤拷锟斤拷锟斤拷锟斤拷锟捷o拷锟斤拷锟斤拷锟揭伙拷锌锟绞硷拷锟<EFBFBD>
|
||||||
uint8_t padding_bytes[3] = { 0, 0, 0 };
|
uint8_t padding_bytes[3] = { 0, 0, 0 };
|
||||||
for (int y = height - 1; y >= 0; y--) {
|
for (int y = height - 1; y >= 0; y--) {
|
||||||
for (int x = 0; x < RGN_DATA_WIN_SIZE; x++) {
|
for (int x = 0; x < RGN_DATA_WIN_SIZE; x++) {
|
||||||
uint8_t pixel = (uint8_t)testSamples[y].data[x];
|
uint8_t pixel = (uint8_t)testSamples[y].data[x];
|
||||||
// <EFBFBD><EFBFBD>RGBתΪBGR˳<EFBFBD><EFBFBD>
|
// 锟斤拷RGB转为BGR顺锟斤拷
|
||||||
fputc(pixel, file); // B
|
fputc(pixel, file); // B
|
||||||
fputc(pixel, file); // G
|
fputc(pixel, file); // G
|
||||||
fputc(pixel, file); // R
|
fputc(pixel, file); // R
|
||||||
}
|
}
|
||||||
fwrite(padding_bytes, 1, padding, file); // <EFBFBD><EFBFBD><EFBFBD>
|
fwrite(padding_bytes, 1, padding, file); // 锟斤拷锟<EFBFBD>
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@ -203,6 +203,15 @@ void genTestSream(
|
|||||||
inStream.write(a_data);
|
inStream.write(a_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//add Last sync data
|
||||||
|
VSync.LazerWinFlag = 0;
|
||||||
|
VSync.LazerWinRid = 0;
|
||||||
|
VSync.LazerWinRsv = 0;
|
||||||
|
VSync.LazerWinX = 0;
|
||||||
|
VSync.LazerWinY = 0;
|
||||||
|
VSync.RltvRdx = 0;
|
||||||
|
VSync.Sync = 0b11;
|
||||||
|
inStream.write(VSync);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,10 +263,12 @@ void convertStreamToArray(
|
|||||||
data16_1(11,0) = VSync.LazerWinX.range(11,0);
|
data16_1(11,0) = VSync.LazerWinX.range(11,0);
|
||||||
*frameROI_y = data16_1;
|
*frameROI_y = data16_1;
|
||||||
//output data
|
//output data
|
||||||
for(int i = 0; i < winNum; i ++)
|
for(int i = 0; i <= winNum; i ++)
|
||||||
{
|
{
|
||||||
RgnPix Hsync = streamData.read();
|
RgnPix Hsync = streamData.read();
|
||||||
if(Hsync.Sync != 0b01)
|
if(Hsync.Sync == 0b11)
|
||||||
|
break;
|
||||||
|
else if(Hsync.Sync != 0b01)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Luma_rgnData a_line;
|
Luma_rgnData a_line;
|
||||||
@ -358,6 +369,7 @@ int main()
|
|||||||
for(int fi = 0; fi < fileSize; fi++)
|
for(int fi = 0; fi < fileSize; fi++)
|
||||||
{
|
{
|
||||||
char fileName[200];
|
char fileName[200];
|
||||||
|
char paraFileName[200];
|
||||||
char outFileName[200];
|
char outFileName[200];
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
sprintf(fileName, "%s%d_L_verilog.txt", InDataPath[n], fi);
|
sprintf(fileName, "%s%d_L_verilog.txt", InDataPath[n], fi);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user