Esempio n. 1
0
    def test_traversable_tutorial(self):
        # Create a Harvester object:
        self.harvester = Harvester()

        # The following block is just for administrative purpose;
        # you should not include it in your code:
        cti_file_path = get_cti_file_path()
        if 'TLSimu.cti' not in cti_file_path:
            return

        # Add a CTI file path:
        self.harvester.add_cti_file(cti_file_path)
        self.harvester.update_device_info_list()

        # Connect to the first camera in the list:
        self.ia = self.harvester.create_image_acquirer(0)

        #
        num_images_to_acquire = 0

        # Then start image acquisition:
        self.ia.start_image_acquisition()

        while num_images_to_acquire < 100:
            #
            with self.ia.fetch_buffer() as buffer:
                # self.do_something(buffer)
                pass

            num_images_to_acquire += 1

        # We don't need the ImageAcquirer object. Destroy it:
        self.ia.destroy()
Esempio n. 2
0
    def test_traversable_tutorial(self):
        # Create a Harvester object:
        self.harvester = Harvester()
        
        # Add a CTI file path:
        self.harvester.add_cti_file(
            get_cti_file_path()
        )
        self.harvester.update_device_info_list()

        # Connect to the first camera in the list:
        self.ia = self.harvester.create_image_acquirer(0)

        #
        num_images_to_acquire = 0

        # Then start image acquisition:
        self.ia.start_image_acquisition()

        while num_images_to_acquire < 100:
            #
            with self.ia.fetch_buffer() as buffer:
                # self.do_something(buffer)
                pass

            num_images_to_acquire += 1

        # We don't need the ImageAcquirer object. Destroy it:
        self.ia.destroy()
Esempio n. 3
0
    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger)
        self._harvester.add_file(self._cti_file_path)
        self._harvester.update()
Esempio n. 4
0
    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger, do_clean_up=False)
        self._harvester.add_file(self._cti_file_path)
        self._harvester.update()
Esempio n. 5
0
    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger)
        self._harvester.add_cti_file(self._cti_file)
        self._harvester.update_device_info_list()
Esempio n. 6
0
    def setUp(self) -> None:
        # The following block is just for administrative purpose;
        # you should not include it in your code:
        self.cti_file_path = get_cti_file_path()
        if 'TLSimu.cti' not in self.cti_file_path:
            self.skipTest('The target is not TLSimu.')

        # Create a Harvester object:
        self.harvester = Harvester()
    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester()
        self._harvester.add_cti_file(self._path + self._filename)
        self._harvester.update_device_info_list()
        self._iam = None
        self._thread = None
class HarvestersSource(Node, Observable):
    def __init__(self):
        Node.__init__(self, "Harvesters")
        Observable.__init__(self, self._on_subscribe)
        self.cfg = self.config[SECTION]
        self.harvester = Harvester()
        if self.cfg["disableInternalLogger"]:
            self.harvester._logger.setLevel(100)

        self.cti_file = self.cfg["ctiFile"]
        self.harvester.add_file(self.cti_file)
        self.logger.info(f"Loaded harvester cti file {self.cti_file}")
        self.harvester.update()
        self.logger.info(
            f"Found {len(self.harvester.device_info_list)} devices.")

    def _on_subscribe(self, observer: Observer, scheduler=None):
        self.acquirer = self.harvester.create_image_acquirer(list_index=0)
        self.reload_camera_driver()
        self.acquirer.add_callback(
            self.acquirer.Events.NEW_BUFFER_AVAILABLE,
            CallbackOnNewBuffer(self.acquirer, observer))
        self.acquirer.start_image_acquisition(run_in_background=True)
        self.logger.info("Started acquisition in background")

        def dispose():
            def _async_dispose(*args):
                # prevent join in the same thread.
                self.logger.info("Stopping image acquisition")
                self.acquirer.stop_image_acquisition()
                self.acquirer.destroy()
                self.logger.info("Stopped image acquisition")

            (scheduler or NewThreadScheduler()).schedule(_async_dispose)

        return Disposable(dispose)

    def reload_camera_driver(self):
        node = self.acquirer.device.node_map
        node.LineSelector.value = self.cfg["lineSelector"]
        node.LineMode.value = self.cfg["lineMode"]
        node.LineInverter.value = self.cfg["lineInverter"]
        node.LineSource.value = "ExposureActive"
        node.ExposureTime.value = self.cfg["exposureTime"]
        if node.has_node("acquisitionFrameRateMode"):
            # Allied Vision Camera
            node.AcquisitionFrameRateMode.value = "Basic"
        node.AcquisitionFrameRate.value = self.cfg["acquisitionFrameRate"]

        if self.cfg["extraNodes"]:
            extra_nodes: dict = self.cfg["extraNodes"]
            for k, v in extra_nodes.items():
                node.get_node(k).value = v
