diff --git a/HPPA/ResononNirImager.cpp b/HPPA/ResononNirImager.cpp index afb9750..0536461 100644 --- a/HPPA/ResononNirImager.cpp +++ b/HPPA/ResononNirImager.cpp @@ -104,20 +104,25 @@ void ResononNirImager::setSpectraBin(int new_spectral_bin) double ResononNirImager::auto_exposure() { //第一步:先设置曝光时间为在当前帧率情况下最大 - double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间 + double f = getFramerate(); + double x = 1 / f * 1000;//获取最大毫秒曝光时间 + std::cout << f << "hz帧率下,最大曝光时间为" << x << std::endl; + reConnectImage(); setIntegrationTime(x); //第二步:通过循环寻找最佳曝光时间 imagerStartCollect(); + double tmpTime; while (true) { getFrame(buffer); - if (GetMaxValue(buffer, m_FrameSize) >= 4095) + if (GetMaxValue(buffer, m_FrameSize) >= 16383) { - setIntegrationTime(getIntegrationTime() * 0.8); - std::cout << "自动曝光-----------" << std::endl; + tmpTime = getIntegrationTime() * 0.8; + setIntegrationTime(tmpTime); + std::cout << "自动曝光-----------:" << tmpTime << std::endl; } else { @@ -136,6 +141,22 @@ double ResononNirImager::auto_exposure() return exposureTime; } +unsigned short ResononNirImager::GetMaxValue(unsigned short* dark, int number) +{ + unsigned int max = 0; + for (size_t i = 0; i < number; i++) + { + if (dark[i] > 16383) continue;//IR L为14位 + + if (dark[i] > max) + { + max = dark[i]; + } + } + std::cout << "本帧最大值为" << max << std::endl; + return max; +} + double ResononNirImager::getWavelengthAtBand(int band) { return m_ResononNirImager.get_wavelength_at_band(band); @@ -412,7 +433,7 @@ void ResononNirImager::WriteHdr() outfile << "ENVI\n"; outfile << "interleave = bil\n"; outfile << "data type = 12\n"; - outfile << "bit depth = 12\n"; + outfile << "bit depth = 14\n"; outfile << "byte order = 0\n"; outfile << "samples = " << getSampleCount() << "\n"; outfile << "bands = " << getBandCount() << "\n"; diff --git a/HPPA/ResononNirImager.h b/HPPA/ResononNirImager.h index e518888..b4aab30 100644 --- a/HPPA/ResononNirImager.h +++ b/HPPA/ResononNirImager.h @@ -38,6 +38,8 @@ public: void WriteHdr(); protected: + unsigned short GetMaxValue(unsigned short* dark, int number); + private: void reConnectImage();