//----------------------------------------------------- // //----------------------------------------------------- void DetInfoCtrlObj::getMaxImageSize(Size& max_image_size) { DEB_MEMBER_FUNCT(); FrameDim fdim; m_adsc.getFrameDim(fdim); max_image_size = fdim.getSize(); }
//----------------------------------------------------- // //----------------------------------------------------- void DetInfoCtrlObj::getCurrImageType(ImageType& curr_image_type) { DEB_MEMBER_FUNCT(); FrameDim fdim; m_adsc.getFrameDim(fdim); curr_image_type = fdim.getImageType(); }
//----------------------------------------------------- // //----------------------------------------------------- void DetInfoCtrlObj::getDefImageType(ImageType& def_image_type) { DEB_MEMBER_FUNCT(); FrameDim fdim; m_adsc.getFrameDim(fdim); def_image_type = fdim.getImageType(); }
//----------------------------------------------------- // //----------------------------------------------------- void DetInfoCtrlObj::setCurrImageType(ImageType curr_image_type) { DEB_MEMBER_FUNCT(); FrameDim fdim; m_adsc.getFrameDim(fdim); fdim.setImageType(curr_image_type); m_adsc.setFrameDim(fdim); }
void BufferCbMgr::getBufferFrameDim(const FrameDim& single_frame_dim, int nb_concat_frames, FrameDim& buffer_frame_dim) { DEB_MEMBER_FUNCT(); DEB_PARAM() << DEB_VAR2(single_frame_dim, nb_concat_frames); if (nb_concat_frames < 1) THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(nb_concat_frames); buffer_frame_dim = single_frame_dim; Size buffer_size = buffer_frame_dim.getSize(); buffer_size *= Point(1, nb_concat_frames); buffer_frame_dim.setSize(buffer_size); DEB_RETURN() << DEB_VAR1(buffer_frame_dim); }
void SavingCtrlObj::HwSavingStream::writeFrame(HwFrameInfoType& frame_info) { DEB_MEMBER_FUNCT(); try { FrameDim fdim = frame_info.frame_dim; Size size = fdim.getSize(); int width = size.getWidth(); int height = size.getHeight(); int saveOpt; m_cam.getSaveOpt(saveOpt); if (height == 1) { uint64_t* image_data = (uint64_t*) frame_info.frame_ptr; hsize_t slab_dim[2]; slab_dim[1] = width; slab_dim[0] = 1; DataSpace slabspace = DataSpace(RANK_TWO, slab_dim); hsize_t offset[] = { (unsigned) frame_info.acq_frame_nb, 0}; hsize_t count[] = { 1, (unsigned) width}; DEB_TRACE() << DEB_VAR4(m_streamNb, frame_info.acq_frame_nb, offset, count); m_image_dataspace->selectHyperslab(H5S_SELECT_SET, count, offset); m_image_dataset->write(image_data, PredType::NATIVE_UINT64, slabspace, *m_image_dataspace); } else { hsize_t slab_dim[3]; slab_dim[2] = size.getWidth(); slab_dim[1] = size.getHeight(); slab_dim[0] = 1; DataSpace slabspace = DataSpace(RANK_THREE, slab_dim); hsize_t offset[] = { (unsigned) frame_info.acq_frame_nb, 0, 0}; hsize_t count[] = { 1, (unsigned) width, (unsigned) height }; DEB_TRACE() << DEB_VAR4(m_streamNb, frame_info.acq_frame_nb, offset, count); m_image_dataspace->selectHyperslab(H5S_SELECT_SET, count, offset); if (saveOpt & Camera::SaveHistogram && m_streamNb == 2) { m_image_dataset->write((uint32_t*) frame_info.frame_ptr, PredType::NATIVE_UINT32, slabspace, *m_image_dataspace); } else { m_image_dataset->write((uint16_t*) frame_info.frame_ptr, PredType::NATIVE_UINT16, slabspace, *m_image_dataspace); } } } catch (H5::Exception &e) { THROW_CTL_ERROR(Error) << e.getCDetailMsg(); } }
void BufferCtrlObj::prepareAcq() { DEB_MEMBER_FUNCT(); FrameDim dim; getFrameDim(dim); m_frame[0].ImageBufferSize = m_frame[1].ImageBufferSize = dim.getMemSize(); m_acq_frame_nb = -1; int buffer_nb,concat_frame_nb; m_buffer_cb_mgr.acqFrameNb2BufferNb(0,buffer_nb,concat_frame_nb); tPvFrame& frame0 = m_frame[0]; frame0.ImageBuffer = (char*) m_buffer_cb_mgr.getBufferPtr(buffer_nb, concat_frame_nb); m_buffer_cb_mgr.acqFrameNb2BufferNb(1,buffer_nb,concat_frame_nb); tPvFrame& frame1 = m_frame[1]; frame1.ImageBuffer = (char*) m_buffer_cb_mgr.getBufferPtr(buffer_nb, concat_frame_nb); }
int lima::GetDefMaxNbBuffers(const FrameDim& frame_dim) { int frame_size = frame_dim.getMemSize(); if (frame_size <= 0) throw LIMA_HW_EXC(InvalidValue, "Invalid FrameDim"); int tot_buffers; GetSystemMem(frame_size, tot_buffers); return int(tot_buffers); }
/***************************************************************//** * @brief Checks the consistency of FrameDim, Bin and RoI * * First checks if Binning is valid * Then checks if FrameDim is inside of the MaxImageSize * Finally checks if the RoI is consistent with the binned frame dim *******************************************************************/ void FrameBuilder::checkValid( const FrameDim &frame_dim, const Bin &bin, const Roi &roi ) throw(Exception) { Size max_size; getMaxImageSize( max_size ); Bin valid_bin = bin; checkBin(valid_bin); if (valid_bin != bin) throw LIMA_HW_EXC(InvalidValue, "Invalid bin"); if( (frame_dim.getSize().getWidth() > max_size.getWidth()) || (frame_dim.getSize().getHeight() > max_size.getHeight()) ) throw LIMA_HW_EXC(InvalidValue, "Frame size too big"); FrameDim bin_dim = frame_dim / bin; if( roi.getSize() != 0 ) { bin_dim.checkValidRoi(roi); } }
int lima::GetDefMaxNbBuffers(const FrameDim& frame_dim, double sys_mem_factor) { int frame_size = frame_dim.getMemSize(); if (frame_size <= 0) throw LIMA_HW_EXC(InvalidValue, "Invalid FrameDim"); if (sys_mem_factor == 0) sys_mem_factor = 0.8; int tot_buffers; GetSystemMem(frame_size, tot_buffers); return int(tot_buffers * sys_mem_factor); }
/***************************************************************//** * @brief FrameBuilder class initialiser setting member variables * * Before setting we check the values for consistency * * @param[in] frame_dim The frame dimensions * @param[in] roi RoI in BINNED units * @param[in] peaks A vector of GaussPeak structures * @param[in] grow_factor Peaks grow % with each frame *******************************************************************/ void FrameBuilder::init( FrameDim &frame_dim, Bin &bin, Roi &roi, const PeakList &peaks, double grow_factor ) { checkValid(frame_dim, bin, roi); setPeaks(peaks); m_frame_dim = frame_dim; m_bin = bin; m_roi = roi; m_fill_type = Gauss; m_rot_axis = RotationY; m_grow_factor = grow_factor; m_frame_nr = 0; m_rot_angle = 0; m_rot_speed = 0; m_diffract_x = frame_dim.getSize().getWidth() / 2; m_diffract_y = frame_dim.getSize().getHeight() / 2; m_diffract_sx = 0; m_diffract_sy = 0; }
void StdBufferCbMgr::allocBuffers(int nb_buffers, int nb_concat_frames, const FrameDim& frame_dim) { DEB_MEMBER_FUNCT(); DEB_PARAM() << DEB_VAR3(nb_buffers, nb_concat_frames, frame_dim); int frame_size = frame_dim.getMemSize(); if (frame_size <= 0) { THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(frame_dim); } else if (nb_concat_frames < 1) { THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(nb_concat_frames); } int curr_nb_buffers; getNbBuffers(curr_nb_buffers); if ((nb_buffers == curr_nb_buffers) && (frame_dim == m_frame_dim) && (nb_concat_frames == m_nb_concat_frames)) { DEB_TRACE() << "Nothing to do"; return; } releaseBuffers(); try { FrameDim buffer_frame_dim; getBufferFrameDim(frame_dim, nb_concat_frames, buffer_frame_dim); DEB_TRACE() << "Allocating buffers"; m_alloc_mgr->allocBuffers(nb_buffers, buffer_frame_dim); m_frame_dim = frame_dim; m_nb_concat_frames = nb_concat_frames; DEB_TRACE() << "Allocating frame info list"; int nb_frames = nb_buffers * nb_concat_frames; m_info_list.reserve(nb_frames); for (int i = 0; i < nb_frames; ++i) m_info_list.push_back(HwFrameInfoType()); } catch (...) { releaseBuffers(); throw; } }
void SoftBufferAllocMgr::allocBuffers(int nb_buffers, const FrameDim& frame_dim) { DEB_MEMBER_FUNCT(); DEB_PARAM() << DEB_VAR2(nb_buffers, frame_dim); int frame_size = frame_dim.getMemSize(); if (frame_size <= 0) THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(frame_dim); int max_buffers = getMaxNbBuffers(frame_dim); if ((nb_buffers < 1) || (nb_buffers > max_buffers)) THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(nb_buffers); int curr_nb_buffers; getNbBuffers(curr_nb_buffers); if ((frame_dim == m_frame_dim) && (nb_buffers == curr_nb_buffers)) { DEB_TRACE() << "Nothing to do"; return; } releaseBuffers(); try { m_buffer_list.reserve(nb_buffers); for (int i = 0; i < nb_buffers; ++i) { MemBuffer *buffer = new MemBuffer(frame_size); m_buffer_list.push_back(buffer); } } catch (...) { DEB_ERROR() << "Error alloc. buffer #" << m_buffer_list.size(); releaseBuffers(); throw; } m_frame_dim = frame_dim; }
void lima::ClearBuffer(void *ptr, int nb_concat_frames, const FrameDim& frame_dim) { memset(ptr, 0, nb_concat_frames * frame_dim.getMemSize()); }