Esempio n. 9
0
class TestHarvesterNoCleanUp(TestHarvesterBase):
    def __init__(self, *args, **kwargs):
        #
        super().__init__(*args, **kwargs)

    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger, do_clean_up=False)
        self._harvester.add_file(self._cti_file_path)
        self._harvester.update()
Esempio n. 10
0
def main():
    h = Harvester()
    h.add_cti_file('C:/Program Files/JAI/SDK/bin/JaiGevTL.cti')
    # JaiUSB3vTL  JaiGevTL
    print(h.cti_files)
    h.update_device_info_list()
    print("file", h.device_info_list)
    print("dty", list(dict.fromkeys(h.device_info_list)))

    # x = unique(h.device_info_list)
    # print("pp",x)
    print("devices end")
    ia = h.create_image_acquirer(0)
    print("dsssx", ia.device)
    print("infor", ia.device.node_map.device_info)
    # ia.device.node_map.Test
    # ia.device.node_mapdsx key.PixelFormat.value = 'RGB12'
    # ia.device.node_map.RGB12Packed.value = 'RGB12'
    # ia.device.node_map.has_node()
    # ia.device.node_map.TestPattern = 'HorizontalColorBar'
    # ia.acquirer.remote_device.node_map
    print(ia.is_acquiring())

    try:
        print("acqui")
        ia.start_image_acquisition()
        print("acquired", ia.is_acquiring())
        print("acqui 2", ia.fetch_buffer())
        i = 0
        done = False
        while not done:
            with ia.fetch_buffer() as buffer:
                print("checkr 1")
                img = buffer.payload.components[0].data
                img = img.reshape(buffer.payload.components[0].height,
                                  buffer.payload.components[0].width)
                # img_copy = img.copy()
                img_copy = cv2.cvtColor(img, cv2.COLOR_BayerRG2RGB)
                cv2.namedWindow("window",
                                cv2.WINDOW_KEEPRATIO | cv2.WINDOW_NORMAL)
                cv2.imshow("window", img_copy)
                fps = ia.statistics.fps
                print("FPS: ", fps)
                if cv2.waitKey(10) == ord('q'):
                    done = True
                    print('break')
                i = i + 1
    except Exception as e:
        traceback.print_exc(file=sys.stdout)
    finally:
        ia.stop_image_acquisition()
        ia.destroy()
        cv2.destroyAllWindows()
        print('fin')
        h.reset()
Esempio n. 11
0
def camera_stream():
    global outputFrame, lock
    
    h = Harvester()
    h.add_cti_file('/opt/mvIMPACT_Acquire/lib/x86_64/mvGenTLProducer.cti')
    h.update_device_info_list()
    ia = h.create_image_acquirer(0)
    #ia.device.node_map.PixelFormat.value = 'BayerRG8'
    #ia.device.node_map.TestPattern = 'HorizontalColorBar'
    try:
        ia.start_image_acquisition()
        i = 0
        done = False

        while not done:
            with ia.fetch_buffer() as buffer:
                img = buffer.payload.components[0].data
                img = img.reshape(
                    buffer.payload.components[0].height, buffer.payload.components[0].width)
                img_copy = img.copy()
                img_copy = cv2.cvtColor(img, cv2.COLOR_BayerRG2RGB)

                if i == 0:
                    first = img_copy.copy()

                change = np.allclose(first, img_copy, 3)

                #print(change)
                if not change:

                    # cv2.namedWindow("window", cv2.WINDOW_KEEPRATIO | cv2.WINDOW_NORMAL)
                    # cv2.imshow("window", img_copy)
                    #cv2.imwrite(f'./images/image_{i}.png', img_copy)
                    
                    outputFrame = img_copy.copy()
                    print(outputFrame)

                first = img_copy.copy()

                if cv2.waitKey(10) == ord('q'):
                    fps = ia.statistics.fps
                    print("FPS: ", fps)
                    done = True
                    print('break')
                i = i + 1
                if i == 500:
                    break
    except Exception as e:
        traceback.print_exc(file=sys.stdout)
    finally:
        ia.stop_image_acquisition()
        ia.destroy()
        cv2.destroyAllWindows()
        print('fin')
        h.reset()
Esempio n. 12
0
    def __init__(self):
        Node.__init__(self, "Harvesters")
        Observable.__init__(self, self._on_subscribe)
        self.cfg = self.config[SECTION]
        self.harvester = Harvester()
        if self.cfg["disableInternalLogger"]:
            self.harvester._logger.setLevel(100)

        self.cti_file = self.cfg["ctiFile"]
        self.harvester.add_file(self.cti_file)
        self.logger.info(f"Loaded harvester cti file {self.cti_file}")
        self.harvester.update()
        self.logger.info(
            f"Found {len(self.harvester.device_info_list)} devices.")
Esempio n. 13
0
    def __init__(self):
        from harvesters.core import Harvester

        super().__init__()
        self.config = config.SettingAccessor(self.config_prefix)
        self.logger = logging.getLogger("console")
        self._stop = subject.Subject()
        self.driver = Harvester()
        self.driver.add_cti_file(self.config["cti_path"])
        self.acquirer = None
        self.simex_instance = None
        self.running = False
        self.scheduler = scheduler.NewThreadScheduler()
        self.scheduler.schedule(
            lambda sc, state: self.driver.update_device_info_list())
Esempio n. 14
0
    def __init__(self, producer_paths=None):
        super(Camera_harvester, self).__init__()

        self.name = "Harvester"

        ##Harvester object used to communicate with Harvester module
        self.h = Harvester()

        ##paths to GenTL producers
        self.paths = []
        if (producer_paths):
            for path in producer_paths:
                self.add_gentl_producer(path)

        ##Image acquifier object used by Harvester
        self.ia = None
Esempio n. 15
0
    def __init__(self, device_handle):
        """
        Implementation of the JAI camera device

        Parameters
        ----------
        device_handle : object
            Unique camera device handle to identify the camera
        """
        # Use the same Harvester core if it is already created
        if not Controller.harvester_instance:
            Controller.harvester_instance = Harvester()
        self._harverster = Controller.harvester_instance

        self.device_handle = device_handle

        super(Camera, self).__init__(device_handle)
        self.logger = logging.getLogger(__name__)
        if LOGGING_LEVEL is not None:
            self.logger.setLevel(LOGGING_LEVEL)

        self.openDevice()
        self.img_list = list()
        self._setTriggerSource(source_name='Line5')

        # Not needed, Just in case a previous Resolution was wrongly set.
        self.node_map.Width.value = self.node_map.WidthMax.value
        self.node_map.Height.value = self.node_map.HeightMax.value

        # Register JAI Camera specific functions.
        # Function to set maximum transfer rate depending has to be yet implemented
        self.registerFeature("gainselector", self._gain_selector)
Esempio n. 16
0
    def test_issue_85(self):
        #
        temp_dir = os.path.join(
            gettempdir(), 'harvester', self.test_issue_85.__name__
        )

        #
        if os.path.isdir(temp_dir):
            rmtree(temp_dir)
        os.makedirs(temp_dir)

        #
        os.environ[self.env_var] = temp_dir

        #
        self.assertFalse(os.listdir(temp_dir))

        #
        with Harvester() as h:
            h.add_file(self._cti_file_path)
            h.update()
            with h.create_image_acquirer(0):
                # Check if XML files have been stored in the expected
                # directory:
                self.assertTrue(os.listdir(temp_dir))
