fix
1、默认渲染波段:可见光、近红外,采集中、打开文件;
This commit is contained in:
@ -2595,7 +2595,7 @@ void HPPA::onconnect()
|
|||||||
connect(m_Imager, SIGNAL(RecordDarlFinishSignal()), this, SLOT(recordDarkFinish()));
|
connect(m_Imager, SIGNAL(RecordDarlFinishSignal()), this, SLOT(recordDarkFinish()));
|
||||||
|
|
||||||
// Connect LayerFileCreated from imager to HPPA slot
|
// Connect LayerFileCreated from imager to HPPA slot
|
||||||
connect(m_Imager, SIGNAL(LayerFileCreated(QString,QString,int)), this, SLOT(onLayerCreatedFromFile(QString,QString,int)));
|
connect(m_Imager, SIGNAL(LayerFileCreated(QString,QString,int, QString)), this, SLOT(onLayerCreatedFromFile(QString,QString,int, QString)));
|
||||||
|
|
||||||
connect(this->ui.actionOpenDirectory, SIGNAL(triggered()), this, SLOT(onActionOpenDirectory()));
|
connect(this->ui.actionOpenDirectory, SIGNAL(triggered()), this, SLOT(onActionOpenDirectory()));
|
||||||
|
|
||||||
@ -3107,22 +3107,22 @@ void WorkerThread3::run()
|
|||||||
emit AutoFocusFinishedSignal();
|
emit AutoFocusFinishedSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex)
|
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe)
|
||||||
{
|
{
|
||||||
if (!m_LayerTreeModel || !m_RasterGroup) return;
|
if (!m_LayerTreeModel || !m_RasterGroup) return;
|
||||||
|
|
||||||
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||||
{
|
{
|
||||||
//addLayer(baseName, filePath, false, false);
|
//addLayer(baseName, filePath, false, false);
|
||||||
addLayer(baseName, filePath, false);
|
addLayer(baseName, filePath, false, true, hyperimagerTppe);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addLayer(baseName, filePath, false);
|
addLayer(baseName, filePath, false, true, hyperimagerTppe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh, bool isAddImage)
|
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh, bool isAddImage, const QString& hyperimagerTppe)
|
||||||
{
|
{
|
||||||
// Create MapLayer first and attach it to a LayerTreeLayerNode
|
// Create MapLayer first and attach it to a LayerTreeLayerNode
|
||||||
RasterLayer* ml = new RasterLayer(baseName, filePath);
|
RasterLayer* ml = new RasterLayer(baseName, filePath);
|
||||||
@ -3139,14 +3139,41 @@ void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refres
|
|||||||
|
|
||||||
if (isAddImage)
|
if (isAddImage)
|
||||||
{
|
{
|
||||||
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh);
|
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh, hyperimagerTppe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerTreeNode* parent, bool refresh)
|
void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerTreeNode* parent, bool refresh, const QString& hyperimagerTppe)
|
||||||
{
|
{
|
||||||
QWidget* mapcavasContainer = onCreateTab(ml->name());
|
QWidget* mapcavasContainer = onCreateTab(ml->name());
|
||||||
RasterImageLayer* rasterImageLayer = new RasterImageLayer(ml, type);
|
RasterImageLayer* rasterImageLayer;
|
||||||
|
|
||||||
|
//当边采集边显示时,需要修改rasterImageLayer默认渲染波段
|
||||||
|
if (hyperimagerTppe== "visibleLight")
|
||||||
|
{
|
||||||
|
rasterImageLayer = new RasterImageLayer(ml, type, false);
|
||||||
|
|
||||||
|
auto params = rasterImageLayer->multibandParams();
|
||||||
|
params.rWave = 665;
|
||||||
|
params.gWave = 560;
|
||||||
|
params.bWave = 490;
|
||||||
|
rasterImageLayer->setMultibandParams(params);
|
||||||
|
}
|
||||||
|
else if (hyperimagerTppe == "nearInfrared")
|
||||||
|
{
|
||||||
|
rasterImageLayer = new RasterImageLayer(ml, type, false);
|
||||||
|
|
||||||
|
auto params = rasterImageLayer->multibandParams();
|
||||||
|
params.rWave = 1500;
|
||||||
|
params.gWave = 1300;
|
||||||
|
params.bWave = 1100;
|
||||||
|
rasterImageLayer->setMultibandParams(params);
|
||||||
|
}
|
||||||
|
else//当打开影像文件时,rasterImageLayer默认渲染波段由头文件决定
|
||||||
|
{
|
||||||
|
rasterImageLayer = new RasterImageLayer(ml, type, true);
|
||||||
|
}
|
||||||
|
|
||||||
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
||||||
if (mapcavas.size() == 0)
|
if (mapcavas.size() == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -430,9 +430,9 @@ public Q_SLOTS:
|
|||||||
void createMicroscopicMotionControlScenario();
|
void createMicroscopicMotionControlScenario();
|
||||||
void onCreated3DModelOneMotor();
|
void onCreated3DModelOneMotor();
|
||||||
|
|
||||||
void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true);
|
void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true, const QString& hyperimagerTppe="");
|
||||||
void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true);
|
void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true, const QString& hyperimagerTppe="");
|
||||||
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
|
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe);
|
||||||
void removeLayerByTreeIndex();
|
void removeLayerByTreeIndex();
|
||||||
void removeLayerByNode(LayerTreeNode* node);
|
void removeLayerByNode(LayerTreeNode* node);
|
||||||
void showColorImageByTreeIndex();
|
void showColorImageByTreeIndex();
|
||||||
|
|||||||
@ -252,7 +252,7 @@ void ImagerOperationBase::start_record()
|
|||||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter, "visibleLight");
|
||||||
|
|
||||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ void ImagerOperationBase::start_record()
|
|||||||
fprintf(hTimesFile, "%ll\n", timeOs);
|
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||||
|
|
||||||
//将rgb波段提取出来,以便在界面中显示
|
//将rgb波段提取出来,以便在界面中显示
|
||||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
m_RgbImage->FillRgbImage(buffer, 121, 79, 40);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
|
||||||
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@ -123,5 +123,5 @@ signals:
|
|||||||
void ImageFileSaved(const QString& path, int fileIndex);
|
void ImageFileSaved(const QString& path, int fileIndex);
|
||||||
|
|
||||||
// 修改:不再直接发送 MapLayer*,而是发送文件名与文件路径,UI 层负责创建 MapLayer 对象并管理生命周期
|
// 修改:不再直接发送 MapLayer*,而是发送文件名与文件路径,UI 层负责创建 MapLayer 对象并管理生命周期
|
||||||
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
|
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,11 +5,39 @@
|
|||||||
#include "MultibandRasterRenderer.h"
|
#include "MultibandRasterRenderer.h"
|
||||||
#include "SinglebandRasterRenderer.h"
|
#include "SinglebandRasterRenderer.h"
|
||||||
|
|
||||||
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type)
|
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type, bool initRenderParamsFromFile)
|
||||||
: m_layer(layer)
|
: m_layer(layer)
|
||||||
, m_rendererType(type)
|
, m_rendererType(type)
|
||||||
, m_rendererInitialized(false)
|
, m_rendererInitialized(false)
|
||||||
{
|
{
|
||||||
|
if (initRenderParamsFromFile)
|
||||||
|
{
|
||||||
|
// 此处根据头文件(打开影像文件)修改默认渲染波段,只对打开文件的情况下有效;
|
||||||
|
// 当边采集边显示时(initRenderParamsFromFile设置为false),应该在实例化RasterImageLayer后调用setMultibandParams设置默认渲染波段
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!m_layer) return;
|
||||||
|
|
||||||
|
std::vector<double> wavelengths = m_layer->bandWavelengths();
|
||||||
|
if (wavelengths.empty()) return;
|
||||||
|
|
||||||
|
std::sort(wavelengths.begin(), wavelengths.end());
|
||||||
|
double m_minWave = wavelengths.front();
|
||||||
|
double m_maxWave = wavelengths.back();
|
||||||
|
|
||||||
|
if (m_minWave > 800 && m_maxWave > 1600)
|
||||||
|
{
|
||||||
|
m_multibandParams.rWave = 1500;
|
||||||
|
m_multibandParams.gWave = 1300;
|
||||||
|
m_multibandParams.bWave = 1100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception&)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterImageLayer::ensureRenderer()
|
void RasterImageLayer::ensureRenderer()
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public:
|
|||||||
Singleband
|
Singleband
|
||||||
};
|
};
|
||||||
|
|
||||||
RasterImageLayer(RasterLayer* layer, RendererType type);
|
RasterImageLayer(RasterLayer* layer, RendererType type, bool initRenderParamsFromFile);
|
||||||
~RasterImageLayer();
|
~RasterImageLayer();
|
||||||
|
|
||||||
void ensureRenderer();
|
void ensureRenderer();
|
||||||
|
|||||||
@ -293,7 +293,7 @@ void ResononNirImager::start_record()
|
|||||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter, "nearInfrared");
|
||||||
|
|
||||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||||
|
|
||||||
@ -355,7 +355,8 @@ void ResononNirImager::start_record()
|
|||||||
fprintf(hTimesFile, "%ll\n", timeOs);
|
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||||
|
|
||||||
//将rgb波段提取出来,以便在界面中显示
|
//将rgb波段提取出来,以便在界面中显示
|
||||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
//需要修改函数m_RgbImage->FillRgbImage,接收参数:提取rgb的偏移,参数由相机类型、单帧大小、波长范围等确定
|
||||||
|
m_RgbImage->FillRgbImage(buffer, 172, 112, 52);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
|
||||||
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@ -288,7 +288,7 @@ QPushButton:pressed
|
|||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>版本:3.1.3</string>
|
<string>版本:3.1.4</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -64,7 +64,7 @@ void CImage::SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumbe
|
|||||||
//std::cout << "rgb影像内存地址为:" << m_QRgbImage << std::endl;
|
//std::cout << "rgb影像内存地址为:" << m_QRgbImage << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CImage::FillRgbImage(unsigned short *datacube)
|
void CImage::FillRgbImage(unsigned short *datacube, int rBandNumber, int gBandNumber, int bBandNumber)
|
||||||
{
|
{
|
||||||
//uchar==unsigned char,内存大小:1个字节,范围为0-255
|
//uchar==unsigned char,内存大小:1个字节,范围为0-255
|
||||||
//uchar * imagebits24 = m_QRgbImage->bits();
|
//uchar * imagebits24 = m_QRgbImage->bits();
|
||||||
@ -78,9 +78,9 @@ void CImage::FillRgbImage(unsigned short *datacube)
|
|||||||
//std::cout << "rgb图像写入数据帧数:" << j << std::endl;
|
//std::cout << "rgb图像写入数据帧数:" << j << std::endl;
|
||||||
|
|
||||||
//取值:一帧影像中,从左到右的rgb像元值
|
//取值:一帧影像中,从左到右的rgb像元值
|
||||||
r = *(datacube + 121 * m_iSampleNumber + j);
|
r = *(datacube + rBandNumber * m_iSampleNumber + j);
|
||||||
g = *(datacube + 79 * m_iSampleNumber + j);
|
g = *(datacube + gBandNumber * m_iSampleNumber + j);
|
||||||
b = *(datacube + 40 * m_iSampleNumber + j);
|
b = *(datacube + bBandNumber * m_iSampleNumber + j);
|
||||||
|
|
||||||
//将像元值赋值到cv::Mat中,操作像元值:https://zhuanlan.zhihu.com/p/51842288
|
//将像元值赋值到cv::Mat中,操作像元值:https://zhuanlan.zhihu.com/p/51842288
|
||||||
//int dataType = m_matRgbImage->type();//当数据类型为CV_16UC3时,返回18
|
//int dataType = m_matRgbImage->type();//当数据类型为CV_16UC3时,返回18
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public:
|
|||||||
CImage(QWidget* pParent = NULL);
|
CImage(QWidget* pParent = NULL);
|
||||||
//~CImage();
|
//~CImage();
|
||||||
void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
|
void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
|
||||||
void FillRgbImage(unsigned short *datacube);
|
void FillRgbImage(unsigned short *datacube, int rBandNumber, int gBandNumber, int bBandNumber);
|
||||||
void FillFocusGrayImage(unsigned short *datacube);
|
void FillFocusGrayImage(unsigned short *datacube);
|
||||||
void FillFocusGrayQImage(unsigned short * datacube);
|
void FillFocusGrayQImage(unsigned short * datacube);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user