def get_control(frame_transmission_delay = 0, inter_packet_delay = 0, packet_size = 8000,force_video_mode= 'false', **keys) : global _BaslerCam global _BaslerInterface if 'camera_id' in keys: camera_id = keys['camera_id'] elif 'serial_number' in keys: camera_id = 'sn://' + keys['serial_number'] elif 'cam_ip_address' in keys: camera_id = 'ip://' + keys['cam_ip_address'] elif 'user_name' in keys: camera_id = 'uname://' + keys['user_name'] else: # if no property is present it uses the server personal name # as Basler user name to identify the camera util = PyTango.Util.instance() camera_id = 'uname://' + util.get_ds_inst_name() print ("basler camera_id:", camera_id) # all properties are passed as string from LimaCCDs device get_control helper # so need to be converted to correct type if force_video_mode == 'true': force = True else: force = False if _BaslerCam is None: _BaslerCam = BaslerAcq.Camera(camera_id, int(packet_size)) _BaslerCam.setInterPacketDelay(int(inter_packet_delay)) _BaslerCam.setFrameTransmissionDelay(int(frame_transmission_delay)) _BaslerInterface = BaslerAcq.Interface(_BaslerCam, force) return Core.CtControl(_BaslerInterface)
def get_control(frame_transmission_delay=0, inter_packet_delay=0, packet_size=8000, **keys): global _BaslerCam global _BaslerInterface if 'camera_id' in keys: camera_id = keys['camera_id'] elif 'serial_number' in keys: camera_id = 'sn://' + keys['serial_number'] elif 'cam_ip_address' in keys: camera_id = 'ip://' + keys['cam_ip_address'] elif 'user_name' in keys: camera_id = 'uname://' + keys['user_name'] else: # if no property is present it uses the server personal name # as Basler user name to identify the camera util = PyTango.Util.instance() camera_id = 'uname://' + util.get_ds_inst_name() print "basler camera_id:", camera_id if _BaslerCam is None: _BaslerCam = BaslerAcq.Camera(camera_id, int(packet_size)) _BaslerCam.setInterPacketDelay(int(inter_packet_delay)) _BaslerCam.setFrameTransmissionDelay(int(frame_transmission_delay)) _BaslerInterface = BaslerAcq.Interface(_BaslerCam) return Core.CtControl(_BaslerInterface)
def get_control(cam_ip_address = "0", frame_transmission_delay = 0, inter_packet_delay = 0, packet_size = 8000,**keys) : print "cam_ip_address",cam_ip_address global _BaslerCam global _BaslerInterface if _BaslerCam is None: _BaslerCam = BaslerAcq.Camera(cam_ip_address,int(packet_size)) _BaslerCam.setInterPacketDelay(int(inter_packet_delay)) _BaslerCam.setFrameTransmissionDelay(int(frame_transmission_delay)) _BaslerInterface = BaslerAcq.Interface(_BaslerCam) return Core.CtControl(_BaslerInterface)
def init(self): self.cam_address = self.getProperty("address") self.cam_type = self.getProperty("type").lower() if self.cam_type == 'prosilica': self.camera = Prosilica.Camera(self.cam_address) self.interface = Prosilica.Interface(self.camera) elif self.cam_type == 'basler': logging.getLogger("HWR").info("Connecting to camera with address %s" % self.cam_address) self.camera = Basler.Camera(self.cam_address) self.interface = Basler.Interface(self.camera) self.control = Core.CtControl(self.interface) self.video = self.control.video() GenericVideoDevice.init(self)
def init(self): self.cam_address = self.getProperty("address") self.cam_type = self.getProperty("type").lower() if self.cam_type == "prosilica": self.camera = Prosilica.Camera(self.cam_address, self.master_mode, False) self.interface = Prosilica.Interface(self.camera) elif self.cam_type == "basler": logging.getLogger("HWR").info( "Connecting to camera with address %s" % self.cam_address) self.camera = Basler.Camera(self.cam_address) self.interface = Basler.Interface(self.camera) self.control = Core.CtControl(self.interface) self.video = self.control.video() AbstractVideoDevice.init(self)
def test_basler(): """ """ import argparse parser = argparse.ArgumentParser(description="Demo for HDF5 writer plugin", epilog="Author: Jérôme KIEFFER") parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="switch to verbose/debug mode") parser.add_argument("-j", "--json", dest="json", default=None, help="json file containing the setup") parser.add_argument("-f", "--fps", type=float, dest="fps", default="30", help="Number of frames per seconds") parser.add_argument("-i", "--ip", dest="ip", default="192.168.5.19", help="IP address of the Basler camera") parser.add_argument("-n", "--nbframes", type=int, dest="n", default=128, help="number of frames to record") parser.add_argument('fname', nargs='*', help='HDF5 filename ', default=["/tmp/lima_test.h5"]) parser.add_argument("-l", "--lima", dest="lima", default=None, help="Base installation of LImA") options = parser.parse_args() if options.verbose: logger.setLevel(logging.DEBUG) logger.debug("Entering debug mode") if options.lima: sys.path.insert(0, options.lima) #Reload Lima: globals()["Core"] = None for mod in sys.modules.copy(): if mod.startswith("Lima"): print("poping:", mod) sys.modules.pop(mod) from Lima import Core globals()["Core"] = Core from Lima import Basler cam = Basler.Camera(options.ip) iface = Basler.Interface(cam) ctrl = Core.CtControl(iface) extMgr = ctrl.externalOperation() myOp = extMgr.addOp(Core.USER_SINK_TASK, "HDF5writer", 10) writer = HDF5Writer(filename=options.fname[0]) myTask = HDF5Sink(writer) myOp.setSinkTask(myTask) callback = PrepareAcqCallback(ctrl, myTask) myOp.registerCallback(callback) acq = ctrl.acquisition() acq.setAcqNbFrames(options.n) acq.setAcqExpoTime(1. / options.fps) ctrl.prepareAcq() ctrl.startAcq() while ctrl.getStatus().ImageCounters.LastImageReady < 1: time.sleep(0.5) logger.info("First frame arrived") time.sleep(1.0 * options.n / options.fps) logger.info("Waiting for last frame") while ctrl.getStatus().ImageCounters.LastImageReady < options.n - 1: time.sleep(0.5)
data = fabio.open(imagefile).data except Exception as error: data = None logger.warning("setFlatfieldFile: Unable to read file %s: %s" % (imagefile, error)) self.ai.set_flatfield(data) if __name__ == "__main__": ai = pyFAI.AzimuthalIntegrator(dist=1, poni1=0.001875, poni2=0.00225, detector="Basler") cam = Basler.Camera(IP) iface = Basler.Interface(cam) ctrl = Core.CtControl(iface) extMgr = ctrl.externalOperation() myOp = extMgr.addOp(Core.USER_LINK_TASK, "azimGroup", 0) myTask = PyFAILink(ai) myOp.setLinkTask(myTask) acq = ctrl.acquisition() # acq.setAcqNbFrames(10) acq.setAcqNbFrames(0) acq.setAcqExpoTime(EXPO) ctrl.prepareAcq() ctrl.startAcq() print ctrl.getStatus() time.sleep(1) base_img = ctrl.ReadBaseImage()
""" import os import time import sys from Lima import Core from Lima import Basler os.environ['QUB_SUBPATH'] = 'qt4' from bliss.data.routines.pixmaptools import qt4 as pixmaptools from PyQt4 import QtGui, QtCore cam = Basler.Camera('sn://21661817', 8000) # gc750 id13 # cam = Basler.Camera('sn://21790015', 8000) # gc3800 id16 # cam.setInterPacketDelay(100) # units ?? hwint = Basler.Interface(cam) ct = Core.CtControl(hwint) video = ct.video() image = ct.image() display = ct.display() display.setNames('basler', 'basler') display.setActive(True) acq = ct.acquisition() print "mode=", video.getMode()
#!/usr/bin/env python import time import signal import threading import numpy import visvis as vv import pyFAI import pyopencl from Lima import Core, Basler fps = 30 acqt = 1.0 / fps ip = "192.168.5.19" cam = Basler.Camera(ip) iface = Basler.Interface(cam) ctrl = Core.CtControl(iface) class MyLink(Core.Processlib.LinkTask): def __init__(self, dist, outshape=(400, 360)): Core.Processlib.LinkTask.__init__(self) self.__dist = dist self.__ai = None self.__sem = threading.Semaphore() self.outshape = outshape def process(self, data): if self.__ai is None: with self.__sem: if self.__ai is None: