我将我的 Flir Lepton 相机连接到我的电路板上,并且由于程序 ThermalView(此处的源代码: https ://github.com/groupgets/LeptonModule/tree/master/ ),我试图获得连续的图像流software/ThermalView ) 我在我的板上编译并下载了以下代码:
int main(void)
{
//HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
SystemClock_Config();
leptonEnd();
// LEPTON VDD OFF
HAL_Delay(1000);
// LEPTON VDD ON
HAL_Delay(185);
LeptonConfigure_I2C();
while(1)
{
LeptonReadFrame();
frameToPc();
}
}
// Output image buffer to USART2
void frameToPc()
{
static uint8_t frameSkipper = 0;
uint8_t timeStamp = (HAL_GetTick() - last_frame_millis); // calculate time passed since last been here
last_frame_millis = HAL_GetTick();
if(frameSkipper==4)
{
//PSEDO//
//IMGtoRGB();
////////
uint8_t thermalView_header[] = {0xDE,0xAD,0xBE,0xEF}; // 4-byte header for ThermalView application
HAL_Delay(1000);
HAL_UART_Transmit_DMA(&huart2, &thermalView_header[0], 4); // print header
while(huart2.gState != HAL_UART_STATE_READY); // wait for transmission to complete
HAL_UART_Transmit_DMA(&huart2, &IMG[0], LEPTON_IMG_SIZE_BYTES);
frameSkipper = 0;
}
frameSkipper++;
}uint8_t LeptonReadFrame()
{
uint8_t i, frame_number, frame_complete=0;
uint16_t bad_frame_counter=0;
while(!frame_complete)
{
leptonBegin();
HAL_SPI_Receive(&hspi1, &FramePacket[0], LEPTON_PACKET_LENGTH, 1000); // READ LINE
leptonEnd();
//HAL_UART_Transmit(&huart2, &FramePacket[0], LEPTON_PACKET_LENGTH, 1000); // PRINT LINE
if( (FramePacket[0] & 0x0f) != 0x0f ) // not discard frame
{
frame_number = FramePacket[1];
if(frame_number < 60) // valid frame
{
bad_frame_counter = 0;
for(i= 0; i<LEPTON_PACKET_CONTENT_LENGTH; i++)
{
IMG[frame_number*LEPTON_PACKET_CONTENT_LENGTH+i] = FramePacket[i+4]; // copy line into IMG buffer, ignoring ID and CRC
}
}
else
{
bad_frame_counter++;
}
if(frame_number == 59)
{
frame_complete = 1;
}
if(bad_frame_counter>1000) // 800 lines = 5 bad frames = resync needed
{
bad_frame_counter = 0;
HAL_Delay(185); // CS is already disabled so the delay is enougth
}
}
}
return 1;
}
我成功地获得了一个流,但我必须在每帧之间延迟 1 秒,并且必须在我发送到计算机的 2 帧之间跳过帧。如果您注意到代码中存在阻止提高帧速率的错误,请告诉我。