1. 精确裁剪有效窗口:setEffectiveWindow + setEffectiveWindowRoi;
2. 添加一些变量:存储重要信息,用于特定函数的返回; 3. 修改cmakelist:添加系统引用;
This commit is contained in:
@ -12,6 +12,7 @@ set(TEMPLATE app)
|
|||||||
set(TARGET irisXimeaImager)
|
set(TARGET irisXimeaImager)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
find_package(Qt5 REQUIRED ${QT})
|
find_package(Qt5 REQUIRED ${QT})
|
||||||
|
include_directories(/usr/include)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
irisXimeaImager SHARED
|
irisXimeaImager SHARED
|
||||||
|
@ -27,13 +27,11 @@ namespace Iris
|
|||||||
bool setSpatialBin(int spatialBin);
|
bool setSpatialBin(int spatialBin);
|
||||||
int getSpectralBin();
|
int getSpectralBin();
|
||||||
int getSpatialBin();
|
int getSpatialBin();
|
||||||
void setRoi(int OffsetX, int width, int OffsetY, int height);
|
void setEffectiveWindow(int OffsetX, int width, int OffsetY, int height);
|
||||||
|
void setEffectiveWindowRoi(int OffsetX, int width);
|
||||||
int getBufferSizeOfOneFrame();
|
int getBufferSizeOfOneFrame();
|
||||||
float getTemperature();
|
float getTemperature();
|
||||||
public:
|
public:
|
||||||
float m_fGain;
|
|
||||||
float m_fOffset;
|
|
||||||
|
|
||||||
//继承基类的
|
//继承基类的
|
||||||
IrisXimeaImager();//11111111111111111111
|
IrisXimeaImager();//11111111111111111111
|
||||||
virtual ~IrisXimeaImager();
|
virtual ~IrisXimeaImager();
|
||||||
@ -99,6 +97,21 @@ namespace Iris
|
|||||||
private:
|
private:
|
||||||
XI_IMG m_image; // image buffer
|
XI_IMG m_image; // image buffer
|
||||||
uint64_t m_timestampOfCamera;
|
uint64_t m_timestampOfCamera;
|
||||||
|
|
||||||
|
int m_iSpectralBin;
|
||||||
|
int m_iSpatialBin;
|
||||||
|
|
||||||
|
int m_iEffectiveWindow_OffsetX;
|
||||||
|
int m_iEffectiveWindow_width;
|
||||||
|
int m_iEffectiveWindow_OffsetY;
|
||||||
|
int m_iEffectiveWindow_height;
|
||||||
|
|
||||||
|
int m_iEffectiveWindowRoi_OffsetX;
|
||||||
|
int m_iEffectiveWindowRoi_width;
|
||||||
|
|
||||||
|
float m_fGain;
|
||||||
|
float m_fOffset;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ bool Iris::IrisXimeaImager::setSpectralBin(int spectralBin)
|
|||||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_SUM));
|
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_SUM));
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, spectralBin));//***********************************
|
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, spectralBin));//***********************************
|
||||||
|
|
||||||
|
m_iSpectralBin = spectralBin;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +25,8 @@ bool Iris::IrisXimeaImager::setSpatialBin(int spatialBin)
|
|||||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_SUM));
|
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_SUM));
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, spatialBin));
|
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, spatialBin));
|
||||||
|
|
||||||
|
m_iSpatialBin = spatialBin;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,31 +46,54 @@ int Iris::IrisXimeaImager::getSpatialBin()
|
|||||||
return spatialBin;
|
return spatialBin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Iris::IrisXimeaImager::setRoi(int OffsetX, int width, int OffsetY, int height)
|
void Iris::IrisXimeaImager::setEffectiveWindow(int OffsetX, int width, int OffsetY, int height)
|
||||||
{
|
{
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_WIDTH, width));
|
CE(xiSetParamInt(m_xiH, XI_PRM_WIDTH, width));
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_X, OffsetX));
|
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_X, OffsetX));
|
||||||
|
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
|
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_Y, OffsetY));
|
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_Y, OffsetY));
|
||||||
|
|
||||||
|
m_iEffectiveWindow_OffsetX = OffsetX;
|
||||||
|
m_iEffectiveWindow_width = width;
|
||||||
|
m_iEffectiveWindow_OffsetY = OffsetY;
|
||||||
|
m_iEffectiveWindow_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Iris::IrisXimeaImager::setEffectiveWindowRoi(int OffsetX, int width)
|
||||||
|
{
|
||||||
|
m_iEffectiveWindowRoi_OffsetX = OffsetX;
|
||||||
|
m_iEffectiveWindowRoi_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Iris::IrisXimeaImager::getBufferSizeOfOneFrame()
|
int Iris::IrisXimeaImager::getBufferSizeOfOneFrame()
|
||||||
{
|
{
|
||||||
if(m_xiH==NULL)
|
// if(m_xiH==NULL)
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
|
// start();
|
||||||
|
//
|
||||||
|
// //清空image缓存
|
||||||
|
// memset(&m_image, 0, sizeof(m_image));
|
||||||
|
// m_image.size = sizeof(XI_IMG);
|
||||||
|
//
|
||||||
|
// CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||||
|
//
|
||||||
|
// stop();
|
||||||
|
//
|
||||||
|
// return static_cast<int>(m_image.bp_size);
|
||||||
|
|
||||||
start();
|
|
||||||
|
|
||||||
//清空image缓存
|
if(m_iSpectralBin == 1)
|
||||||
memset(&m_image, 0, sizeof(m_image));
|
{
|
||||||
m_image.size = sizeof(XI_IMG);
|
return m_iEffectiveWindow_height * 1364 * 2;
|
||||||
|
}
|
||||||
|
else if (m_iSpectralBin == 2)
|
||||||
|
{
|
||||||
|
return m_iEffectiveWindow_height * 682 * 2;
|
||||||
|
}
|
||||||
|
|
||||||
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
|
||||||
|
|
||||||
stop();
|
|
||||||
|
|
||||||
return static_cast<int>(m_image.bp_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Iris::IrisXimeaImager::getTemperature()
|
float Iris::IrisXimeaImager::getTemperature()
|
||||||
@ -92,6 +119,11 @@ void Iris::IrisXimeaImager::connect(const char *camera_serial_number)
|
|||||||
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
|
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
|
||||||
CE(xiOpenDevice(0, &m_xiH));//没有插上ximea相机,这句代码都过不去
|
CE(xiOpenDevice(0, &m_xiH));//没有插上ximea相机,这句代码都过不去
|
||||||
|
|
||||||
|
int NUM_THREADS = 0;
|
||||||
|
xiGetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, &NUM_THREADS);
|
||||||
|
printf("Iris::IrisXimeaImager::connect---- XI_PRM_PROC_NUM_THREADS默认值为%d\n", NUM_THREADS);
|
||||||
|
xiSetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, 8);
|
||||||
|
|
||||||
//设置数据格式
|
//设置数据格式
|
||||||
printf("Iris::IrisXimeaImager::connect----2 设置数据格式(xiSetParamInt)\n");
|
printf("Iris::IrisXimeaImager::connect----2 设置数据格式(xiSetParamInt)\n");
|
||||||
CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW16));//Default value: XI_MONO8
|
CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW16));//Default value: XI_MONO8
|
||||||
@ -193,40 +225,18 @@ unsigned short *Iris::IrisXimeaImager::get_frame(unsigned short *buffer)
|
|||||||
memset(&m_image, 0, sizeof(m_image));
|
memset(&m_image, 0, sizeof(m_image));
|
||||||
m_image.size = sizeof(XI_IMG);
|
m_image.size = sizeof(XI_IMG);
|
||||||
|
|
||||||
// //Reads the current timestamp value from camera in nanoseconds.
|
|
||||||
// m_timestampOfCamera=0;
|
|
||||||
// DWORD size=sizeof(m_timestampOfCamera);
|
|
||||||
// XI_PRM_TYPE type=xiTypeInteger64;
|
|
||||||
// xiGetParam(m_xiH, XI_PRM_TIMESTAMP,&m_timestampOfCamera,&size,&type);
|
|
||||||
|
|
||||||
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||||
|
|
||||||
|
|
||||||
// int buffer_policy=0;//
|
|
||||||
// xiGetParamInt(m_xiH, XI_PRM_BUFFER_POLICY,&buffer_policy);
|
|
||||||
//// XI_BP_UNSAFE =0, // User gets pointer to internally allocated circle buffer and data may be overwritten by device.
|
|
||||||
//// XI_BP_SAFE =1, // Data from device will be copied to user allocated buffer or xiApi allocated memory.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// int b1=m_image.width*m_image.height*2;
|
|
||||||
// int b2=m_image.size;//结构体XI_IMG的大小
|
|
||||||
int b3=m_image.bp_size;//一般b1==b3
|
|
||||||
// int b4=0;
|
|
||||||
// xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE,&b4);
|
|
||||||
|
|
||||||
|
|
||||||
// std::cout<<"b1="<<b1<<std::endl;
|
|
||||||
// std::cout<<"b2="<<b2<<std::endl;
|
|
||||||
// std::cout<<"b3="<<b3<<std::endl;
|
|
||||||
// std::cout<<"b4="<<b4<<std::endl;
|
|
||||||
// std::cout<<"buffer_policy="<<buffer_policy<<std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
//方法1:memcpy
|
//方法1:memcpy
|
||||||
memcpy(buffer,m_image.bp,b3);//*2是因为memcpy拷贝的单位是字节数
|
// memcpy(buffer,m_image.bp,m_image.bp_size);
|
||||||
// //方法2:此做法是错误的,虽然是指针,也是传值!
|
// //方法2:此做法是错误的,虽然是指针,也是传值!
|
||||||
// buffer = (unsigned short *)m_image.bp;
|
// buffer = (unsigned short *)m_image.bp;
|
||||||
|
|
||||||
|
for(int i=0;i<m_iEffectiveWindow_height;i++)
|
||||||
|
{
|
||||||
|
memcpy(buffer+i*m_iEffectiveWindowRoi_width, (unsigned short *)m_image.bp + i*m_iEffectiveWindow_width + m_iEffectiveWindowRoi_OffsetX, m_iEffectiveWindowRoi_width*2);
|
||||||
|
}
|
||||||
|
|
||||||
//强制将指针从高精度(uint64_t*)转换到低精度(unsigned short *),会有精度降低的问题???????????????????????????????????????????????????
|
//强制将指针从高精度(uint64_t*)转换到低精度(unsigned short *),会有精度降低的问题???????????????????????????????????????????????????
|
||||||
return (unsigned short *)&m_timestampOfCamera;
|
return (unsigned short *)&m_timestampOfCamera;
|
||||||
}
|
}
|
||||||
@ -269,9 +279,7 @@ int Iris::IrisXimeaImager::get_max_spectral_bin()
|
|||||||
|
|
||||||
int Iris::IrisXimeaImager::get_band_count()
|
int Iris::IrisXimeaImager::get_band_count()
|
||||||
{
|
{
|
||||||
int height;
|
return m_iEffectiveWindow_height;
|
||||||
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
|
|
||||||
return height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Iris::IrisXimeaImager::get_start_band()
|
int Iris::IrisXimeaImager::get_start_band()
|
||||||
@ -331,9 +339,14 @@ int Iris::IrisXimeaImager::get_inc_end_band()
|
|||||||
|
|
||||||
int Iris::IrisXimeaImager::get_sample_count()
|
int Iris::IrisXimeaImager::get_sample_count()
|
||||||
{
|
{
|
||||||
int width;
|
if(m_iSpectralBin == 1)
|
||||||
CE(xiGetParamInt(m_xiH, XI_PRM_WIDTH, &width));
|
{
|
||||||
return width;
|
return 1364;
|
||||||
|
}
|
||||||
|
else if (m_iSpectralBin == 2)
|
||||||
|
{
|
||||||
|
return 682;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Iris::IrisXimeaImager::get_start_sample()
|
int Iris::IrisXimeaImager::get_start_sample()
|
||||||
|
Reference in New Issue
Block a user