示例#1
0
    def __init__(self,
                 interface="all",
                 camera_num=0,
                 *,
                 metadata_mode=False,
                 timestamp_mode=True):
        """
        pco.sdk_manual page 10:
        First step is to PCO_OpenCamera
        As next step camera description and status should be queried
        by calling PCO_GetCameraDescription and PCO_GetCameraHealthStatus
        """

        print("interface =", interface)
        print("camera_num =", camera_num)

        self.handle = pf.PCO_OpenCameraEx(interface, camera_num)
        self.camera_description = pf.PCO_GetCameraDescription(self.handle)
        warn, err, status = self.health_status()
        if warn or err:
            print("Warning bits :", warn)
            print("Error bits :", err)
        else:
            print("Connected to", pf.PCO_GetInfoString(self.handle))
            print("Status bits :", status)
        pf.PCO_SetBitAlignment(self.handle, sys.byteorder == "little")
        self.metadata_mode = metadata_mode
        self.timestamp_mode = timestamp_mode
        if timestamp_mode:
            # Timestamp is supported by all cameras but the information
            # is written on the first 14 pixels of the transfered image
            pf.PCO_SetTimestampMode(
                self.handle,
                0x0001)  # binary mode (BCD coded in the first 14 px)
        else:
            pf.PCO_SetTimestampMode(self.handle, 0x0000)
        if metadata_mode:
            # MetaData is supported on pco.dimax and pco.edge only
            MetaDataSize, MetaDataVersion = pf.PCO_SetMetaDataMode(
                self.handle, True)
            self.MetaDataSize = MetaDataSize
            self.MetaDataVersion = MetaDataVersion
示例#2
0
                                        buffer.bufPtr[:14])
                                    stop_signal = yield MetadataArray(
                                        buffer.as_array(),
                                        metadata={
                                            "counter": counter,
                                            "timestamp": dt
                                        },
                                    )
                                else:
                                    stop_signal = yield buffer.as_array()
                            count += 1
                            pf.PCO_AddBufferEx(self.handle, 0, 0, buffer.bufNr,
                                               XResAct, YResAct, 16)
                        else:
                            break
                        if stop_signal:
                            break
                    if stop_signal:
                        break
            finally:
                pf.PCO_SetRecordingState(self.handle, False)
                pf.PCO_CancelImages(self.handle)
        if stop_signal:
            yield True


if __name__ == "__main__":
    h = pf.PCO_OpenCameraEx("USB 3.0", 0)
    pf.PCO_GetInfoString(h)
    pf.PCO_CloseCamera(h)