Esempio n. 17
0
    def test_issue_85(self):
        #
        temp_dir = os.path.join(
            gettempdir(), 'harvester', self.test_issue_85.__name__
        )

        #
        if os.path.isdir(temp_dir):
            rmtree(temp_dir)
        os.makedirs(temp_dir)

        #
        env_var = 'HARVESTERS_XML_FILE_DIR'
        original = None if os.environ else os.environ[env_var]

        os.environ[env_var] = temp_dir

        #
        self.assertFalse(os.listdir(temp_dir))

        #
        with Harvester() as h:
            h.add_cti_file(self._cti_file_path)
            h.update_device_info_list()
            with h.create_image_acquirer(0):
                pass

        #
        if original:
            os.environ[env_var] = original

        #
        self.assertTrue(os.listdir(temp_dir))
Esempio n. 18
0
def run_camera():
    # Create a Harvester object:
    h = Harvester()

    # Load a GenTL Producer; you can load many more if you want to:   ##find producer
    h.add_file(
        'C:\Program Files\Allied Vision\Vimba_4.2\VimbaGigETL\Bin\Win64\VimbaGigETL.cti'
    )

    # Enumerate the available devices that GenTL Producers can handle:
    h.update()
    print(h.device_info_list)

    # Select a target device and create an ImageAcquire object that
    # controls the device:
    ia = h.create_image_acquirer(0)

    # Configure the target device; it looks very small but this is just
    # for demonstration:
    # ia.remote_device.node_map.Width.value = 1936
    # ia.remote_device.node_map.Height.value = 1216
    # ia.remote_device.node_map.PixelFormat.value = 'RGB8Packed'

    # Allow the ImageAcquire object to start image acquisition:
    ia.start_acquisition()

    # We are going to fetch a buffer filled up with an image:
    # Note that you'll have to queue the buffer back to the
    # ImageAcquire object once you consumed the buffer; the
    # with statement takes care of it on behalf of you:
    with ia.fetch_buffer() as buffer:
        # Let's create an alias of the 2D image component; it can be
        # lengthy which is not good for typing. In addition, note that
        # a 3D camera can give you 2 or more components:
        component = buffer.payload.components[0]

        # Reshape the NumPy array into a 2D array:
        image_rgb = component.data.reshape(component.height, component.width,
                                           3)

        image_bgr = cv2.cvtColor(image_rgb, cv2.COLOR_RGB2BGR)

        # img_inference runs both models
        processing_time, boxes, scores, labels = img_inference(image_bgr)

    # Stop the ImageAcquier object acquiring images:
    ia.stop_acquisition()

    # We're going to leave here shortly:
    ia.destroy()
    h.reset()
Esempio n. 19
0
 def run(self):
     h = Harvester()
     h.add_file(self._cti_file_path)
     h.update()
     try:
         ia = h.create_image_acquirer(0)
     except:
         # Transfer the exception anyway:
         self._message_queue.put(sys.exc_info())
     else:
         ia.start_acquisition()
         ia.stop_acquisition()
         ia.destroy()
         h.reset()
Esempio n. 20
0
    def __init__(self,
                 SetCameraLighting,
                 Config_module=None,
                 Warnings_module=None):

        # Misc
        from time import sleep
        import sys

        self.sleep = sleep
        self.warnings = Warnings_module
        self.sys = sys

        # Store custom module
        self.FileConfig = Config_module

        # Lights function
        self.SetCameraLighting = SetCameraLighting

        # GenICam helper
        from harvesters.core import Harvester, TimeoutException

        # Init harvester
        self.harvester = Harvester()
        self.TimeoutException = TimeoutException

        # Temperature
        self.criticalTemp = self.FileConfig.Get(
            "Cameras")["Generic"]["Temperature"]["Critical"]
        self.warningTemp = self.FileConfig.Get(
            "Cameras")["Generic"]["Temperature"]["Warning"]

        # Storage for camera modules
        self.n_camera = self.FileConfig.Get("QuickSettings")["ActiveCameras"]

        self.ImportCTI()  # import cti file
        self.Scan()  # check if producer is available
        self.Create()  # define image Acquirer objects from discovered devices
        self.Config()  # configure image acquirer objects

        self.ImportOpenCV()  # Create opencv module
Esempio n. 21
0
    def open(self) -> None:
        """TBW."""
        if self._simulate:
            return
        h = Harvester()

        locs = [
            r"~/tools/mvImpact/lib/x86_64/mvGenTLProducer.cti",
            r"C:\Program Files\MATRIX VISION\mvIMPACT Acquire\bin\x64\mvGenTLProducer.cti"
        ]
        cti = ""
        for loc in locs:
            if Path(loc).expanduser().exists():
                cti = loc
        if not cti:
            raise FileNotFoundError(
                "Could not locate cti file: mvGenTLProducer.cti")

        cti = str(Path(cti).expanduser())
        h.add_file(cti)
        h.update()
        len(h.device_info_list)
        h.device_info_list[0]
        print("creating ia....")
        ia = h.create_image_acquirer(0)
        print("ia created")
        # ia = h.create_image_acquirer(serial_number='050200047485')
        # ia.remote_device.node_map.Width.value = 1024  # max: 1312
        # ia.remote_device.node_map.Height.value = 1024  # max: 1082
        # ia.remote_device.node_map.PixelFormat.value = 'Mono12'

        from harvesters.core import ImageAcquirer
        print(ImageAcquirer.Events.__members__)
        from harvesters.core import Callback

        class CallbackOnNewBuffer(Callback):
            def __init__(self, ia: ImageAcquirer):
                #
                super().__init__()
                #
                self._ia = ia

            def emit(self, context):
                # # You would implement this method by yourself.
                # with _ia.fetch_buffer() as buffer:
                #     # Work with the fetched buffer.
                #     print(buffer)
                print(datetime.utcnow(), "New image")

        on_new_buffer = CallbackOnNewBuffer(self)
        ia.add_callback(ia.Events.NEW_BUFFER_AVAILABLE, on_new_buffer)

        ia.start_acquisition(run_in_background=True)
        self._dev = h
        self._ia = ia
        self.on_new_buffer = on_new_buffer
Esempio n. 22
0
class TestHarvesterCoreBase(unittest.TestCase):
    _cti_file_path = get_cti_file_path()
    sys.path.append(_cti_file_path)

    def __init__(self, *args, **kwargs):
        #
        super().__init__(*args, **kwargs)

        #
        self._harvester = None
        self._ia = None
        self._thread = None
        self._logger = get_logger(name='harvesters', level=DEBUG)
        self._buffers = []

    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger)
        self._harvester.add_cti_file(self._cti_file_path)
        self._harvester.update_device_info_list()

    def tearDown(self):
        #
        if self.ia:
            self.ia.destroy()

        #
        self._harvester.reset()

        #
        self._ia = None

        #
        super().tearDown()

    @property
    def harvester(self):
        return self._harvester

    @property
    def ia(self):
        return self._ia

    @ia.setter
    def ia(self, value):
        self._ia = value

    @property
    def general_purpose_thread(self):
        return self._thread

    @general_purpose_thread.setter
    def general_purpose_thread(self, value):
        self._thread = value

    def is_running_with_default_target(self):
        return True if 'TLSimu.cti' in self._cti_file_path else False
class TestHarvesterCoreBase(unittest.TestCase):
    _path = 'C:/Users/z1533tel/dev/genicam/bin/Win64_x64/' \
        if is_running_on_windows() else \
        '/Users/kznr/dev/genicam/bin/Maci64_x64/'

    _filename = 'TLSimu.cti'

    sys.path.append(_path)

    def __init__(self, *args, **kwargs):
        #
        super().__init__(*args, **kwargs)

        #
        self._harvester = None
        self._iam = None
        self._thread = None

    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester()
        self._harvester.add_cti_file(self._path + self._filename)
        self._harvester.update_device_info_list()
        self._iam = None
        self._thread = None

    def tearDown(self):
        #
        if self.iam:
            self.iam.destroy()

        #
        self._harvester.reset()

        #
        super().tearDown()

    @property
    def harvester(self):
        return self._harvester

    @property
    def iam(self):
        return self._iam

    @iam.setter
    def iam(self, value):
        self._iam = value

    @property
    def general_purpose_thread(self):
        return self._thread

    @general_purpose_thread.setter
    def general_purpose_thread(self, value):
        self._thread = value
