def __getFrameDim(self, max_dim=False): control = _control_ref() image = control.image() if max_dim: size = image.getMaxImageSize() frame_dim = Core.FrameDim(size, image.getImageType()) else: frame_dim = image.getImageDim() return frame_dim
def getFrameDimFromLongArray(self, dim_arr): width, height, depth = dim_arr if depth == 1: image_type = Core.Bpp8 elif depth == 2: image_type = Core.Bpp16 elif depth == 4: image_type = Core.Bpp32 else: raise ValueError('Unknown pixel depth: %d' % depth) return Core.FrameDim(width, height, image_type)
def test_big_detector_size(): """Change the size of the simulator Make sure the hardware detector size matches the request """ cam = Simulator.Camera() hw = Simulator.Interface(cam) ct = Core.CtControl(hw) cam.setFrameDim(Core.FrameDim(2048, 2000, Core.Bpp32)) dim = ct.image().getImageDim() assert dim.getSize() == Core.Size(2048, 2000) detinfo = hw.getHwCtrlObj(Core.HwCap.DetInfo) assert detinfo.getMaxImageSize() == Core.Size(2048, 2000)
def test_update_mode(): """Change the simulator mode of the detector Check that the size have not changed """ cam = Simulator.Camera() hw = Simulator.Interface(cam) ct = Core.CtControl(hw) cam.setFrameDim(Core.FrameDim(100, 100, Core.Bpp32)) dim = ct.image().getImageDim() assert dim.getSize() == Core.Size(100, 100) new_mode = Simulator.Camera.MODE_GENERATOR_PREFETCH cam.setMode(new_mode) dim = ct.image().getImageDim() assert dim.getSize() == Core.Size(100, 100)
def data2FrameInfo(self, data): arr = data.buffer arr_type = arr.dtype.type arr_height, arr_width = arr.shape image_type = self.DataType2ImageType[arr_type] buffer_ctrl = self.m_hw_inter.getHwCtrlObj(Core.HwCap.Buffer) start_ts = buffer_ctrl.getStartTimestamp() fdim = Core.FrameDim(arr_width, arr_height, image_type) timestamp = Core.Timestamp(data.timestamp) valid_pixels = Core.Point(fdim.getSize()).getArea() ownership = Core.HwFrameInfoType.Managed finfo = Core.HwFrameInfoType(data.frameNumber, arr, timestamp, valid_pixels, ownership) return finfo, fdim
def __init__(self, hw_inter, deps, config): self.hw_inter = hw_inter self.deps = deps self.config = config if self.use_control(): self.ct = Core.CtControl(self.hw_inter) self.acq = self.ct.acquisition() self.acq.setLatencyTime(self.config['readout_time']) self.acq.setAcqExpoTime(self.config['exp_time']) image = self.ct.image() self.frame_dim = image.getImageDim() else: det_info = self.hw_inter.getHwCtrlObj(Core.HwCap.DetInfo) self.frame_dim = Core.FrameDim(det_info.getDetectorImageSize(), det_info.getCurrImageType()) self.buffer = self.hw_inter.getHwCtrlObj(Core.HwCap.Buffer) self.buffer.setFrameDim(self.frame_dim) self.sync = self.hw_inter.getHwCtrlObj(Core.HwCap.Sync) self.sync.setLatTime(self.config['readout_time']) self.sync.setExpTime(self.config['exp_time']) self.max_nb_buffers = int(Core.GetDefMaxNbBuffers(self.frame_dim) * 0.7) / 2 self.max_nb_buffers += 1000 - self.max_nb_buffers % 1000 min_nb_buffers = min(6000, self.max_nb_buffers / 2) self.nb_frames_list = range(min_nb_buffers, self.max_nb_buffers + 1, 500) self.end = False self.nb_frames = None self.base_mem = self.memory_usage_gb() self.nb_warnings = 0 mega_bytes = self.frame_dim.getMemSize() / 1024.0**2 print "Frame dim: %s (%s Mbytes)" % (self.frame_dim, mega_bytes)
def main(argv): deb.Always("Creating Espia.Dev") edev = Espia.Dev(0) deb.Always("Creating Espia.Acq") acq = Espia.Acq(edev) acqstat = acq.getStatus() deb.Always("Whether the Acquisition is running : %s" % acqstat.running) deb.Always("Creating Espia.BufferMgr") buffer_cb_mgr = Espia.BufferMgr(acq) deb.Always("Creating BufferCtrlMgr") buffer_mgr = Core.BufferCtrlMgr(buffer_cb_mgr) deb.Always("Creating Espia.SerialLine") eser_line = Espia.SerialLine(edev) deb.Always("Creating Frelon.Camera") cam = Frelon.Camera(eser_line) deb.Always("Creating the Hw Interface ... ") hw_inter = Frelon.Interface(acq, buffer_mgr, cam) deb.Always("Creating HW BufferSave") buffer_save = Core.HwBufferSave(Core.HwBufferSave.EDF, "img", 0, ".edf", True, 1) deb.Always("Getting HW detector info") hw_det_info = hw_inter.getHwCtrlObj(Core.HwCap.DetInfo) deb.Always("Getting HW buffer") hw_buffer = hw_inter.getHwCtrlObj(Core.HwCap.Buffer) deb.Always("Getting HW Sync") hw_sync = hw_inter.getHwCtrlObj(Core.HwCap.Sync) deb.Always("Getting HW Bin") hw_bin = hw_inter.getHwCtrlObj(Core.HwCap.Bin) deb.Always("Getting HW RoI") hw_roi = hw_inter.getHwCtrlObj(Core.HwCap.Roi) mis_cb = MaxImageSizeCallback() hw_det_info.registerMaxImageSizeCallback(mis_cb) deb.Always("Setting FTM") cam.setFrameTransferMode(Frelon.FTM) deb.Always("Setting FFM") cam.setFrameTransferMode(Frelon.FFM) soft_roi = Core.Roi() acq_state = Core.AcqState() deb.Always("Creating a TestFrameCallback") cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_state) do_reset = False if do_reset: deb.Always("Reseting hardware ...") hw_inter.reset(HwInterface.HardReset) deb.Always(" Done!") size = hw_det_info.getMaxImageSize() image_type = hw_det_info.getCurrImageType() frame_dim = Core.FrameDim(size, image_type) bin = Core.Bin(Core.Point(1)) hw_bin.setBin(bin) #Roi set_roi, real_roi; #set_hw_roi(hw_roi, set_roi, real_roi, soft_roi); effect_frame_dim = Core.FrameDim(frame_dim) # was (frame_dim / bin) hw_buffer.setFrameDim(effect_frame_dim) hw_buffer.setNbBuffers(10) hw_buffer.registerFrameCallback(cb) hw_sync.setExpTime(2) hw_sync.setNbFrames(3) deb.Always("Starting Acquisition") acq_state.set(Core.AcqState.Acquiring) hw_inter.startAcq() deb.Always("Waiting acq finished...") acq_state.waitNot(Core.AcqState.Acquiring) deb.Always("Acq finished!!") deb.Always("Stopping Acquisition") hw_inter.stopAcq() deb.Always("This is the End...")
def maxImageSizeChanged(self, size, image_type): fdim = Core.FrameDim(size, image_type) msg = "size=%sx%s, image_type=%s, depth=%d" % \ (size.getWidth(), size.getHeight(), image_type, \ fdim.getDepth()) deb.Always("MaxImageSizeChanged: %s" % msg)
# This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. ############################################################################ from Lima import Core, Simulator Core.DebParams.setTypeFlags(Core.DebParams.AllFlags) cam = Simulator.Camera() frame_dim = Core.FrameDim(Core.Size(800, 600), Core.Bpp32) cam = Simulator.Camera() getter = cam.getFrameGetter() getter.setFrameDim(frame_dim) hwint = Simulator.Interface(cam) control = Core.CtControl(hwint) acq = control.acquisition() acq.setAcqNbFrames(1) img = control.image() roi = Core.Roi(300,50,450,300) img.setRoi(roi) # img.setBin(Core.Bin(2, 2)) img.setRotation(Core.Rotation_90)
import time from Lima import Core, Simulator #Core.DebParams.setTypeFlags(Core.DebParams.AllFlags) cam = Simulator.Camera() frame_dim = Core.FrameDim(Core.Size(600, 300), Core.Bpp32) cam = Simulator.Camera() getter = cam.getFrameGetter() getter.setFrameDim(frame_dim) hwint = Simulator.Interface(cam) control = Core.CtControl(hwint) acq = control.acquisition() acq.setAcqNbFrames(1) acq.setAcqExpoTime(0.001) img = control.image() print("Attach debugger now") input() roi = Core.Roi(1, 1, 598, 298) # Almost full frame #roi = Core.Roi(0, 0, 600, 300) # Full frame img.setRoi(roi) rots = [ Core.Rotation_0, Core.Rotation_90, Core.Rotation_180, Core.Rotation_270 ]
def getFrameDim(self): det_info = self.__det_info() return Core.FrameDim(det_info.getDetectorImageSize(), det_info.getDefImageType())