Ejemplo n.º 1
0
    def init_cameras(self):
        try:
            # Initialize StApi before using.
            st.initialize()

            # Create a system object for device scan and connection.
            st_system = st.create_system()

            while True:
                try:
                    self.st_devices.append(st_system.create_first_device())
                except:
                    if len(self.st_devices) == 0:
                        raise
                    break

                # Display the DisplayName of the device.
                print("Device {0} = {1}".format(len(self.st_devices),
                      self.st_devices[len(self.st_devices)-1].info.display_name))

                # Create a DataStream object
                self.st_datastreams.append(self.st_devices[len(self.st_devices)-1].create_datastream())

                # setup the image transfer callback functions
                my_callback = CMyCallback(len(self.st_devices),
                        self.st_devices[len(self.st_devices)-1].info.display_name)
                self.my_callbacks.append(my_callback)
                self.cb_funcs.append(my_callback.datastream_callback)

                # Get the nodemap for the camera settings.
                nodemap = self.st_devices[len(self.st_devices)-1].remote_port.nodemap

                # Set the TriggerSelector for FrameStart or ExposureStart.
                try:
                    set_enumeration(
                        nodemap, TRIGGER_SELECTOR, TRIGGER_SELECTOR_FRAME_START)
                except st.PyStError:
                    set_enumeration(
                        nodemap, TRIGGER_SELECTOR, TRIGGER_SELECTOR_EXPOSURE_START)

                # Set the TriggerMode to On.
                set_enumeration(nodemap, TRIGGER_MODE, TRIGGER_MODE_ON)

                # Set the TriggerSource to Software
                set_enumeration(nodemap, TRIGGER_SOURCE, TRIGGER_SOURCE_SOFTWARE)

                # Get and cast to Command interface of the TriggerSoftware mode
                self.trigger_softwares.append(st.PyICommand(nodemap.get_node(TRIGGER_SOFTWARE)))

        # Start the image acquisition of the host side.
        for counter, st_datastream in enumerate(self.st_datastreams):
            # Register callback for datastream
            callback = self.st_datastream.register_callback(self.cb_funcs[counter])

            # Start the image acquisition of the host (local machine) side.
            st_datastream.start_acquisition()

        # Start the image acquisition of the camera side.
        for device in self.st_devices:
            device.acquisition_start()
Ejemplo n.º 2
0
    def init_cameras(self):
        try:
            # Initialize StApi before using.
            st.initialize()

            # Create a system object for device scan and connection.
            st_system = st.create_system()

            # discovered camera index
            i = 0

            while True:
                try:
                    st_device = st_system.create_first_device()
                    self.st_devices.append(st_device)
                except:
                    if len(self.st_devices) == 0:
                        raise
                    break

                # Display the DisplayName of the device.
                cam_disp_name = st_device.info.display_name
                logging.debug("Device {0} = {1}".format(
                    len(self.st_devices), cam_disp_name))

                # determine camera Number
                if cam_disp_name == CAMERA_1_ID:
                    cam_num = 1
                elif cam_disp_name == CAMERA_2_ID:
                    cam_num = 2
                elif cam_disp_name == CAMERA_3_ID:
                    cam_num = 3
                else:
                    raise NameError('Unknown Camera ID.')

                # setup the image transfer callback functions
                my_cam = Camera(cam_num)
                self.cameras.append(my_cam)

                acquisition_frame_rate = st_device.remote_port.nodemap.get_node(
                    "AcquisitionFrameRate")
                if acquisition_frame_rate:
                    self.fps = acquisition_frame_rate.value

                # Create a DataStream object
                st_datastream = st_device.create_datastream()
                self.st_datastreams.append(st_datastream)

                i += 1

        except Exception as exception:
            logging.error("init: " + exception)
Ejemplo n.º 3
0
    # Note that depending on your use case, there are three ways to set
    # the enumeration value:
    # 1) Assign the integer value of the entry with set_int_value(val) or .value
    # 2) Assign the symbolic value of the entry with set_symbolic_value("val")
    # 3) Assign the entry (PyIEnumEntry) with set_entry_value(entry)
    # Here set_entry_value is used:
    enum_node.set_entry_value(entry_node)


if __name__ == "__main__":
    try:
        # Initialize StApi before using.
        st.initialize()

        # Create a system object for device scan and connection.
        st_system = st.create_system()

        # Connect to first detected device.
        st_device = st_system.create_first_device()

        # Display DisplayName of the device.
        print('Device=', st_device.info.display_name)

        # Get the nodemap for the camera settings.
        nodemap = st_device.remote_port.nodemap

        # Set the TriggerSelector for FrameStart or ExposureStart.
        try:
            set_enumeration(nodemap, TRIGGER_SELECTOR,
                            TRIGGER_SELECTOR_FRAME_START)
        except st.PyStError:
Ejemplo n.º 4
0
    device_ip = iface_nodemap.get_node("GevDeviceIPAddress")
    for index in range(max_index + 1):
        device_selector.value = index
        if device_ip.is_available:
            if device_ip.value == ip_address:
                return pinterface.create_device_by_index(index)
    return None


if __name__ == "__main__":
    try:
        # Initialize StApi before using.
        st.initialize()

        # Create a system object for device scan and connection only for GigE.
        st_system = st.create_system(st.EStSystemVendor.Default,
                                     st.EStInterfaceType.GigEVision)
        for index in range(st_system.interface_count):
            st_interface = st_system.get_interface(index)
            if st_interface.device_count > 0:
                break

        # Update the IP address setting of the first detected GigE device.
        update_device_ip_address(st_interface.port.nodemap)

        # Get the updated IP address
        device_force_ip = st_interface.port.nodemap\
            .get_node(GEV_DEVICE_FORCE_IP_ADDRESS)

        # Create a camera device object and connect.
        st_device = None
        for loop in range(30):