1. 精确裁剪有效窗口:setEffectiveWindow + setEffectiveWindowRoi;
2. 添加一些变量:存储重要信息,用于特定函数的返回; 3. 修改cmakelist:添加系统引用;
This commit is contained in:
@ -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, spectralBin));//***********************************
|
||||
|
||||
m_iSpectralBin = spectralBin;
|
||||
|
||||
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, spatialBin));
|
||||
|
||||
m_iSpatialBin = spatialBin;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -42,31 +46,54 @@ int Iris::IrisXimeaImager::getSpatialBin()
|
||||
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_OFFSET_X, OffsetX));
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
|
||||
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()
|
||||
{
|
||||
if(m_xiH==NULL)
|
||||
return 0;
|
||||
// if(m_xiH==NULL)
|
||||
// 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缓存
|
||||
memset(&m_image, 0, sizeof(m_image));
|
||||
m_image.size = sizeof(XI_IMG);
|
||||
if(m_iSpectralBin == 1)
|
||||
{
|
||||
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()
|
||||
@ -92,6 +119,11 @@ void Iris::IrisXimeaImager::connect(const char *camera_serial_number)
|
||||
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
|
||||
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");
|
||||
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));
|
||||
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
|
||||
|
||||
|
||||
// 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
|
||||
memcpy(buffer,m_image.bp,b3);//*2是因为memcpy拷贝的单位是字节数
|
||||
// memcpy(buffer,m_image.bp,m_image.bp_size);
|
||||
// //方法2:此做法是错误的,虽然是指针,也是传值!
|
||||
// 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 *),会有精度降低的问题???????????????????????????????????????????????????
|
||||
return (unsigned short *)&m_timestampOfCamera;
|
||||
}
|
||||
@ -269,9 +279,7 @@ int Iris::IrisXimeaImager::get_max_spectral_bin()
|
||||
|
||||
int Iris::IrisXimeaImager::get_band_count()
|
||||
{
|
||||
int height;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
|
||||
return height;
|
||||
return m_iEffectiveWindow_height;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_band()
|
||||
@ -331,9 +339,14 @@ int Iris::IrisXimeaImager::get_inc_end_band()
|
||||
|
||||
int Iris::IrisXimeaImager::get_sample_count()
|
||||
{
|
||||
int width;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_WIDTH, &width));
|
||||
return width;
|
||||
if(m_iSpectralBin == 1)
|
||||
{
|
||||
return 1364;
|
||||
}
|
||||
else if (m_iSpectralBin == 2)
|
||||
{
|
||||
return 682;
|
||||
}
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_sample()
|
||||
|
Reference in New Issue
Block a user