Esempio n. 24
0
    def __init__(self, *, vsync=True, logger=None):
        #
        self._logger = logger or get_logger(name='harvesters')

        #
        super().__init__()

        #
        self._mutex = QMutex()

        profile = True if 'HARVESTER_PROFILE' in os.environ else False
        self._harvester_core = HarvesterCore(profile=profile,
                                             logger=self._logger)
        self._ia = None  # Image Acquirer

        #
        self._widget_canvas = Canvas2D(vsync=vsync)
        self._widget_canvas.create_native()
        self._widget_canvas.native.setParent(self)

        #
        self._action_stop_image_acquisition = None

        #
        self._observer_widgets = []

        #
        self._widget_device_list = None
        self._widget_status_bar = None
        self._widget_main = None
        self._widget_about = None
        self._widget_attribute_controller = None

        #
        self._signal_update_statistics.connect(self.update_statistics)
        self._signal_stop_image_acquisition.connect(
            self._stop_image_acquisition)
        self._thread_statistics_measurement = _PyQtThread(
            parent=self,
            mutex=self._mutex,
            worker=self._worker_update_statistics,
            update_cycle_us=250000)

        #
        self._initialize_widgets()

        #
        for o in self._observer_widgets:
            o.update()
Esempio n. 25
0
class Camera(QtCore.QObject):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.harvester = Harvester()
        self.acquirer = None

    def load_cti_from_env(self):
        if arch.is_64bits:
            env_name = "GENICAM_GENTL64_PATH"
        else:
            env_name = "GENICAM_GENTL32_PATH"

        genicam_paths = os.environ[env_name].split(os.pathsep)
        cti_files = glob.glob(os.path.join(genicam_paths, "*.cti"))

        for cti in cti_files:
            self.harvester.add_cti_file(cti)

    def reload_device(self):
        self.harvester.update_device_info_list()

    def list_devices(self, reload=False) -> DeviceInfoList:
        if reload:
            self.reload_device()
        return self.harvester.device_info_list

    def use_device(self, cam_id, cfg_file):
        devices = self.list_devices()

        self.acquirer = self.harvester.create_image_acquirer(id_=cam_id)

        parser = configparser.ConfigParser()
        parser.read(cfg_file)
        config: dict = parser["DEVICE_CONFIG"]
        for k, v in config.items():
            node_map: NodeMap = self.acquirer.device.node_map
Esempio n. 26
0
    def __init__(self, *, logger=None):
        #
        self._logger = logger or get_logger(name=__name__)

        #
        super().__init__()

        #
        self._mutex = QMutex()

        profile = True if 'HARVESTER_PROFILE' in os.environ else False
        self._harvester_core = HarvesterCore(profile=profile,
                                             logger=self._logger)
        self._iam = None  # Image Acquisition Manager

        self._widget_canvas = Canvas()
        self._widget_canvas.set_shaders()  # Pass custom shares if needed.
        self._widget_canvas.create_native()
        self._widget_canvas.native.setParent(self)

        #
        self._action_stop_image_acquisition = None

        #
        self._observer_widgets = []

        #
        self._widget_device_list = None
        self._widget_status_bar = None
        self._widget_main = None
        self._widget_about = None
        self._widget_attribute_controller = None

        #
        self._signal_update_statistics.connect(self.update_statistics)
        self._signal_stop_image_acquisition.connect(
            self._stop_image_acquisition)

        #
        self._initialize_widgets()

        #
        for o in self._observer_widgets:
            o.update()

        self._is_going_to_terminate = False
