fix & add
1、在界面上实现选择相机类型的功能; 2、创建了一个光谱仪操作的纯虚基类(ImagerOperationBase)并实现了大部分的操作,具体类型的光谱仪应继承此类并实现纯虚函数; 3、添加了 resonon 的 nir 320 相机,修改 resonon 的 pica l 相机的实现:继承 ImagerOperationBase; 4、重构类 QMotorDoubleSlider,提高其通用性,所有马达相关的 slider 都使用此类; 5、适配 resonon nir 320 显微镜使用的 2 轴线性平台,有些特殊的马达参数设置(setMotorParamMicroscope 函数)绑定了 nir 的相机类型参数; 6、修改:将线性平台的量程信息保存在cfg配置文件中,并修改配置文件读写类来读写此量程信息;
This commit is contained in:
2
HPPA.sln
2
HPPA.sln
@ -8,7 +8,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj",
|
||||
{B12702AD-ABFB-343A-A199-8E24837244A3} = {B12702AD-ABFB-343A-A199-8E24837244A3}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "..\..\cpp_project_vs2019\vincecontrol\vincecontrol\vincecontrol.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "vincecontrol\vincecontrol.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
293
HPPA/HPPA.cpp
293
HPPA/HPPA.cpp
@ -15,6 +15,37 @@ HPPA::HPPA(QWidget *parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><D0A3>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
if (!configfile.isConfigfileExist())
|
||||
{
|
||||
configfile.createConfigFile();
|
||||
qDebug() << "create: " << QString::fromStdString(HPPACfgFile);
|
||||
}
|
||||
configfile.parseConfigfile();
|
||||
qDebug() << "exist: " << QString::fromStdString(HPPACfgFile);
|
||||
|
||||
/*int max, min;
|
||||
configfile.getPositionRestriction(max, min);
|
||||
|
||||
string sn;
|
||||
configfile.getSN(sn);
|
||||
|
||||
int coarse, fine;
|
||||
configfile.getTuningStepSize(coarse, fine);
|
||||
float fa, fb;
|
||||
configfile.getFitParams(fa, fb);
|
||||
int max_FocusRange, min_FocusRange;
|
||||
configfile.getAutoFocusRange(max_FocusRange, min_FocusRange);
|
||||
|
||||
float StepAnglemar_x, Lead_x, ScaleFactor_x;
|
||||
int SubdivisionMultiples_x;
|
||||
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
|
||||
float StepAnglemar_y, Lead_y, ScaleFactor_y;
|
||||
int SubdivisionMultiples_y;
|
||||
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);*/
|
||||
|
||||
//״̬<D7B4><CCAC>
|
||||
xmotor_state_label1 = new QLabel();
|
||||
ymotor_state_label1 = new QLabel();
|
||||
@ -24,9 +55,6 @@ HPPA::HPPA(QWidget *parent)
|
||||
ui.statusBar->addPermanentWidget(ymotor_state_label1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(this->ui.action_exit, SIGNAL(triggered()), this, SLOT(onExit()));
|
||||
|
||||
//ui.cam_label->setScaledContents(true);
|
||||
@ -108,7 +136,7 @@ HPPA::HPPA(QWidget *parent)
|
||||
|
||||
m_xMotor = nullptr;
|
||||
m_yMotor = nullptr;
|
||||
newMotor();
|
||||
|
||||
|
||||
|
||||
//m_TestXmotorStausThread = new MotorWorkerThread(m_xMotor);
|
||||
@ -136,6 +164,15 @@ HPPA::HPPA(QWidget *parent)
|
||||
QRegExp rx("\\d{0,3}[1-9]$");
|
||||
ui.xmotor_speed_lineEdit->setValidator(new QRegExpValidator(rx));
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
float lead;//<2F><><EFBFBD><EFBFBD>
|
||||
float stepAnglemar;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float scaleFactor;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int subdivisionMultiples;//ϸ<><CFB8><EFBFBD><EFBFBD>
|
||||
float maxRange;
|
||||
configfile.getXMotorParm(stepAnglemar, lead, subdivisionMultiples, scaleFactor, maxRange);
|
||||
|
||||
ui.xmotor_speed_slider->setMultiplier(lead, stepAnglemar, scaleFactor, subdivisionMultiples);
|
||||
ui.xmotor_speed_slider->setRange(0, 3);//5.2734375cm/s=10000<30><30><EFBFBD><EFBFBD>
|
||||
ui.xmotor_speed_slider->setValue(1);
|
||||
connect(this->ui.xmotor_speed_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnXmotorSpeedLineeditEditingFinished()));
|
||||
@ -145,14 +182,14 @@ HPPA::HPPA(QWidget *parent)
|
||||
connect(this->ui.xmotor_location_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnXmotorLocationLineeditEditingFinished()));
|
||||
connect(this->ui.xmotor_location_slider, SIGNAL(valueChanged(double)), this, SLOT(OnXmotorLocationSliderChanged(double)));
|
||||
connect(this->ui.xmotor_location_slider, SIGNAL(sliderReleased()), this, SLOT(OnXmotorLocationSliderReleased()));
|
||||
ui.xmotor_location_slider->setMultiplier(lead, stepAnglemar, scaleFactor, subdivisionMultiples);
|
||||
ui.xmotor_location_slider->setValue(0);
|
||||
|
||||
|
||||
|
||||
|
||||
configfile.getYMotorParm(stepAnglemar, lead, subdivisionMultiples, scaleFactor, maxRange);
|
||||
connect(this->ui.ymotor_location_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnYmotorLocationLineeditEditingFinished()));
|
||||
connect(this->ui.ymotor_location_slider, SIGNAL(valueChanged(double)), this, SLOT(OnYmotorLocationSliderChanged(double)));
|
||||
connect(this->ui.ymotor_location_slider, SIGNAL(sliderReleased()), this, SLOT(OnYmotorLocationSliderReleased()));
|
||||
ui.ymotor_location_slider->setMultiplier(lead, stepAnglemar, scaleFactor, subdivisionMultiples);
|
||||
ui.ymotor_location_slider->setValue(0);
|
||||
|
||||
|
||||
@ -233,38 +270,7 @@ HPPA::HPPA(QWidget *parent)
|
||||
//
|
||||
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><D0A3>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
if (!configfile.isConfigfileExist())
|
||||
{
|
||||
configfile.createConfigFile();
|
||||
qDebug() << "create: " << QString::fromStdString(HPPACfgFile);
|
||||
}
|
||||
configfile.parseConfigfile();
|
||||
qDebug() << "exist: " << QString::fromStdString(HPPACfgFile);
|
||||
|
||||
/*int max, min;
|
||||
configfile.getPositionRestriction(max, min);
|
||||
|
||||
string sn;
|
||||
configfile.getSN(sn);
|
||||
|
||||
int coarse, fine;
|
||||
configfile.getTuningStepSize(coarse, fine);
|
||||
float fa, fb;
|
||||
configfile.getFitParams(fa, fb);
|
||||
int max_FocusRange, min_FocusRange;
|
||||
configfile.getAutoFocusRange(max_FocusRange, min_FocusRange);
|
||||
|
||||
float StepAnglemar_x, Lead_x, ScaleFactor_x;
|
||||
int SubdivisionMultiples_x;
|
||||
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
|
||||
float StepAnglemar_y, Lead_y, ScaleFactor_y;
|
||||
int SubdivisionMultiples_y;
|
||||
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);*/
|
||||
|
||||
|
||||
//
|
||||
connect(ui.objective_table1_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable1Up_btn()));
|
||||
@ -274,12 +280,36 @@ HPPA::HPPA(QWidget *parent)
|
||||
connect(ui.objective_table2_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Up_btn()));
|
||||
connect(ui.objective_table2_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Down_btn()));
|
||||
connect(ui.objective_table2_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Stop_btn()));
|
||||
|
||||
createActionGroups();
|
||||
connect(mImagerGroup, &QActionGroup::triggered, this, &HPPA::selectingImager);
|
||||
}
|
||||
|
||||
void HPPA::createActionGroups()
|
||||
{
|
||||
// Imager Tool Group
|
||||
mImagerGroup = new QActionGroup(this);
|
||||
mImagerGroup->addAction(ui.mActionPica_L);
|
||||
mImagerGroup->addAction(ui.mActionPika_XC2);
|
||||
mImagerGroup->addAction(ui.mActionCorning_410);
|
||||
mImagerGroup->addAction(ui.mActionPica_NIR);
|
||||
|
||||
ui.mActionPica_NIR->setChecked(true);
|
||||
imagerSelected = ui.mActionPica_NIR->objectName();
|
||||
}
|
||||
|
||||
void HPPA::selectingImager(QAction* selectedAction)
|
||||
{
|
||||
imagerSelected = selectedAction->objectName();
|
||||
}
|
||||
|
||||
HPPA::~HPPA()
|
||||
{
|
||||
if (m_Imager != nullptr)
|
||||
m_Imager->~ResononImager();//<2F>ͷ<EFBFBD><CDB7><EFBFBD>Դ
|
||||
{
|
||||
//m_Imager->~ResononNirImager();//<2F>ͷ<EFBFBD><CDB7><EFBFBD>Դ
|
||||
delete m_Imager;
|
||||
}
|
||||
|
||||
if (m_xMotor != nullptr && m_yMotor != nullptr)
|
||||
{
|
||||
@ -296,7 +326,7 @@ HPPA::~HPPA()
|
||||
|
||||
void HPPA::CalculateIntegratioinTimeRange()
|
||||
{
|
||||
double range = 1 / m_Imager->get_framerate() * 1000;//<2F><><EFBFBD><EFBFBD>
|
||||
double range = 1 / m_Imager->getFramerate() * 1000;//<2F><><EFBFBD><EFBFBD>
|
||||
|
||||
ui.IntegratioinTimeSlider->blockSignals(true);//<2F><>ΪsetMaximum<75>ᴥ<EFBFBD><E1B4A5>valueChanged<65>źţ<C5BA><C5A3><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD>setMaximumǰ<6D><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
ui.IntegratioinTimeSlider->setMaximum(range);
|
||||
@ -544,7 +574,7 @@ void HPPA::onActionOpenDirectory()
|
||||
void HPPA::OnFramerateLineeditEditingFinished()
|
||||
{
|
||||
std::cout << "Lineedit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>------------------------------------------" << std::endl;
|
||||
m_Imager->set_framerate(this->ui.framerate_lineEdit->text().toDouble());
|
||||
m_Imager->setFramerate(this->ui.framerate_lineEdit->text().toDouble());
|
||||
ui.FramerateSlider->setValue(ui.framerate_lineEdit->text().toDouble());
|
||||
|
||||
CalculateIntegratioinTimeRange();
|
||||
@ -553,7 +583,7 @@ void HPPA::OnFramerateLineeditEditingFinished()
|
||||
void HPPA::OnFramerateSliderChanged(double framerate)
|
||||
{
|
||||
std::cout << "Slider<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>------------------------------------------" << std::endl;
|
||||
m_Imager->set_framerate(this->ui.framerate_lineEdit->text().toDouble());
|
||||
m_Imager->setFramerate(this->ui.framerate_lineEdit->text().toDouble());
|
||||
ui.framerate_lineEdit->setText(QString::number(framerate));
|
||||
|
||||
CalculateIntegratioinTimeRange();
|
||||
@ -562,26 +592,26 @@ void HPPA::OnFramerateSliderChanged(double framerate)
|
||||
void HPPA::OnIntegratioinTimeEditingFinished()
|
||||
{
|
||||
std::cout << "Lineedit<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>------------------------------------------" << std::endl;
|
||||
m_Imager->set_integration_time(this->ui.integratioin_time_lineEdit->text().toDouble());
|
||||
m_Imager->setIntegrationTime(this->ui.integratioin_time_lineEdit->text().toDouble());
|
||||
ui.IntegratioinTimeSlider->setValue(ui.integratioin_time_lineEdit->text().toDouble());
|
||||
}
|
||||
|
||||
void HPPA::OnIntegratioinTimeSliderChanged(double IntegratioinTime)
|
||||
{
|
||||
std::cout << "Slider<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>------------------------------------------" << std::endl;
|
||||
m_Imager->set_integration_time(IntegratioinTime);
|
||||
m_Imager->setIntegrationTime(IntegratioinTime);
|
||||
ui.integratioin_time_lineEdit->setText(QString::number(IntegratioinTime));
|
||||
}
|
||||
|
||||
void HPPA::OnGainEditingFinished()
|
||||
{
|
||||
m_Imager->set_gain(this->ui.gain_lineEdit->text().toDouble());
|
||||
m_Imager->setGain(this->ui.gain_lineEdit->text().toDouble());
|
||||
ui.GainSlider->setValue(ui.gain_lineEdit->text().toDouble());
|
||||
}
|
||||
|
||||
void HPPA::OnGainSliderChanged(double Gain)
|
||||
{
|
||||
m_Imager->set_gain(this->ui.gain_lineEdit->text().toDouble());
|
||||
m_Imager->setGain(this->ui.gain_lineEdit->text().toDouble());
|
||||
ui.gain_lineEdit->setText(QString::number(Gain));
|
||||
}
|
||||
|
||||
@ -603,7 +633,7 @@ void HPPA::onLeftMouseButtonPressed(int x, int y)
|
||||
ImageReaderWriter *ImageReader = new ImageReaderWriter(imgPath.c_str());
|
||||
|
||||
|
||||
if (x < 0 || x>899 || y<0 || y>ImageReader->getyCount() - 1)
|
||||
if (x < 0 || x>ImageReader->getXCount() || y<0 || y>ImageReader->getyCount() - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -654,6 +684,13 @@ void HPPA::timerEvent(QTimerEvent *event)
|
||||
if (m_xMotor == nullptr || m_yMotor == nullptr)
|
||||
{
|
||||
qDebug() << "Motor pointer is null!!!!!";
|
||||
|
||||
xmotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
SetXMotorWidgetEnable(false);
|
||||
|
||||
ymotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
SetYMotorWidgetEnable(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -727,6 +764,7 @@ void HPPA::onxMotorLeft()
|
||||
|
||||
m_xMotor->EnableMotro();
|
||||
m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
|
||||
//m_xMotor->SettingSpeed(ui.xmotor_speed_lineEdit->text().toLong());
|
||||
m_xMotor->MoveMotar(false);
|
||||
}
|
||||
|
||||
@ -740,6 +778,7 @@ void HPPA::onxMotorRight()
|
||||
|
||||
m_xMotor->EnableMotro();
|
||||
m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
|
||||
//m_xMotor->SettingSpeed(ui.xmotor_speed_lineEdit->text().toLong());
|
||||
m_xMotor->MoveMotar(true);
|
||||
}
|
||||
|
||||
@ -766,6 +805,7 @@ void HPPA::onyMotorForward()
|
||||
|
||||
m_yMotor->EnableMotro();
|
||||
m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
|
||||
//m_yMotor->SettingSpeed(ui.xmotor_speed_lineEdit->text().toLong());
|
||||
m_yMotor->MoveMotar(true);
|
||||
}
|
||||
|
||||
@ -781,6 +821,7 @@ void HPPA::onyMotorBackward()
|
||||
|
||||
m_yMotor->EnableMotro();
|
||||
m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
|
||||
//m_yMotor->SettingSpeed(ui.xmotor_speed_lineEdit->text().toLong());
|
||||
m_yMotor->MoveMotar(false);
|
||||
}
|
||||
|
||||
@ -846,8 +887,8 @@ void HPPA::SetXMotorWidgetEnable(bool enable)
|
||||
ui.test_range_btn->setEnabled(enable);
|
||||
ui.motor_reset_btn->setEnabled(enable);
|
||||
|
||||
//ui.xmotor_left_btn->setEnabled(enable);
|
||||
//ui.xmotor_right_btn->setEnabled(enable);
|
||||
ui.xmotor_left_btn->setEnabled(enable);
|
||||
ui.xmotor_right_btn->setEnabled(enable);
|
||||
ui.xmotor_speed_lineEdit->setEnabled(enable);
|
||||
ui.xmotor_speed_slider->setEnabled(enable);
|
||||
ui.xmotor_location_lineEdit->setEnabled(enable);
|
||||
@ -859,8 +900,8 @@ void HPPA::SetYMotorWidgetEnable(bool enable)
|
||||
ui.test_range_btn->setEnabled(enable);
|
||||
ui.motor_reset_btn->setEnabled(enable);
|
||||
|
||||
//ui.ymotor_forward_btn->setEnabled(enable);
|
||||
//ui.ymotor_backward_btn->setEnabled(enable);
|
||||
ui.ymotor_forward_btn->setEnabled(enable);
|
||||
ui.ymotor_backward_btn->setEnabled(enable);
|
||||
ui.ymotor_location_lineEdit->setEnabled(enable);
|
||||
ui.ymotor_location_slider->setEnabled(enable);
|
||||
}
|
||||
@ -870,28 +911,17 @@ void HPPA::setMotorRange()
|
||||
try
|
||||
{
|
||||
//<2F><>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> <20><> <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
float xMotorRange;
|
||||
float yMotorRange;
|
||||
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
string xMotorRangeFilePath = directory + "\\xMotorRange";
|
||||
string yMotorRangeFilePath = directory + "\\yMotorRange";
|
||||
float lead;//<2F><><EFBFBD><EFBFBD>
|
||||
float stepAnglemar;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float scaleFactor;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int subdivisionMultiples;//ϸ<><CFB8><EFBFBD><EFBFBD>
|
||||
|
||||
configfile.getXMotorParm(stepAnglemar, lead, subdivisionMultiples, scaleFactor, xMotorRange);
|
||||
configfile.getYMotorParm(stepAnglemar, lead, subdivisionMultiples, scaleFactor, yMotorRange);
|
||||
|
||||
FILE * xMotorRangeFile = fopen(xMotorRangeFilePath.c_str(), "r+b");
|
||||
FILE * yMotorRangeFile = fopen(yMotorRangeFilePath.c_str(), "r+b");
|
||||
|
||||
|
||||
//FILE * xMotorRangeFile = fopen("xMotorRange", "r+b");
|
||||
//FILE * yMotorRangeFile = fopen("yMotorRange", "r+b");
|
||||
|
||||
double xMotorRange;
|
||||
double yMotorRange;
|
||||
|
||||
fread(&xMotorRange, sizeof(double), 1, xMotorRangeFile);
|
||||
fread(&yMotorRange, sizeof(double), 1, yMotorRangeFile);
|
||||
|
||||
fclose(xMotorRangeFile);
|
||||
fclose(yMotorRangeFile);
|
||||
|
||||
//std::cout << "xMotorRange<67><65>" << xMotorRange << std::endl;
|
||||
//std::cout << "yMotorRange<67><65>" << yMotorRange << std::endl;
|
||||
@ -1100,10 +1130,10 @@ void HPPA::ontimerTestRangeOfxMotor()
|
||||
{
|
||||
if (isMotorConnected(m_xMotor))
|
||||
{
|
||||
std::cout << "x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
qDebug() << "x TestRangeOfxMotor: x motor is bad+++++++++++++++++++++++++++++++++++++++++++";
|
||||
return;
|
||||
}
|
||||
|
||||
//qDebug() << "x TestRangeOfxMoto: start+++++++++++++++++++++++++++++++++++++++++++";
|
||||
|
||||
ByteBack MotorState = m_xMotor->GetState();
|
||||
//std::cout << "x<><78><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>" << MotorState.Speed << std::endl;
|
||||
@ -1111,7 +1141,7 @@ void HPPA::ontimerTestRangeOfxMotor()
|
||||
|
||||
if (MotorState.Speed == 0 && MotorState.Location == 0)//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ϊ0<CEAA>ĵط<C4B5>
|
||||
{
|
||||
std::cout << "<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
qDebug() << "x TestRangeOfxMotor: speed is 0<><30>reach to original point+++++++++++++++++++++++++++++++++++++++++++";
|
||||
|
||||
m_xMotor->EnableMotro();
|
||||
m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
|
||||
@ -1120,21 +1150,15 @@ void HPPA::ontimerTestRangeOfxMotor()
|
||||
|
||||
if (MotorState.Speed == 0 && MotorState.Location != 0)//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵط<C4B5>
|
||||
{
|
||||
qDebug() << "x TestRangeOfxMotor: speed is 0, reach to most far point, completed+++++++++++++++++++++++++++++++++++++++++++";
|
||||
|
||||
m_xMotor->MoveToLocation(0);
|
||||
m_timerTestRangeOfxMotor->stop();
|
||||
|
||||
double maxDistance = ui.xmotor_location_slider->getDistanceFromPulse(MotorState.Location);
|
||||
|
||||
//<2F><>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> <20><> <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
string xMotorRangeFile = directory + "\\xMotorRange";
|
||||
|
||||
FILE * motorRange = fopen(xMotorRangeFile.c_str(), "w+b");
|
||||
|
||||
fwrite(&maxDistance, sizeof(double), 1, motorRange);
|
||||
fclose(motorRange);
|
||||
configfile.setMaxRange(maxDistance, "x");
|
||||
|
||||
ui.xmotor_location_slider->setMaximum(maxDistance);
|
||||
ui.xmotor_max_location_label->setText(QString::number(ui.xmotor_location_slider->maximum()));
|
||||
@ -1150,15 +1174,17 @@ void HPPA::ontimerTestRangeOfyMotor()
|
||||
{
|
||||
if (isMotorConnected(m_yMotor))
|
||||
{
|
||||
std::cout << "y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
qDebug() << "y TestRangeOfxMotor: y motor is bad+++++++++++++++++++++++++++++++++++++++++++";
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBack MotorState = m_yMotor->GetState();
|
||||
int a = 1;
|
||||
//qDebug() << "y TestRangeOfyMoto: start";
|
||||
|
||||
if (MotorState.Speed == 0 && MotorState.Location == 0)//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ϊ0<CEAA>ĵط<C4B5>
|
||||
{
|
||||
std::cout << "<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
qDebug() << "y TestRangeOfyMotor: speed is 0<><30>reach to original point+++++++++++++++++++++++++++++++++++++++++++";
|
||||
|
||||
m_yMotor->EnableMotro();
|
||||
m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
|
||||
@ -1167,20 +1193,15 @@ void HPPA::ontimerTestRangeOfyMotor()
|
||||
|
||||
if (MotorState.Speed == 0 && MotorState.Location != 0)//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵط<C4B5>
|
||||
{
|
||||
qDebug() << "y TestRangeOfyMotor: speed is 0, reach to most far point, completed+++++++++++++++++++++++++++++++++++++++++++";
|
||||
|
||||
m_yMotor->MoveToLocation(0);
|
||||
m_timerTestRangeOfyMotor->stop();
|
||||
|
||||
double maxDistance = ui.ymotor_location_slider->getDistanceFromPulse(MotorState.Location);
|
||||
|
||||
//<2F><>y<EFBFBD><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> <20><> <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
string yMotorRangeFile = directory + "\\yMotorRange";
|
||||
|
||||
FILE * motorRange = fopen(yMotorRangeFile.c_str(), "w+b");
|
||||
fwrite(&maxDistance, sizeof(double), 1, motorRange);
|
||||
fclose(motorRange);
|
||||
configfile.setMaxRange(maxDistance, "y");
|
||||
|
||||
ui.ymotor_location_slider->setMaximum(maxDistance);
|
||||
ui.ymotor_max_location_label->setText(QString::number(ui.ymotor_location_slider->maximum()));
|
||||
@ -1680,11 +1701,47 @@ void HPPA::newMotor()
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
m_xMotor = new VinceControl(NETTCP, 6002);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_yMotor = new VinceControl(NETTCP, 6001);//ԭ<><D4AD><EFBFBD><EFBFBD>6001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>6003
|
||||
if (imagerSelected == "mActionPica_NIR")
|
||||
{
|
||||
connect(m_xMotor, SIGNAL(newTCPConnection(VinceControl*)), this, SLOT(setMotorParamMicroscope(VinceControl*)));
|
||||
connect(m_yMotor, SIGNAL(newTCPConnection(VinceControl*)), this, SLOT(setMotorParamMicroscope(VinceControl*)));
|
||||
}
|
||||
|
||||
m_xConnectCount = 0;
|
||||
m_yConnectCount = 0;
|
||||
|
||||
connect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
|
||||
connect(m_yMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
|
||||
|
||||
//connect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
|
||||
//connect(m_yMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
|
||||
}
|
||||
|
||||
void HPPA::setMotorParamMicroscope(VinceControl* motor)
|
||||
{
|
||||
//<2F><><EFBFBD><CEA2>nir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QString commonstr;
|
||||
QByteArray buf;
|
||||
|
||||
commonstr = "cfg msr=2\n";
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
commonstr = "cfg msv=1\n";
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
|
||||
commonstr = "cfg psr=1\n";
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
commonstr = "cfg psv=1\n";
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
|
||||
commonstr = "cfg zsd=-3000\n";//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD>ٶȺͷ<C8BA><CDB7><EFBFBD>
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
|
||||
commonstr = "cfg snr=1\n";//<2F><><EFBFBD>ù<EFBFBD><C3B9>㴫<EFBFBD><E3B4AB><EFBFBD><EFBFBD>
|
||||
motor->SendCommandtoMotor(commonstr, "non");
|
||||
motor->GetCommonRetrun(buf);
|
||||
}
|
||||
|
||||
void HPPA::deleteMotor()
|
||||
@ -1775,7 +1832,33 @@ void HPPA::onconnect()
|
||||
{
|
||||
//<2F>ɼ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>вɼ<D0B2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD>濨<EFBFBD><E6BFA8><EFBFBD><EFBFBD>https://www.cnblogs.com/xia-weiwen/p/10306089.html
|
||||
m_RecordThread = new QThread();
|
||||
m_Imager = new ResononImager();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mImagerGroup
|
||||
if (imagerSelected == "mActionPica_L")
|
||||
{
|
||||
m_Imager = new ResononPicaLImager();
|
||||
}
|
||||
else if (imagerSelected == "mActionPica_NIR")
|
||||
{
|
||||
m_Imager = new ResononNirImager();
|
||||
}
|
||||
else if (imagerSelected == "mActionPika_XC2")
|
||||
{
|
||||
|
||||
}
|
||||
else if (imagerSelected == "mActionCorning_410")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
msgBox.exec();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_Imager->moveToThread(m_RecordThread);
|
||||
m_RecordThread->start();
|
||||
|
||||
@ -1787,6 +1870,8 @@ void HPPA::onconnect()
|
||||
connect(m_Imager, SIGNAL(SpectralSignal(int)), this, SLOT(PlotSpectral(int)));
|
||||
//connect(m_Imager, SIGNAL(testImagerStatus()), this, SLOT(testImagerStatus()));
|
||||
|
||||
newMotor();//<2F><><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ƽ̨<C6BD><CCA8><EFBFBD>ò<EFBFBD>ͬ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3B4B4BD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_CopyFileThread = new QThread();
|
||||
@ -1843,18 +1928,20 @@ void HPPA::onconnect()
|
||||
ui.gain_lineEdit->setValidator(new QRegExpValidator(rx));*/
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ui.framerate_lineEdit->setText(QString::number(m_Imager->get_framerate(), 10, 2));
|
||||
ui.FramerateSlider->setValue(m_Imager->get_framerate(), true);
|
||||
ui.framerate_lineEdit->setText(QString::number(m_Imager->getFramerate(), 10, 2));
|
||||
ui.FramerateSlider->setValue(m_Imager->getFramerate(), true);
|
||||
CalculateIntegratioinTimeRange();
|
||||
|
||||
ui.integratioin_time_lineEdit->setText(QString::number(m_Imager->get_integration_time(), 10, 2));
|
||||
ui.IntegratioinTimeSlider->setValue(m_Imager->get_integration_time());
|
||||
ui.integratioin_time_lineEdit->setText(QString::number(m_Imager->getIntegrationTime(), 10, 2));
|
||||
ui.IntegratioinTimeSlider->setValue(m_Imager->getIntegrationTime());
|
||||
|
||||
ui.gain_lineEdit->setText(QString::number(m_Imager->get_gain(), 10, 2));
|
||||
ui.GainSlider->setValue(m_Imager->get_gain());
|
||||
ui.gain_lineEdit->setText(QString::number(m_Imager->getGain(), 10, 2));
|
||||
ui.GainSlider->setValue(m_Imager->getGain());
|
||||
}
|
||||
catch (...)
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
|
||||
delete m_Imager;
|
||||
m_Imager = nullptr;
|
||||
|
||||
|
17
HPPA/HPPA.h
17
HPPA/HPPA.h
@ -33,6 +33,8 @@
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
|
||||
#include "ResononNirImager.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
@ -44,9 +46,9 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
ResononImager *m_Imager;
|
||||
ImagerOperationBase*m_Imager;
|
||||
|
||||
WorkerThread(ResononImager * Imager)
|
||||
WorkerThread(ImagerOperationBase* Imager)
|
||||
{
|
||||
m_Imager = Imager;
|
||||
}
|
||||
@ -163,8 +165,10 @@ private:
|
||||
QLabel * xmotor_state_label1;
|
||||
QLabel * ymotor_state_label1;
|
||||
|
||||
Configfile configfile;
|
||||
|
||||
ForLoopControl * m_ForLoopControl;
|
||||
ResononImager * m_Imager;//
|
||||
ImagerOperationBase* m_Imager;//
|
||||
|
||||
int m_RecordState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>̣<EFBFBD>ȡ2<C8A1><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD>0 <20><> ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
|
||||
@ -205,6 +209,7 @@ private:
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
void deleteMotor();
|
||||
void newMotor();
|
||||
|
||||
bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
||||
void SetXMotorWidgetEnable(bool enable);
|
||||
void SetYMotorWidgetEnable(bool enable);
|
||||
@ -224,6 +229,11 @@ private:
|
||||
|
||||
void getRequest(QString str);
|
||||
|
||||
QActionGroup* mImagerGroup = nullptr;
|
||||
QString imagerSelected;
|
||||
void createActionGroups();
|
||||
void selectingImager(QAction* selectedAction);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage();
|
||||
void PlotSpectral(int state);
|
||||
@ -258,6 +268,7 @@ public Q_SLOTS:
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
void timerEvent(QTimerEvent *event);
|
||||
void setMotorParamMicroscope(VinceControl* motor);
|
||||
|
||||
|
||||
void onxMotorLeft();
|
||||
|
180
HPPA/HPPA.ui
180
HPPA/HPPA.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>2213</width>
|
||||
<height>1262</height>
|
||||
<width>1643</width>
|
||||
<height>831</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,7 +18,7 @@
|
||||
<normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(240, 240, 240);</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
@ -51,7 +51,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -92,7 +92,20 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-size:1px;</string>
|
||||
<string notr="true">QGroupBox {
|
||||
/* border: 2px solid #3498db; 边框颜色 */
|
||||
border-radius: 5px; /* 圆角 */
|
||||
padding: 10px; /* 内边距 */
|
||||
background-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
QGroupBox:title {
|
||||
subcontrol-position: top left; /* 标题位置 */
|
||||
padding: 0 10px; /* 标题内边距 */
|
||||
font-weight: bold; /* 标题字体加粗 */
|
||||
color: #3498db; /* 标题文字颜色 */
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
@ -101,14 +114,14 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="open_rgb_camera_btn">
|
||||
<property name="text">
|
||||
<string>打开摄像头</string>
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="close_rgb_camera_btn">
|
||||
<property name="text">
|
||||
<string>关闭摄像头</string>
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -284,12 +297,33 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTabWidget::pane {
|
||||
border: 1px solid #ccc; /* 选项卡面板边框颜色 */
|
||||
border-radius: 5px; /* 选项卡面板圆角 */
|
||||
|
||||
}
|
||||
|
||||
QTabBar::tab {
|
||||
background: #f0f0f0; /* 选项卡背景颜色 */
|
||||
border: 1px solid #ccc; /* 选项卡边框颜色 */
|
||||
padding: 10px; /* 内边距 */
|
||||
border-radius: 5px; /* 选项卡圆角 */
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
QTabBar::tab:selected {
|
||||
background: #3498db; /* 激活状态选项卡背景颜色 */
|
||||
color: white; /* 激活状态选项卡文字颜色 */
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>camera</string>
|
||||
<string>光谱仪</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
@ -456,6 +490,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="gain_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
@ -483,6 +523,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSlider" name="GainSlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -507,7 +553,7 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>stage</string>
|
||||
<string>线性平台</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
@ -642,7 +688,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>马达量程检测</string>
|
||||
<string>量程检测</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1055,9 +1101,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QGroupBox" name="groupBox_9">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -1160,7 +1206,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QYMotorDoubleSlider" name="ymotor_location_slider">
|
||||
<widget class="QMotorDoubleSlider" name="ymotor_location_slider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@ -1799,28 +1845,56 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>2213</width>
|
||||
<height>30</height>
|
||||
<width>1643</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QMenuBar{
|
||||
background:rgb(255,255,255);
|
||||
color:rgb(0,0,0);
|
||||
font-size:16px;
|
||||
padding:2px;
|
||||
border:1px solid rgb(165,171,184);
|
||||
}
|
||||
QMenuBar::item{
|
||||
background:rgb(255,255,255);
|
||||
width:52px;
|
||||
height:24px;
|
||||
}
|
||||
QMenuBar::item:selected{
|
||||
background:rgb(185,196,221);
|
||||
}
|
||||
QMenu{
|
||||
background:rgb(255,255,255);
|
||||
color:rgb(0,0,0);
|
||||
border:1px solid rgb(165,171,184);
|
||||
}
|
||||
QMenu::item:selected{
|
||||
background:rgb(69,123,255);
|
||||
color:white;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="file">
|
||||
<property name="title">
|
||||
<string>file</string>
|
||||
<string>文件</string>
|
||||
</property>
|
||||
<addaction name="action_exit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuspectrometer">
|
||||
<property name="title">
|
||||
<string>spectrometer</string>
|
||||
<string>光谱仪</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
<property name="title">
|
||||
<string>选择相机类型</string>
|
||||
</property>
|
||||
<addaction name="actionpica_L"/>
|
||||
<addaction name="actionPika_XC2"/>
|
||||
<addaction name="mActionPica_L"/>
|
||||
<addaction name="mActionPica_NIR"/>
|
||||
<addaction name="mActionPika_XC2"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actioncorning_410"/>
|
||||
<addaction name="mActionCorning_410"/>
|
||||
</widget>
|
||||
<addaction name="menu"/>
|
||||
<addaction name="action_connect_imager"/>
|
||||
@ -1836,7 +1910,7 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuhelp">
|
||||
<property name="title">
|
||||
<string>help</string>
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
<addaction name="action_about"/>
|
||||
</widget>
|
||||
@ -1851,6 +1925,23 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QToolBar{
|
||||
background:rgb(255,255,255);
|
||||
color:rgb(0,0,0);
|
||||
}
|
||||
QToolBar QToolButton {
|
||||
background: rgb(255,255,255); /* 按钮背景颜色 */
|
||||
font-size:15px;
|
||||
border-radius: 3px; /* 按钮圆角 */
|
||||
padding: 4px; /* 按钮内边距 */
|
||||
}
|
||||
QToolBar QToolButton:hover {
|
||||
background: rgb(185,196,221); /* 按钮悬停背景颜色 */
|
||||
color: white; /* 按钮悬停文字颜色 */
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
@ -1865,10 +1956,21 @@
|
||||
<addaction name="action_start_recording"/>
|
||||
<addaction name="actionOpenDirectory"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QStatusBar" name="statusBar">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QStatusBar {
|
||||
|
||||
background-color: rgb(255, 255, 255);
|
||||
color: white; /* 文字颜色 */
|
||||
border-top: 1px solid #ccc; /* 顶部边框 */
|
||||
padding: 5px; /* 内边距 */
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
<action name="action_exit">
|
||||
<property name="text">
|
||||
<string>exit</string>
|
||||
<string>退出</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_open">
|
||||
@ -1919,24 +2021,41 @@
|
||||
<string>打开文件夹</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionpica_L">
|
||||
<action name="mActionPica_L">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pika L</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actioncorning_410">
|
||||
<action name="mActionCorning_410">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Corning 410</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPika_XC2">
|
||||
<action name="mActionPika_XC2">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pika XC2</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_about">
|
||||
<property name="text">
|
||||
<string>about</string>
|
||||
<string>关于</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionPica_NIR">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pika NIR</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
@ -1957,11 +2076,6 @@
|
||||
<extends>QGraphicsView</extends>
|
||||
<header location="global">imagerpositionsimulation.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QYMotorDoubleSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header location="global">QYMotorDoubleSlider.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="HPPA.qrc"/>
|
||||
|
@ -55,16 +55,17 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA - 副本\vincecontrol;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA - 副本\vincecontrol\x64\Debug;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;$(IncludePath)</IncludePath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
@ -72,7 +73,8 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
@ -104,16 +106,18 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="aboutWindow.cpp" />
|
||||
<ClCompile Include="hppaConfigFile.cpp" />
|
||||
<ClCompile Include="ImagerOperationBase.cpp" />
|
||||
<ClCompile Include="path_tc.cpp" />
|
||||
<ClCompile Include="QDoubleSlider.cpp" />
|
||||
<ClCompile Include="QMotorDoubleSlider.cpp" />
|
||||
<ClCompile Include="QYMotorDoubleSlider.cpp" />
|
||||
<ClCompile Include="resononImager.cpp" />
|
||||
<ClCompile Include="ResononNirImager.cpp" />
|
||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utility_tc.cpp" />
|
||||
<QtRcc Include="HPPA.qrc" />
|
||||
<QtUic Include="about.ui" />
|
||||
<QtUic Include="FocusDialog.ui" />
|
||||
@ -140,16 +144,18 @@
|
||||
<QtMoc Include="image2display.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
<QtMoc Include="aboutWindow.h" />
|
||||
<ClInclude Include="hppaConfigFile.h" />
|
||||
<ClInclude Include="imageProcessor.h" />
|
||||
<ClInclude Include="ImageReaderWriter.h" />
|
||||
<QtMoc Include="ImagerOperationBase.h" />
|
||||
<ClInclude Include="path_tc.h" />
|
||||
<ClInclude Include="ResononNirImager.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<QtMoc Include="RgbCameraOperation.h" />
|
||||
<QtMoc Include="resononImager.h" />
|
||||
<QtMoc Include="QYMotorDoubleSlider.h" />
|
||||
<QtMoc Include="QMotorDoubleSlider.h" />
|
||||
<QtMoc Include="QDoubleSlider.h" />
|
||||
<QtMoc Include="ImageViewer.h" />
|
||||
|
@ -70,9 +70,6 @@
|
||||
<ClCompile Include="QMotorDoubleSlider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="QYMotorDoubleSlider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="resononImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -91,6 +88,15 @@
|
||||
<ClCompile Include="path_tc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ResononNirImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImagerOperationBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utility_tc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -117,9 +123,6 @@
|
||||
<QtMoc Include="QMotorDoubleSlider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="QYMotorDoubleSlider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="resononImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -129,6 +132,9 @@
|
||||
<QtMoc Include="aboutWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="ImagerOperationBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -149,6 +155,12 @@
|
||||
<ClInclude Include="path_tc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ResononNirImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utility_tc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
|
399
HPPA/ImagerOperationBase.cpp
Normal file
399
HPPA/ImagerOperationBase.cpp
Normal file
@ -0,0 +1,399 @@
|
||||
#include "ImagerOperationBase.h"
|
||||
|
||||
ImagerOperationBase::ImagerOperationBase()
|
||||
{
|
||||
m_iFrameCounter = 1;
|
||||
m_bRecordControlState = true;
|
||||
|
||||
m_FileName2Save = "tmp_image";
|
||||
m_FileSavedCounter = 1;
|
||||
|
||||
m_RgbImage = new CImage();
|
||||
|
||||
buffer = nullptr;
|
||||
dark = nullptr;
|
||||
white = nullptr;
|
||||
|
||||
m_HasDark = false;
|
||||
m_HasWhite = false;
|
||||
m_bFocusControlState = false;
|
||||
}
|
||||
|
||||
ImagerOperationBase::~ImagerOperationBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImagerOperationBase::connect_imager(int frameNumber)
|
||||
{
|
||||
connectImager();
|
||||
setIntegrationTime(1);
|
||||
setFramerate(30.0);
|
||||
//set_gain(0);
|
||||
|
||||
//m_ResononNirImager.set_spectral_bin(2);
|
||||
|
||||
set_buffer();
|
||||
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), frameNumber);
|
||||
m_iFrameNumber = frameNumber;
|
||||
|
||||
emit testImagerStatus();
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
}
|
||||
|
||||
double ImagerOperationBase::auto_exposure()
|
||||
{
|
||||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double x = 1 / getFramerate() * 1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
setIntegrationTime(x);
|
||||
|
||||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
imagerStartCollect();
|
||||
|
||||
while (true)
|
||||
{
|
||||
getFrame(buffer);
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||
{
|
||||
setIntegrationTime(getIntegrationTime() * 0.8);
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
imagerStopCollect();
|
||||
|
||||
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
|
||||
|
||||
return getIntegrationTime();
|
||||
}
|
||||
|
||||
void ImagerOperationBase::focus()
|
||||
{
|
||||
m_iFocusFrameCounter = 1;
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
|
||||
|
||||
double tmpFrmerate = getFramerate();
|
||||
double tmpIntegrationTime = getIntegrationTime();
|
||||
|
||||
|
||||
setFramerate(5);
|
||||
auto_exposure();
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
||||
|
||||
imagerStartCollect();
|
||||
|
||||
//emit SpectralSignal(1);
|
||||
m_bFocusControlState = true;
|
||||
while (m_bFocusControlState)
|
||||
{
|
||||
getFrame(buffer);
|
||||
//m_RgbImage->FillFocusGrayImage(buffer);
|
||||
m_RgbImage->FillFocusGrayQImage(buffer);
|
||||
|
||||
emit SpectralSignal(1);
|
||||
|
||||
++m_iFocusFrameCounter;
|
||||
}
|
||||
emit SpectralSignal(0);
|
||||
|
||||
imagerStopCollect();
|
||||
|
||||
setFramerate(tmpFrmerate);
|
||||
setIntegrationTime(tmpIntegrationTime);
|
||||
}
|
||||
|
||||
void ImagerOperationBase::record_dark()
|
||||
{
|
||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
imagerStartCollect();
|
||||
getFrame(dark);
|
||||
imagerStopCollect();
|
||||
|
||||
m_HasDark = true;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::record_white()
|
||||
{
|
||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
imagerStartCollect();
|
||||
getFrame(white);
|
||||
imagerStopCollect();
|
||||
|
||||
//<2F>װ<EFBFBD><D7B0>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_HasDark)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
if (white[i] < dark[i])
|
||||
{
|
||||
white[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
white[i] = white[i] - dark[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_HasWhite = true;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::start_record()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
|
||||
m_iFrameCounter = 0;
|
||||
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
|
||||
m_bRecordControlState = true;
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (buffer == 0)
|
||||
{
|
||||
std::cerr << "Error: memory could not be allocated for datacube";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
|
||||
|
||||
FILE* m_fImage = fopen(imgPath.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
double pixelValueTmp;
|
||||
|
||||
imagerStartCollect();
|
||||
while (m_bRecordControlState)
|
||||
{
|
||||
m_iFrameCounter++;
|
||||
|
||||
getFrame(buffer);
|
||||
|
||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
||||
if (m_HasDark)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
if (buffer[i] < dark[i])
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = buffer[i] - dark[i];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_HasWhite)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (white[i] != 0)
|
||||
{
|
||||
pixelValueTmp = buffer[i];
|
||||
buffer[i] = (pixelValueTmp / white[i]) * 10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||
|
||||
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
||||
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
|
||||
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal();
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||
}
|
||||
|
||||
//QThread::msleep(1001);
|
||||
fclose(m_fImage);
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFrameNumber(int FrameNumber)
|
||||
{
|
||||
m_iFrameNumber = FrameNumber;
|
||||
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFileName2Save(string FileName)
|
||||
{
|
||||
m_FileName2Save = FileName;
|
||||
m_FileSavedCounter = 1;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
|
||||
{
|
||||
m_bFocusControlState = FocusControlState;
|
||||
}
|
||||
|
||||
int ImagerOperationBase::GetFrameSize(int& iWidth, int& iHeight)
|
||||
{
|
||||
/*using namespace GENAPI_NAMESPACE;
|
||||
using namespace std;
|
||||
INodeMap& nodemap = m_phCamera->GetNodeMap();
|
||||
|
||||
iWidth = (int)CIntegerPtr(nodemap.GetNode("Width"))->GetValue();
|
||||
iHeight = (int)CIntegerPtr(nodemap.GetNode("Height"))->GetValue();*/
|
||||
|
||||
iWidth = getSampleCount();
|
||||
iHeight = getBandCount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CImage* ImagerOperationBase::getRgbImage() const
|
||||
{
|
||||
return m_RgbImage;
|
||||
}
|
||||
|
||||
cv::Mat* ImagerOperationBase::getMatRgbImage() const
|
||||
{
|
||||
return m_RgbImage->m_matRgbImage;
|
||||
}
|
||||
|
||||
cv::Mat* ImagerOperationBase::getMatFocusGrayImage() const
|
||||
{
|
||||
return m_RgbImage->m_matFocusGrayImage;
|
||||
}
|
||||
|
||||
QImage ImagerOperationBase::getQImageFocusGrayImage() const
|
||||
{
|
||||
return *m_RgbImage->m_qimageFocusGrayImage;
|
||||
}
|
||||
|
||||
bool ImagerOperationBase::getRecordControlState() const
|
||||
{
|
||||
return m_bRecordControlState;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setRecordControlState(bool RecordControlState)
|
||||
{
|
||||
m_bRecordControlState = RecordControlState;
|
||||
}
|
||||
|
||||
int ImagerOperationBase::getFrameCounter() const
|
||||
{
|
||||
return m_iFrameCounter;
|
||||
}
|
||||
|
||||
int ImagerOperationBase::getFocusFrameCounter() const
|
||||
{
|
||||
return m_iFocusFrameCounter;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::set_buffer()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
m_FrameSize = getBandCount() * getSampleCount();
|
||||
//std::cout << "m_FrameSize<7A><65>СΪ" << m_FrameSize << std::endl;
|
||||
|
||||
buffer = new unsigned short[m_FrameSize];
|
||||
dark = new unsigned short[m_FrameSize];
|
||||
white = new unsigned short[m_FrameSize];
|
||||
|
||||
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
|
||||
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
|
||||
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::WriteHdr()
|
||||
{
|
||||
//write an ENVI compatible header file
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
|
||||
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
|
||||
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
outfile << "ENVI\n";
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
outfile << "framerate = " << getFramerate() << "\n";
|
||||
outfile << "shutter = " << getIntegrationTime() << "\n";
|
||||
outfile << "gain = " << getGain() << "\n";
|
||||
outfile << "wavelength = {";
|
||||
outfile << std::setprecision(5);
|
||||
|
||||
int start = getStartBand();
|
||||
int end = getEndBand();
|
||||
for (int i = start; i < end - 1; i++)
|
||||
{
|
||||
outfile << getWavelengthAtBand(i) << ", ";
|
||||
}
|
||||
outfile << getWavelengthAtBand(end - 1) << "}\n";
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
unsigned short ImagerOperationBase::GetMaxValue(unsigned short* dark, int number)
|
||||
{
|
||||
unsigned short max = 0;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
if (dark[i] > max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
||||
return max;
|
||||
}
|
102
HPPA/ImagerOperationBase.h
Normal file
102
HPPA/ImagerOperationBase.h
Normal file
@ -0,0 +1,102 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "image2display.h"
|
||||
#include "fileOperation.h"
|
||||
#include <string>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include "ImagerOperationBase.h"
|
||||
|
||||
class ImagerOperationBase :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImagerOperationBase();
|
||||
~ImagerOperationBase();
|
||||
|
||||
virtual double getWavelengthAtBand(int band) = 0;
|
||||
virtual int getBandCount() = 0;
|
||||
virtual int getSampleCount() = 0;
|
||||
virtual double getFramerate() = 0;
|
||||
virtual double getIntegrationTime() = 0;
|
||||
virtual double getGain() = 0;
|
||||
virtual void setFramerate(const double frames_per_second) = 0;
|
||||
virtual void setIntegrationTime(const double milliseconds) = 0;
|
||||
virtual void setGain(const double gain) = 0;
|
||||
virtual int getStartBand() = 0;
|
||||
virtual int getEndBand() = 0;
|
||||
virtual void connectImager(const char* camera_sn = NULL) = 0;
|
||||
virtual void disconnectImager() = 0;
|
||||
virtual void imagerStartCollect() = 0;
|
||||
virtual void imagerStopCollect() = 0;
|
||||
virtual unsigned short* getFrame(unsigned short* buffer) = 0;
|
||||
virtual void setSpectraBin(int new_spectral_bin) = 0;
|
||||
|
||||
|
||||
CImage* getRgbImage() const;
|
||||
cv::Mat* getMatRgbImage() const;
|
||||
cv::Mat* getMatFocusGrayImage() const;
|
||||
QImage getQImageFocusGrayImage() const;
|
||||
|
||||
bool getRecordControlState() const;
|
||||
void setRecordControlState(bool RecordControlState);
|
||||
|
||||
int getFrameCounter() const;
|
||||
int getFocusFrameCounter() const;
|
||||
|
||||
unsigned short* buffer;//<2F>洢<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>д<EFBFBD>뵽Ӳ<EBB5BD><D3B2><EFBFBD><EFBFBD>
|
||||
void set_buffer();
|
||||
void setFileName2Save(string FileName);
|
||||
|
||||
void setFrameNumber(int FrameNumber);
|
||||
void setFocusControlState(bool FocusControlState);
|
||||
int GetFrameSize(int& iWidth, int& iHeight);
|
||||
|
||||
|
||||
protected:
|
||||
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
|
||||
bool m_bRecordControlState;//<2F>ɼ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
int m_iFrameCounter;//<2F><>¼<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
|
||||
int m_iFocusFrameCounter;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
|
||||
int m_FrameSize;//<2F><>ʾһ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>ֵ<EFBFBD><D6B5>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
|
||||
int m_iFrameNumber;//<2F><>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
string m_FileName2Save;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
int m_FileSavedCounter;//<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
bool m_HasDark;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
||||
bool m_HasWhite;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰װ<CBB0>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
||||
|
||||
unsigned short* dark;//<2F>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned short* white;//<2F>洢<EFBFBD>װ<EFBFBD>
|
||||
|
||||
bool m_bFocusControlState;//<2F><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
|
||||
virtual void WriteHdr();
|
||||
unsigned short GetMaxValue(unsigned short* dark, int number);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
public slots:
|
||||
virtual void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
||||
virtual double auto_exposure();
|
||||
virtual void focus();
|
||||
virtual void start_record();
|
||||
virtual void record_dark();
|
||||
virtual void record_white();
|
||||
signals:
|
||||
void PlotSignal();//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ź<EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
|
||||
|
||||
|
||||
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
@ -9,24 +9,15 @@ QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pPa
|
||||
setOrientation(Qt::Horizontal);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
if (!configfile.isConfigfileExist())
|
||||
configfile.createConfigFile();
|
||||
configfile.parseConfigfile();
|
||||
|
||||
float Lead_x;//<2F><><EFBFBD><EFBFBD>
|
||||
float StepAnglemar_x;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float ScaleFactor_x;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SubdivisionMultiples_x;//ϸ<><CFB8><EFBFBD><EFBFBD>
|
||||
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
|
||||
m_Multiplier = 0;
|
||||
}
|
||||
|
||||
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionMultiples)
|
||||
{
|
||||
//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>廻<EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
||||
//m_Multiplier(0.00054496986),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
|
||||
//m_Multiplier(0.00054496986)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
|
||||
m_Multiplier = Lead_x / (360 / StepAnglemar_x * SubdivisionMultiples_x) * ScaleFactor_x;
|
||||
m_Multiplier = lead / (360 / stepAnglemar * subdivisionMultiples) * scaleFactor;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ⷢ<EFBFBD><E2B7A2>
|
||||
|
@ -12,8 +12,9 @@ class QMotorDoubleSlider : public QSlider
|
||||
|
||||
public:
|
||||
QMotorDoubleSlider(QWidget* pParent = NULL);
|
||||
void setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionMultiples);
|
||||
|
||||
double m_Multiplier;
|
||||
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>廻<EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
||||
|
||||
void setRange(double Min, double Max);
|
||||
void setMinimum(double Min);
|
||||
@ -25,17 +26,15 @@ public:
|
||||
long getPositionPulse(double position);//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
double getDistanceFromPulse(int pulse);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void notifyValueChanged(int value);//<2F>ź<EFBFBD>valueChanged(int)<29><>wrap
|
||||
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
|
||||
|
||||
private slots:
|
||||
|
||||
signals :
|
||||
signals:
|
||||
void valueChanged(double Value);
|
||||
void rangeChanged(double Min, double Max);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,101 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "QYMotorDoubleSlider.h"
|
||||
QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
|
||||
{
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
|
||||
|
||||
setSingleStep(1);
|
||||
|
||||
setOrientation(Qt::Horizontal);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
if (!configfile.isConfigfileExist())
|
||||
configfile.createConfigFile();
|
||||
configfile.parseConfigfile();
|
||||
|
||||
float StepAnglemar_y;
|
||||
float Lead_y;
|
||||
float ScaleFactor_y;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SubdivisionMultiples_y;
|
||||
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);
|
||||
|
||||
//m_Multiplier(0.000108993972),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
|
||||
//m_Multiplier(0.000108993972)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
|
||||
m_Multiplier = Lead_y / (360 / StepAnglemar_y * SubdivisionMultiples_y) * ScaleFactor_y;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ⷢ<EFBFBD><E2B7A2>
|
||||
void QYMotorDoubleSlider::notifyValueChanged(int Value)
|
||||
{
|
||||
emit valueChanged((double)Value * m_Multiplier);//////////
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void QYMotorDoubleSlider::setValue(double Value, bool BlockSignals)
|
||||
{
|
||||
QSlider::blockSignals(BlockSignals);
|
||||
|
||||
QSlider::setValue(Value / m_Multiplier);////////////
|
||||
|
||||
if (!BlockSignals)
|
||||
emit valueChanged(Value);
|
||||
|
||||
QSlider::blockSignals(false);
|
||||
}
|
||||
|
||||
void QYMotorDoubleSlider::setRange(double Min, double Max)
|
||||
{
|
||||
QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
|
||||
|
||||
emit rangeChanged(Min, Max);
|
||||
}
|
||||
|
||||
void QYMotorDoubleSlider::setMinimum(double Min)
|
||||
{
|
||||
QSlider::setMinimum(Min / m_Multiplier);//////
|
||||
|
||||
emit rangeChanged(minimum(), maximum());
|
||||
}
|
||||
|
||||
double QYMotorDoubleSlider::minimum() const
|
||||
{
|
||||
return QSlider::minimum() * m_Multiplier;/////
|
||||
}
|
||||
|
||||
void QYMotorDoubleSlider::setMaximum(double Max)
|
||||
{
|
||||
QSlider::setMaximum(Max / m_Multiplier);//////
|
||||
|
||||
emit rangeChanged(minimum(), maximum());
|
||||
}
|
||||
|
||||
double QYMotorDoubleSlider::maximum() const
|
||||
{
|
||||
return QSlider::maximum() * m_Multiplier;///////
|
||||
}
|
||||
|
||||
double QYMotorDoubleSlider::value() const
|
||||
{
|
||||
int Value = QSlider::value();
|
||||
return (double)Value * m_Multiplier;//////
|
||||
}
|
||||
|
||||
double QYMotorDoubleSlider::OriginalValue() const
|
||||
{
|
||||
int Value = QSlider::value();
|
||||
return (double)Value;
|
||||
}
|
||||
|
||||
long QYMotorDoubleSlider::getPositionPulse(double position)
|
||||
{
|
||||
return position / m_Multiplier;
|
||||
}
|
||||
|
||||
double QYMotorDoubleSlider::getDistanceFromPulse(int pulse)
|
||||
{
|
||||
return pulse * m_Multiplier;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef Q_YMOTOR_DOUBLE_SLIDER_H
|
||||
#define Q_YMOTOR_DOUBLE_SLIDER_H
|
||||
#include <QtGui/QtGui>
|
||||
#include <QSlider>
|
||||
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
|
||||
class QYMotorDoubleSlider : public QSlider//QYMotorDoubleSlider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QYMotorDoubleSlider(QWidget* pParent = NULL);
|
||||
|
||||
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>廻<EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
|
||||
|
||||
void setRange(double Min, double Max);
|
||||
void setMinimum(double Min);
|
||||
double minimum() const;
|
||||
void setMaximum(double Max);
|
||||
double maximum() const;
|
||||
double value() const;
|
||||
double OriginalValue() const;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʵ<D2AA>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>
|
||||
long getPositionPulse(double position);//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE>뷵<EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
double getDistanceFromPulse(int pulse);
|
||||
|
||||
public slots:
|
||||
void notifyValueChanged(int value);//<2F>ź<EFBFBD>valueChanged(int)<29><>wrap
|
||||
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
|
||||
|
||||
private slots:
|
||||
|
||||
signals :
|
||||
void valueChanged(double Value);
|
||||
void rangeChanged(double Min, double Max);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif
|
338
HPPA/ResononNirImager.cpp
Normal file
338
HPPA/ResononNirImager.cpp
Normal file
@ -0,0 +1,338 @@
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <exception>
|
||||
#include "ResononNirImager.h"
|
||||
|
||||
ResononNirImager::ResononNirImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ResononNirImager::~ResononNirImager()
|
||||
{
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
||||
free(buffer);
|
||||
free(dark);
|
||||
free(white);
|
||||
}
|
||||
}
|
||||
|
||||
void ResononNirImager::reConnectImage()
|
||||
{
|
||||
disconnectImager();
|
||||
connectImager();
|
||||
}
|
||||
|
||||
double ResononNirImager::getFramerate()
|
||||
{
|
||||
return m_ResononNirImager.get_framerate();
|
||||
}
|
||||
|
||||
double ResononNirImager::getIntegrationTime()
|
||||
{
|
||||
return m_ResononNirImager.get_integration_time();
|
||||
}
|
||||
|
||||
double ResononNirImager::getGain()
|
||||
{
|
||||
//return m_ResononNirImager.get_gain();
|
||||
return 0.0;//nir<69><72>֧<EFBFBD><D6A7>gian
|
||||
}
|
||||
|
||||
void ResononNirImager::setGain(const double gain)
|
||||
{
|
||||
//m_ResononNirImager.set_gain(gain);//nir<69><72>֧<EFBFBD><D6A7>gian
|
||||
}
|
||||
|
||||
void ResononNirImager::setFramerate(const double frames_per_second)
|
||||
{
|
||||
m_ResononNirImager.set_framerate(frames_per_second);
|
||||
m_RgbImage->m_iFramerate = frames_per_second;
|
||||
}
|
||||
|
||||
void ResononNirImager::setIntegrationTime(const double milliseconds)
|
||||
{
|
||||
m_ResononNirImager.set_integration_time(milliseconds);
|
||||
}
|
||||
|
||||
int ResononNirImager::getStartBand()
|
||||
{
|
||||
return m_ResononNirImager.get_start_band();
|
||||
}
|
||||
|
||||
int ResononNirImager::getEndBand()
|
||||
{
|
||||
return m_ResononNirImager.get_end_band();
|
||||
}
|
||||
|
||||
void ResononNirImager::connectImager(const char* camera_sn)
|
||||
{
|
||||
m_ResononNirImager.connect();
|
||||
}
|
||||
|
||||
void ResononNirImager::disconnectImager()
|
||||
{
|
||||
m_ResononNirImager.disconnect();
|
||||
}
|
||||
|
||||
void ResononNirImager::imagerStartCollect()
|
||||
{
|
||||
m_ResononNirImager.start();
|
||||
}
|
||||
|
||||
void ResononNirImager::imagerStopCollect()
|
||||
{
|
||||
m_ResononNirImager.stop();
|
||||
}
|
||||
|
||||
unsigned short* ResononNirImager::getFrame(unsigned short* buffer)
|
||||
{
|
||||
m_ResononNirImager.get_frame(buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void ResononNirImager::setSpectraBin(int new_spectral_bin)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double ResononNirImager::auto_exposure()
|
||||
{
|
||||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double x = 1 / getFramerate() * 1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
reConnectImage();
|
||||
setIntegrationTime(x);
|
||||
|
||||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
imagerStartCollect();
|
||||
|
||||
while (true)
|
||||
{
|
||||
getFrame(buffer);
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||
{
|
||||
setIntegrationTime(getIntegrationTime() * 0.8);
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reConnectImage();
|
||||
//imagerStopCollect();
|
||||
|
||||
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
|
||||
|
||||
return getIntegrationTime();
|
||||
}
|
||||
|
||||
double ResononNirImager::getWavelengthAtBand(int band)
|
||||
{
|
||||
return m_ResononNirImager.get_wavelength_at_band(band);
|
||||
}
|
||||
|
||||
int ResononNirImager::getBandCount()
|
||||
{
|
||||
return m_ResononNirImager.get_band_count();
|
||||
}
|
||||
|
||||
int ResononNirImager::getSampleCount()
|
||||
{
|
||||
return m_ResononNirImager.get_sample_count();
|
||||
}
|
||||
|
||||
void ResononNirImager::focus()
|
||||
{
|
||||
m_iFocusFrameCounter = 1;
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
|
||||
|
||||
double tmpFrmerate = getFramerate();
|
||||
double tmpIntegrationTime = getIntegrationTime();
|
||||
|
||||
|
||||
setFramerate(5);
|
||||
auto_exposure();
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
||||
|
||||
reConnectImage();
|
||||
imagerStartCollect();
|
||||
|
||||
//emit SpectralSignal(1);
|
||||
m_bFocusControlState = true;
|
||||
while (m_bFocusControlState)
|
||||
{
|
||||
getFrame(buffer);
|
||||
//m_RgbImage->FillFocusGrayImage(buffer);
|
||||
m_RgbImage->FillFocusGrayQImage(buffer);
|
||||
|
||||
emit SpectralSignal(1);
|
||||
|
||||
++m_iFocusFrameCounter;
|
||||
}
|
||||
emit SpectralSignal(0);
|
||||
|
||||
imagerStopCollect();
|
||||
|
||||
//reConnectImage();
|
||||
Sleep(20);
|
||||
setFramerate(tmpFrmerate);//Ϊɶ<CEAA><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʾͲ<CABE><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
reConnectImage();
|
||||
setIntegrationTime(tmpIntegrationTime);
|
||||
}
|
||||
|
||||
void ResononNirImager::start_record()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
|
||||
m_iFrameCounter = 0;
|
||||
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
|
||||
m_bRecordControlState = true;
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (buffer == 0)
|
||||
{
|
||||
std::cerr << "Error: memory could not be allocated for datacube";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
|
||||
|
||||
FILE* m_fImage = fopen(imgPath.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
double pixelValueTmp;
|
||||
|
||||
reConnectImage();//nir<69>ڶ<EFBFBD><DAB6>βɼ<CEB2>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>imagerStartCollect()<29>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
imagerStartCollect();
|
||||
while (m_bRecordControlState)
|
||||
{
|
||||
m_iFrameCounter++;
|
||||
|
||||
getFrame(buffer);
|
||||
|
||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
||||
if (m_HasDark)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
if (buffer[i] < dark[i])
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = buffer[i] - dark[i];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_HasWhite)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (white[i] != 0)
|
||||
{
|
||||
pixelValueTmp = buffer[i];
|
||||
buffer[i] = (pixelValueTmp / white[i]) * 10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||
|
||||
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
||||
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
|
||||
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal();
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||
}
|
||||
|
||||
//QThread::msleep(1001);
|
||||
fclose(m_fImage);
|
||||
}
|
||||
|
||||
void ResononNirImager::WriteHdr()
|
||||
{
|
||||
//write an ENVI compatible header file
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
|
||||
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
|
||||
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
outfile << "ENVI\n";
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
outfile << "framerate = " << getFramerate() << "\n";
|
||||
outfile << "shutter = " << getIntegrationTime() << "\n";
|
||||
outfile << "gain = " << getGain() << "\n";
|
||||
outfile << "wavelength = {";
|
||||
outfile << std::setprecision(5);
|
||||
|
||||
int num_bands = getBandCount();
|
||||
for (int i = 0; i < num_bands - 1; i++)
|
||||
{
|
||||
outfile << getWavelengthAtBand(i) << ", ";
|
||||
}
|
||||
outfile << getWavelengthAtBand(num_bands - 1) << "}\n";
|
||||
outfile.close();
|
||||
}
|
50
HPPA/ResononNirImager.h
Normal file
50
HPPA/ResononNirImager.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "resonon_imager_allied.h"
|
||||
#include "image2display.h"
|
||||
#include "fileOperation.h"
|
||||
|
||||
class ResononNirImager :public ImagerOperationBase
|
||||
{
|
||||
public:
|
||||
ResononNirImager();
|
||||
~ResononNirImager();
|
||||
|
||||
Resonon::PikaAllied m_ResononNirImager;//
|
||||
|
||||
double getWavelengthAtBand(int band);
|
||||
int getBandCount();
|
||||
int getSampleCount();
|
||||
double getFramerate();
|
||||
double getIntegrationTime();
|
||||
double getGain();
|
||||
void setFramerate(const double frames_per_second);
|
||||
void setIntegrationTime(const double milliseconds);
|
||||
void setGain(const double gain);
|
||||
int getStartBand();
|
||||
int getEndBand();
|
||||
void connectImager(const char* camera_sn = NULL);
|
||||
void disconnectImager();
|
||||
void imagerStartCollect();
|
||||
void imagerStopCollect();
|
||||
unsigned short* getFrame(unsigned short* buffer);
|
||||
void setSpectraBin(int new_spectral_bin);
|
||||
|
||||
void WriteHdr();
|
||||
|
||||
protected:
|
||||
private:
|
||||
void reConnectImage();
|
||||
|
||||
public slots:
|
||||
double auto_exposure();
|
||||
void focus();
|
||||
void start_record();
|
||||
|
||||
signals:
|
||||
|
||||
};
|
@ -70,7 +70,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:1.7</string>
|
||||
<string>版本:1.8</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "focusWindow.h"
|
||||
|
||||
focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
|
||||
focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
@ -77,12 +77,12 @@ bool test(void *pCaller, int *x, int *y, void **pvdata)
|
||||
{
|
||||
focusWindow *p = (focusWindow *)pCaller;
|
||||
|
||||
p->m_Imager->GetImageSize(*x, *y);
|
||||
p->m_Imager->GetFrameSize(*x, *y);
|
||||
USHORT *pusData = new USHORT[(*x)*(*y)];
|
||||
|
||||
p->m_Imager->m_ResononImager.start();
|
||||
p->m_Imager->m_ResononImager.get_frame(pusData);
|
||||
p->m_Imager->m_ResononImager.stop();
|
||||
p->m_Imager->imagerStartCollect();
|
||||
p->m_Imager->getFrame(pusData);
|
||||
p->m_Imager->imagerStopCollect();
|
||||
|
||||
|
||||
BYTE *pbData = (BYTE*)pusData;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
#include "ImagerOperationBase.h"
|
||||
|
||||
class focusWindow:public QDialog
|
||||
{
|
||||
@ -32,10 +33,10 @@ class focusWindow:public QDialog
|
||||
|
||||
public:
|
||||
focusWindow(QWidget *parent = Q_NULLPTR);
|
||||
focusWindow(QWidget *parent, ResononImager * imager);
|
||||
focusWindow(QWidget *parent, ImagerOperationBase* imager);
|
||||
~focusWindow();
|
||||
|
||||
ResononImager * m_Imager;
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
|
||||
private:
|
||||
|
@ -155,7 +155,7 @@ bool Configfile::getAutoFocusRange(int& max, int& min)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
|
||||
bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
@ -170,6 +170,7 @@ bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
|
||||
if (!(x.lookupValue("StepAnglemar", StepAnglemar)
|
||||
&& x.lookupValue("Lead", Lead) && x.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
|
||||
&& x.lookupValue("ScaleFactor", ScaleFactor)
|
||||
&& x.lookupValue("MaxRange", MaxRange)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
@ -184,7 +185,7 @@ bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
|
||||
bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
@ -199,6 +200,7 @@ bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
|
||||
if (!(y.lookupValue("StepAnglemar", StepAnglemar)
|
||||
&& y.lookupValue("Lead", Lead) && y.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
|
||||
&& y.lookupValue("ScaleFactor", ScaleFactor)
|
||||
&& y.lookupValue("MaxRange", MaxRange)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
@ -213,6 +215,43 @@ bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::setMaxRange(float maxRange, QString x_y)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
Setting& _maxRange = root["motionPlatform"][x_y.toStdString()]["MaxRange"];
|
||||
_maxRange = maxRange;
|
||||
|
||||
writeConfig2File();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'MaxRange' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Configfile::writeConfig2File()
|
||||
{
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
// cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
}
|
||||
catch (const FileIOException& fioex)
|
||||
{
|
||||
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getSN(string &SN)
|
||||
{
|
||||
try
|
||||
@ -266,10 +305,12 @@ bool Configfile::createConfigFile()
|
||||
Setting& x_Lead = x.add("Lead", Setting::TypeFloat) = 13.5;//<2F><><EFBFBD>̣<EFBFBD><CCA3><EFBFBD>λ<EFBFBD><CEBB>cm
|
||||
Setting& x_SubdivisionMultiples = x.add("SubdivisionMultiples", Setting::TypeInt) = 128;//ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
Setting& x_ScaleFactor = x.add("ScaleFactor", Setting::TypeFloat) = 1.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Setting& x_MaxRange = x.add("MaxRange", Setting::TypeFloat) = 120.0;
|
||||
Setting& y_StepAnglemar = y.add("StepAnglemar", Setting::TypeFloat) = 1.8;
|
||||
Setting& y_Lead = y.add("Lead", Setting::TypeFloat) = 13.5;
|
||||
Setting& y_SubdivisionMultiples = y.add("SubdivisionMultiples", Setting::TypeInt) = 128;
|
||||
Setting& y_ScaleFactor = y.add("ScaleFactor", Setting::TypeFloat) = 0.2;
|
||||
Setting& y_MaxRange = y.add("MaxRange", Setting::TypeFloat) = 120.0;
|
||||
|
||||
// Write out the new configuration.
|
||||
try
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "utility_tc.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
@ -35,8 +37,10 @@ public:
|
||||
bool getFitParams(float& fa, float& fb);
|
||||
bool getAutoFocusRange(int& max, int& min);
|
||||
|
||||
bool getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
|
||||
bool getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
|
||||
bool getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange);
|
||||
bool getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange);
|
||||
bool setMaxRange(float maxRange, QString x_y);
|
||||
bool writeConfig2File();
|
||||
|
||||
bool createConfigFile();
|
||||
bool updateConfigFile();
|
||||
|
@ -27,7 +27,7 @@ std::vector<cv::Point2f> ImageProcessor::CHistogram(const cv::Mat img)
|
||||
|
||||
//<2F>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>ڿ۳<DABF><DBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ϊ<EFBFBD><CEAA>ֵ
|
||||
//<2F><><EFBFBD><EFBFBD>mat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16UC3<43><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ϊ65535
|
||||
if (gv > 4096)
|
||||
if (gv >= 4096)
|
||||
{
|
||||
++hisnum[0];
|
||||
}
|
||||
|
@ -1,30 +1,11 @@
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <exception>
|
||||
#include "resononImager.h"
|
||||
|
||||
ResononImager::ResononImager()
|
||||
ResononPicaLImager::ResononPicaLImager()
|
||||
{
|
||||
m_iFrameCounter = 1;
|
||||
m_bRecordControlState = true;
|
||||
|
||||
m_FileName2Save = "tmp_image";
|
||||
m_FileSavedCounter = 1;
|
||||
|
||||
m_RgbImage = new CImage();
|
||||
|
||||
buffer = nullptr;
|
||||
dark = nullptr;
|
||||
white = nullptr;
|
||||
|
||||
m_HasDark = false;
|
||||
m_HasWhite = false;
|
||||
m_bFocusControlState = false;
|
||||
}
|
||||
|
||||
ResononImager::~ResononImager()
|
||||
ResononPicaLImager::~ResononPicaLImager()
|
||||
{
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
@ -35,425 +16,90 @@ ResononImager::~ResononImager()
|
||||
}
|
||||
}
|
||||
|
||||
CImage * ResononImager::getRgbImage() const
|
||||
double ResononPicaLImager::getFramerate()
|
||||
{
|
||||
return m_RgbImage;
|
||||
return m_ResononPicaLImager.get_framerate();
|
||||
}
|
||||
|
||||
cv::Mat * ResononImager::getMatRgbImage() const
|
||||
double ResononPicaLImager::getIntegrationTime()
|
||||
{
|
||||
return m_RgbImage->m_matRgbImage;
|
||||
return m_ResononPicaLImager.get_integration_time();
|
||||
}
|
||||
|
||||
cv::Mat * ResononImager::getMatFocusGrayImage() const
|
||||
double ResononPicaLImager::getGain()
|
||||
{
|
||||
return m_RgbImage->m_matFocusGrayImage;
|
||||
return m_ResononPicaLImager.get_gain();
|
||||
}
|
||||
|
||||
QImage ResononImager::getQImageFocusGrayImage() const
|
||||
void ResononPicaLImager::setGain(const double gain)
|
||||
{
|
||||
return *m_RgbImage->m_qimageFocusGrayImage;
|
||||
m_ResononPicaLImager.set_gain(gain);
|
||||
}
|
||||
|
||||
bool ResononImager::getRecordControlState() const
|
||||
void ResononPicaLImager::setFramerate(const double frames_per_second)
|
||||
{
|
||||
return m_bRecordControlState;
|
||||
}
|
||||
|
||||
void ResononImager::setRecordControlState(bool RecordControlState)
|
||||
{
|
||||
m_bRecordControlState = RecordControlState;
|
||||
}
|
||||
|
||||
int ResononImager::getFrameCounter() const
|
||||
{
|
||||
return m_iFrameCounter;
|
||||
}
|
||||
|
||||
int ResononImager::getFocusFrameCounter() const
|
||||
{
|
||||
return m_iFocusFrameCounter;
|
||||
}
|
||||
|
||||
void ResononImager::WriteHdr()
|
||||
{
|
||||
//write an ENVI compatible header file
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
|
||||
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
|
||||
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
outfile << "ENVI\n";
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "samples = " << m_ResononImager.get_sample_count() << "\n";
|
||||
outfile << "bands = " << m_ResononImager.get_band_count() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
outfile << "framerate = " << m_ResononImager.get_framerate() << "\n";
|
||||
outfile << "shutter = " << m_ResononImager.get_integration_time() << "\n";
|
||||
outfile << "gain = " << m_ResononImager.get_gain() << "\n";
|
||||
outfile << "wavelength = {";
|
||||
outfile << std::setprecision(5);
|
||||
|
||||
int start = m_ResononImager.get_start_band();
|
||||
int end = m_ResononImager.get_end_band();
|
||||
for (int i = start; i < end - 1; i++)
|
||||
{
|
||||
outfile << m_ResononImager.get_wavelength_at_band(i) << ", ";
|
||||
}
|
||||
outfile << m_ResononImager.get_wavelength_at_band(end - 1) << "}\n";
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
unsigned short ResononImager::GetMaxValue(unsigned short * dark, int number)
|
||||
{
|
||||
unsigned short max = 0;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
if (dark[i]>max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
||||
return max;
|
||||
}
|
||||
|
||||
void ResononImager::connect_imager(int frameNumber)
|
||||
{
|
||||
m_ResononImager.connect();
|
||||
set_framerate(30.0);
|
||||
set_integration_time(1);
|
||||
set_gain(0);
|
||||
|
||||
m_ResononImager.set_spectral_bin(2);
|
||||
//m_ResononImager.set_spatial_bin(2);
|
||||
|
||||
set_buffer();
|
||||
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), frameNumber);
|
||||
m_iFrameNumber = frameNumber;
|
||||
|
||||
emit testImagerStatus();
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
}
|
||||
|
||||
void ResononImager::start_record()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
|
||||
m_iFrameCounter = 0;
|
||||
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
|
||||
m_bRecordControlState = true;
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (buffer == 0)
|
||||
{
|
||||
std::cerr << "Error: memory could not be allocated for datacube";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
|
||||
|
||||
m_fImage = fopen(imgPath.c_str(), "w+b");
|
||||
|
||||
|
||||
size_t x;
|
||||
double pixelValueTmp;
|
||||
|
||||
m_ResononImager.start();
|
||||
while (m_bRecordControlState)
|
||||
{
|
||||
m_iFrameCounter++;
|
||||
|
||||
m_ResononImager.get_frame(buffer);
|
||||
|
||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
||||
if (m_HasDark)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
if (buffer[i] < dark[i])
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = buffer[i] - dark[i];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_HasWhite)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (white[i] != 0)
|
||||
{
|
||||
pixelValueTmp = buffer[i];
|
||||
buffer[i] = (pixelValueTmp / white[i]) * 10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||
|
||||
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
||||
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
|
||||
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)m_ResononImager.get_framerate() == 0)
|
||||
{
|
||||
emit PlotSignal();
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
m_ResononImager.stop();
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||
}
|
||||
|
||||
//QThread::msleep(1001);
|
||||
fclose(m_fImage);
|
||||
}
|
||||
|
||||
void ResononImager::record_dark()
|
||||
{
|
||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
m_ResononImager.start();
|
||||
m_ResononImager.get_frame(dark);
|
||||
m_ResononImager.stop();
|
||||
|
||||
m_HasDark = true;
|
||||
}
|
||||
|
||||
void ResononImager::record_white()
|
||||
{
|
||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
m_ResononImager.start();
|
||||
m_ResononImager.get_frame(white);
|
||||
m_ResononImager.stop();
|
||||
|
||||
//<2F>װ<EFBFBD><D7B0>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_HasDark)
|
||||
{
|
||||
for (size_t i = 0; i < m_FrameSize; i++)
|
||||
{
|
||||
if (white[i] < dark[i])
|
||||
{
|
||||
white[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
white[i] = white[i] - dark[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_HasWhite = true;
|
||||
}
|
||||
|
||||
double ResononImager::get_framerate()
|
||||
{
|
||||
return m_ResononImager.get_framerate();
|
||||
}
|
||||
|
||||
double ResononImager::get_integration_time()
|
||||
{
|
||||
return m_ResononImager.get_integration_time();
|
||||
}
|
||||
|
||||
double ResononImager::get_gain()
|
||||
{
|
||||
return m_ResononImager.get_gain();
|
||||
}
|
||||
|
||||
void ResononImager::set_framerate(const double frames_per_second)
|
||||
{
|
||||
|
||||
m_ResononImager.set_framerate(frames_per_second);
|
||||
m_ResononPicaLImager.set_framerate(frames_per_second);
|
||||
m_RgbImage->m_iFramerate = frames_per_second;
|
||||
}
|
||||
|
||||
void ResononImager::set_integration_time(const double milliseconds)
|
||||
void ResononPicaLImager::setIntegrationTime(const double milliseconds)
|
||||
{
|
||||
m_ResononImager.set_integration_time(milliseconds);
|
||||
m_ResononPicaLImager.set_integration_time(milliseconds);
|
||||
}
|
||||
|
||||
void ResononImager::set_gain(const double gain)
|
||||
int ResononPicaLImager::getStartBand()
|
||||
{
|
||||
m_ResononImager.set_gain(gain);
|
||||
return m_ResononPicaLImager.get_start_band();
|
||||
}
|
||||
|
||||
void ResononImager::set_buffer()
|
||||
int ResononPicaLImager::getEndBand()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
m_FrameSize = m_ResononImager.get_band_count()*m_ResononImager.get_sample_count();
|
||||
//std::cout << "m_FrameSize<7A><65>СΪ" << m_FrameSize << std::endl;
|
||||
|
||||
buffer = new unsigned short[m_FrameSize];
|
||||
dark = new unsigned short[m_FrameSize];
|
||||
white = new unsigned short[m_FrameSize];
|
||||
|
||||
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
|
||||
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
|
||||
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
|
||||
return m_ResononPicaLImager.get_end_band();
|
||||
}
|
||||
|
||||
void ResononImager::setFrameNumber(int FrameNumber)
|
||||
void ResononPicaLImager::connectImager(const char* camera_sn)
|
||||
{
|
||||
m_iFrameNumber = FrameNumber;
|
||||
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
|
||||
m_ResononPicaLImager.connect();
|
||||
}
|
||||
|
||||
double ResononImager::auto_exposure()
|
||||
void ResononPicaLImager::disconnectImager()
|
||||
{
|
||||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double x = 1 / m_ResononImager.get_framerate()*1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
m_ResononImager.set_integration_time(x);
|
||||
|
||||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
m_ResononImager.start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
m_ResononImager.get_frame(buffer);
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||
{
|
||||
set_integration_time(get_integration_time()*0.8);
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ResononImager.stop();
|
||||
|
||||
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << get_integration_time() << std::endl;
|
||||
|
||||
return get_integration_time();
|
||||
m_ResononPicaLImager.disconnect();
|
||||
}
|
||||
|
||||
void ResononImager::setFocusControlState(bool FocusControlState)
|
||||
void ResononPicaLImager::imagerStartCollect()
|
||||
{
|
||||
m_bFocusControlState = FocusControlState;
|
||||
m_ResononPicaLImager.start();
|
||||
}
|
||||
|
||||
void ResononImager::setFileName2Save(string FileName)
|
||||
void ResononPicaLImager::imagerStopCollect()
|
||||
{
|
||||
m_FileName2Save = FileName;
|
||||
m_FileSavedCounter = 1;
|
||||
m_ResononPicaLImager.stop();
|
||||
}
|
||||
|
||||
double ResononImager::getWavelengthAtBand(int band)
|
||||
unsigned short* ResononPicaLImager::getFrame(unsigned short* buffer)
|
||||
{
|
||||
return m_ResononImager.get_wavelength_at_band(band);
|
||||
m_ResononPicaLImager.get_frame(buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int ResononImager::getBandCount()
|
||||
void ResononPicaLImager::setSpectraBin(int new_spectral_bin)
|
||||
{
|
||||
return m_ResononImager.get_band_count();
|
||||
|
||||
}
|
||||
|
||||
int ResononImager::getSampleCount()
|
||||
double ResononPicaLImager::getWavelengthAtBand(int band)
|
||||
{
|
||||
return m_ResononImager.get_sample_count();
|
||||
return m_ResononPicaLImager.get_wavelength_at_band(band);
|
||||
}
|
||||
|
||||
int ResononImager::GetImageSize(int &iWidth, int &iHeight)
|
||||
int ResononPicaLImager::getBandCount()
|
||||
{
|
||||
/*using namespace GENAPI_NAMESPACE;
|
||||
using namespace std;
|
||||
INodeMap& nodemap = m_phCamera->GetNodeMap();
|
||||
|
||||
iWidth = (int)CIntegerPtr(nodemap.GetNode("Width"))->GetValue();
|
||||
iHeight = (int)CIntegerPtr(nodemap.GetNode("Height"))->GetValue();*/
|
||||
|
||||
iWidth = getSampleCount();
|
||||
iHeight = getBandCount();
|
||||
|
||||
return 0;
|
||||
return m_ResononPicaLImager.get_band_count();
|
||||
}
|
||||
|
||||
void ResononImager::focus()
|
||||
int ResononPicaLImager::getSampleCount()
|
||||
{
|
||||
m_iFocusFrameCounter = 1;
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
|
||||
|
||||
double tmpFrmerate = m_ResononImager.get_framerate();
|
||||
double tmpIntegrationTime = m_ResononImager.get_integration_time();
|
||||
|
||||
|
||||
m_ResononImager.set_framerate(5);
|
||||
auto_exposure();
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << m_ResononImager.get_integration_time() << std::endl;
|
||||
|
||||
m_ResononImager.start();
|
||||
|
||||
//emit SpectralSignal(1);
|
||||
m_bFocusControlState = true;
|
||||
while (m_bFocusControlState)
|
||||
{
|
||||
m_ResononImager.get_frame(buffer);
|
||||
//m_RgbImage->FillFocusGrayImage(buffer);
|
||||
m_RgbImage->FillFocusGrayQImage(buffer);
|
||||
|
||||
emit SpectralSignal(1);
|
||||
|
||||
++m_iFocusFrameCounter;
|
||||
}
|
||||
emit SpectralSignal(0);
|
||||
|
||||
m_ResononImager.stop();
|
||||
|
||||
m_ResononImager.set_framerate(tmpFrmerate);
|
||||
m_ResononImager.set_integration_time(tmpIntegrationTime);
|
||||
return m_ResononPicaLImager.get_sample_count();
|
||||
}
|
||||
|
@ -4,94 +4,45 @@
|
||||
#include <string>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "resonon_imager_basler.h"
|
||||
#include "image2display.h"
|
||||
#include "fileOperation.h"
|
||||
|
||||
class ResononImager:public QObject
|
||||
class ResononPicaLImager:public ImagerOperationBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ResononImager();
|
||||
~ResononImager();
|
||||
ResononPicaLImager();
|
||||
~ResononPicaLImager();
|
||||
|
||||
Resonon::PikaBasler m_ResononImager;//
|
||||
|
||||
CImage* getRgbImage() const;
|
||||
cv::Mat * getMatRgbImage() const;
|
||||
cv::Mat * getMatFocusGrayImage() const;
|
||||
QImage getQImageFocusGrayImage() const;
|
||||
|
||||
bool getRecordControlState() const;
|
||||
void setRecordControlState(bool RecordControlState);
|
||||
|
||||
int getFrameCounter() const;
|
||||
int getFocusFrameCounter() const;
|
||||
|
||||
unsigned short * buffer;//<2F>洢<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>д<EFBFBD>뵽Ӳ<EBB5BD><D3B2><EFBFBD><EFBFBD>
|
||||
|
||||
void set_buffer();
|
||||
void setFrameNumber(int FrameNumber);
|
||||
double auto_exposure();
|
||||
|
||||
|
||||
void setFocusControlState(bool FocusControlState);
|
||||
|
||||
void setFileName2Save(string FileName);
|
||||
Resonon::PikaBasler m_ResononPicaLImager;//
|
||||
|
||||
double getWavelengthAtBand(int band);
|
||||
int getBandCount();
|
||||
int getSampleCount();
|
||||
|
||||
int GetImageSize(int &iWidth, int &iHeight);
|
||||
double getFramerate();
|
||||
double getIntegrationTime();
|
||||
double getGain();
|
||||
void setFramerate(const double frames_per_second);
|
||||
void setIntegrationTime(const double milliseconds);
|
||||
void setGain(const double gain);
|
||||
int getStartBand();
|
||||
int getEndBand();
|
||||
void connectImager(const char* camera_sn = NULL);
|
||||
void disconnectImager();
|
||||
void imagerStartCollect();
|
||||
void imagerStopCollect();
|
||||
unsigned short* getFrame(unsigned short* buffer);
|
||||
void setSpectraBin(int new_spectral_bin);
|
||||
|
||||
protected:
|
||||
private:
|
||||
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
|
||||
int m_iFrameNumber;//<2F><>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
|
||||
int m_iFrameCounter;//<2F><>¼<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
|
||||
int m_iFocusFrameCounter;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
|
||||
bool m_bRecordControlState;//<2F>ɼ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool m_bFocusControlState;//<2F><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
string m_FileName2Save;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
int m_FileSavedCounter;//<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
unsigned short * dark;//<2F>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned short * white;//<2F>洢<EFBFBD>װ<EFBFBD>
|
||||
|
||||
FILE *m_fImage;//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ӳ<EFBFBD>̵<EFBFBD><CCB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
int m_FrameSize;//<2F><>ʾһ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>ֵ<EFBFBD><D6B5>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
|
||||
bool m_HasDark;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
||||
bool m_HasWhite;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰װ<CBB0>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
||||
|
||||
void WriteHdr();
|
||||
unsigned short GetMaxValue(unsigned short * dark, int number);
|
||||
|
||||
public slots:
|
||||
void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
||||
void start_record();
|
||||
void record_dark();
|
||||
void record_white();
|
||||
void focus();
|
||||
|
||||
double get_framerate();
|
||||
double get_integration_time();
|
||||
double get_gain();
|
||||
|
||||
void set_framerate(const double frames_per_second);
|
||||
void set_integration_time(const double milliseconds);
|
||||
void set_gain(const double gain);
|
||||
|
||||
signals:
|
||||
void PlotSignal();//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ź<EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
|
||||
|
||||
|
||||
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
#endif
|
123
HPPA/utility_tc.cpp
Normal file
123
HPPA/utility_tc.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
#include "utility_tc.h"
|
||||
#include <QDir>
|
||||
|
||||
QString formatTimeStr(char * format)
|
||||
{
|
||||
//获取系统时间
|
||||
time_t timer;//time_t就是long int 类型
|
||||
struct tm *tblock;
|
||||
timer = time(NULL);//返回秒数(精度为秒),从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
|
||||
tblock = localtime(&timer);
|
||||
//printf("Local time is: %s\n", asctime(tblock));
|
||||
|
||||
//格式化时间为需要的格式
|
||||
char timeStr_tmp[256] = { 0 };
|
||||
strftime(timeStr_tmp, sizeof(timeStr_tmp), format, tblock);//
|
||||
|
||||
QString timeStr2(timeStr_tmp);
|
||||
// qDebug() << "time is:" << timeStr2;
|
||||
|
||||
return timeStr2;
|
||||
}
|
||||
|
||||
QString getFileNameBaseOnTime()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
//获取系统时间
|
||||
time_t timer;//time_t就是long int 类型
|
||||
struct tm *tblock;
|
||||
timer = time(NULL);//返回秒数(精度为秒),从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
|
||||
tblock = localtime(&timer);
|
||||
//printf("Local time is: %s\n", asctime(tblock));
|
||||
|
||||
//格式化时间为需要的格式
|
||||
char fileNameTmp[256] = { 0 };
|
||||
char dirNameTmp[256] = { 0 };
|
||||
strftime(fileNameTmp, sizeof(fileNameTmp), "%Y%m%d_%H%M%S", tblock);
|
||||
strftime(dirNameTmp, sizeof(dirNameTmp), "%Y%m%d", tblock);
|
||||
QString fileName(fileNameTmp);
|
||||
QString dirName(dirNameTmp);
|
||||
|
||||
// QString fileName=QString::number(tblock->tm_year+1900)+QString::number(tblock->tm_mon+1)+QString::number(tblock->tm_mday)+"_"+QString::number(tblock->tm_hour)+QString::number(tblock->tm_min);//
|
||||
|
||||
//设置文件绝对路径
|
||||
QDir path("/media/nvme");
|
||||
if(!path.exists(dirName))
|
||||
{
|
||||
path.mkdir(dirName);
|
||||
}
|
||||
path.cd(dirName);
|
||||
QString absoluteFilePath=path.path()+"/"+fileName;
|
||||
// printf("absoluteFilePath is: %s\n", absoluteFilePath.c_str());
|
||||
// qDebug() << "absoluteFilePath is:" << absoluteFilePath;
|
||||
|
||||
return absoluteFilePath;
|
||||
}
|
||||
|
||||
void bubbleSort(unsigned short * a, int n)
|
||||
{
|
||||
// //排序实现1
|
||||
// for(int i=0;i<numberOfPixel;i++)
|
||||
// for(int j=1;j<numberOfPixel-i;j++)
|
||||
// if(a[j-1]>a[j])
|
||||
// swap(a+j-1,a+j);
|
||||
|
||||
//排序实现2
|
||||
int j,k,flag;
|
||||
|
||||
flag = n;
|
||||
while(flag>0)
|
||||
{
|
||||
k=flag;
|
||||
flag=0;
|
||||
for(j=1;j<k;j++)
|
||||
if(a[j-1]>a[j])
|
||||
{
|
||||
swap(a+j-1,a+j);
|
||||
flag=j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void swap(unsigned short * a, unsigned short * b)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
tmp=*a;
|
||||
*a=*b;
|
||||
*b=tmp;
|
||||
}
|
||||
|
||||
|
||||
bool createDir(QString fullPath)
|
||||
{
|
||||
QDir dir(fullPath);
|
||||
if (dir.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
bool ok = dir.mkpath(fullPath);//创建多级目录
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QString> getFileInfo(QString file)
|
||||
{
|
||||
QFileInfo fileInfo = QFileInfo(file);
|
||||
|
||||
QString fileName, fileSuffix, filePath;
|
||||
filePath = fileInfo.absolutePath();//绝对路径
|
||||
fileName = fileInfo.fileName();//文件名
|
||||
fileSuffix = fileInfo.suffix();//文件后缀
|
||||
|
||||
// qDebug() << fileName <<endl
|
||||
// << fileSuffix<< endl
|
||||
// << filePath<< endl;
|
||||
|
||||
QList<QString> result;
|
||||
result.append(filePath);
|
||||
result.append(fileName);
|
||||
result.append(fileSuffix);
|
||||
|
||||
return result;
|
||||
}
|
23
HPPA/utility_tc.h
Normal file
23
HPPA/utility_tc.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef UTILITY_TC_H
|
||||
#define UTILITY_TC_H
|
||||
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
QString getFileNameBaseOnTime();
|
||||
|
||||
QString formatTimeStr(char * format);
|
||||
|
||||
//https://blog.csdn.net/MoreWindows/article/details/6657829
|
||||
void bubbleSort(unsigned short * a, int n);
|
||||
|
||||
void swap(unsigned short * a, unsigned short * b);
|
||||
|
||||
bool createDir(QString fullPath);
|
||||
|
||||
QList<QString> getFileInfo(QString file);
|
||||
|
||||
#endif // UTILITY_TC_H
|
Reference in New Issue
Block a user