Files
HPPA/HPPA/Corning410Imager.cpp
tangchao0503 c1e4144ed6 add
支持corning 410,并添加配置文件
2025-05-09 17:27:04 +08:00

159 lines
3.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Corning410Imager.h"
Corning410Imager::Corning410Imager()
{
//配置文件:如果没有,就创建配置文件
string CfgFile = getPathofEXE() + "\\corning410.cfg";
m_configfile.setConfigfilePath(CfgFile);
if (!m_configfile.isConfigfileExist())
{
m_configfile.createConfigFile();
qDebug() << "create: " << QString::fromStdString(CfgFile);
}
m_configfile.parseConfigfile();
qDebug() << "exist: " << QString::fromStdString(CfgFile);
}
Corning410Imager::~Corning410Imager()
{
if (buffer != nullptr)
{
std::cout << "释放堆上内存" << std::endl;
free(buffer);
free(dark);
free(white);
}
}
double Corning410Imager::getFramerate()
{
return m_imager.get_framerate();
}
double Corning410Imager::getIntegrationTime()
{
return m_imager.get_integration_time();
}
double Corning410Imager::getGain()
{
return m_imager.get_gain();
}
void Corning410Imager::setGain(const double gain)
{
m_imager.set_gain(gain);
}
void Corning410Imager::setFramerate(const double frames_per_second)
{
m_imager.set_framerate(frames_per_second);
m_RgbImage->m_iFramerate = frames_per_second;
}
void Corning410Imager::setIntegrationTime(const double milliseconds)
{
m_imager.set_integration_time(milliseconds);
}
int Corning410Imager::getStartBand()
{
return m_imager.get_start_band();
}
int Corning410Imager::getEndBand()
{
return m_imager.get_end_band();
}
void Corning410Imager::connectImager(const char* camera_sn)
{
m_imager.connect();
//读取配置文件参数,并为相机设置参数
bool ret, ret1, ret2;
int spatialBin;
int spectralBin;
ret1 = m_configfile.getspatialBin(spatialBin);
ret2 = m_configfile.getSpectralBin(spectralBin);
if (ret1 && ret2)
{
bool haha = m_imager.setSpectralBin(spectralBin);
bool haha2 = m_imager.setSpatialBin(spatialBin);
std::cout << "spectralBin" << spectralBin << std::endl;
std::cout << "spatialBin" << spatialBin << std::endl;
}
float gain, offset;
ret = m_configfile.getGainOffset(gain, offset);
if (ret)
{
m_imager.setGainOffset(gain, offset);
}
int width = 0, offsetx = 0, height = 0, offsety = 0;
ret = m_configfile.getEffectiveWindow(width, offsetx, height, offsety);
if (ret)
{
m_imager.setEffectiveWindow(offsetx, width, offsety, height);
}
int bufferPolicy, acqBufferSize;
ret1 = m_configfile.getBufferPolicy(bufferPolicy);
if (ret1)
{
m_imager.setBufferPolicy(bufferPolicy);
}
ret1 = m_configfile.getAcqBufferSize(acqBufferSize);
if (ret1)
{
m_imager.setAcqBufferSize(acqBufferSize);
}
}
void Corning410Imager::disconnectImager()
{
m_imager.disconnect();
}
void Corning410Imager::imagerStartCollect()
{
m_imager.start();
}
void Corning410Imager::imagerStopCollect()
{
m_imager.stop();
}
unsigned short* Corning410Imager::getFrame(unsigned short* buffer)
{
m_imager.get_frame(buffer);
return buffer;
}
void Corning410Imager::setSpectraBin(int new_spectral_bin)
{
}
double Corning410Imager::getWavelengthAtBand(int band)
{
return m_imager.get_wavelength_at_band(band);
}
int Corning410Imager::getBandCount()
{
return m_imager.get_band_count();
}
int Corning410Imager::getSampleCount()
{
return m_imager.get_sample_count();
}