Esempio n. 27
0
    def __init__(self):
        #
        super().__init__()

        #
        self._mutex = QMutex()
        self._harvester_core = HarvesterCore(
            frontend=self, profile=False, parent=self
        )
        self._iam = None  # Image Acquisition Manager

        self._widget_canvas = Canvas()
        self._widget_canvas.set_shaders()  # Pass custom shares if needed.
        self._widget_canvas.create_native()
        self._widget_canvas.native.setParent(self)

        #
        self._action_stop_image_acquisition = None

        #
        self._observer_widgets = []

        #
        self._widget_device_list = None
        self._widget_status_bar = None
        self._widget_main = None
        self._widget_about = None
        self._widget_attribute_controller = None

        #
        self._signal_update_statistics.connect(self.update_statistics)
        self._signal_stop_image_acquisition.connect(self._stop_image_acquisition)

        #
        self._initialize_widgets()

        #
        for o in self._observer_widgets:
            o.update()

        self._is_going_to_terminate = False
Esempio n. 28
0
    def __init__(self):
        """
        Camera controller for JAI camera devices. This implementation uses
        Harvester as backend.
        """
        if Controller.harvester_instance is None:
            Controller.harvester_instance = Harvester()
        self._harverster = Controller.harvester_instance

        super(Controller, self).__init__()
        self.logger = logging.getLogger(__name__)
        if LOGGING_LEVEL is not None:
            self.logger.setLevel(LOGGING_LEVEL)
        self.logger.debug('Starting JAI Camera Controller')

        try:
            self._harverster.add_cti_file(CTI_FILE)
        except LoadLibraryException:
            raise LoadLibraryException(
                "Installation path differs from default "
                "value. Change constant CTI_FILE to "
                "correct file path.")
def create(observer, sc=None):
    h = Harvester()
    h.add_cti_file(
        "C:\\Program Files\\MATRIX VISION\\mvIMPACT Acquire\\bin\\x64\\mvGenTLProducer.cti"
    )
    h.update_device_info_list()
    acquirer = h.create_image_acquirer(0)
    print("create")

    def on_new_buffer_arrival():
        buffer = acquirer.fetch_buffer()
        print("buffer")
        observer.on_next(buffer)
        buffer.queue()

    def dispose():
        # scheduler.NewThreadScheduler().schedule(lambda *args: acquirer.stop_image_acquisition())
        acquirer.stop_image_acquisition()

    acquirer.on_new_buffer_arrival = on_new_buffer_arrival
    acquirer.start_image_acquisition()
    return Disposable(dispose)
Esempio n. 30
0
class TestHarvesterCoreBase(unittest.TestCase):
    name = 'HARVESTER_TEST_TARGET'
    if name in os.environ:
        _cti_file = os.getenv(name)
    else:
        if is_running_on_windows():
            _cti_file = 'C:/Users/z1533tel/dev/genicam/bin/Win64_x64'
        else:
            if is_running_on_macos():
                _cti_file = '/Users/kznr/dev/genicam/bin/Maci64_x64'
            else:
                _cti_file = '/home/vagrant/dev/genicam/bin/Linux64_x64'

        _cti_file += '/TLSimu.cti'

    sys.path.append(_cti_file)

    def __init__(self, *args, **kwargs):
        #
        super().__init__(*args, **kwargs)

        #
        self._harvester = None
        self._ia = None
        self._thread = None
        self._logger = get_logger(name='harvesters', level=DEBUG)

    def setUp(self):
        #
        super().setUp()

        #
        self._harvester = Harvester(logger=self._logger)
        self._harvester.add_cti_file(self._cti_file)
        self._harvester.update_device_info_list()

    def tearDown(self):
        #
        if self.ia:
            self.ia.destroy()

        #
        self._harvester.reset()

        #
        self._ia = None

        #
        super().tearDown()

    @property
    def harvester(self):
        return self._harvester

    @property
    def ia(self):
        return self._ia

    @ia.setter
    def ia(self, value):
        self._ia = value

    @property
    def general_purpose_thread(self):
        return self._thread

    @general_purpose_thread.setter
    def general_purpose_thread(self, value):
        self._thread = value

    def is_running_with_default_target(self):
        return True if 'TLSimu.cti' in self._cti_file else False