コード例 #1
0
    def __init__(self, mediaStreamDescriptor):
        try:
            # media descriptor holding input data format
            self._mediaStreamDescriptor = mediaStreamDescriptor

            # Get how data will be transferred
            if self._mediaStreamDescriptor.WhichOneof(
                    "data_transfer_properties") is None:
                self._contentTransferType = TransferType.BYTES
            elif self._mediaStreamDescriptor.HasField(
                    "shared_memory_buffer_transfer_properties"):
                self._contentTransferType = TransferType.REFERENCE
            elif self._mediaStreamDescriptor.HasField(
                    "shared_memory_segments_transfer_properties"):
                self._contentTransferType = TransferType.HANDLE

            # Setup if shared mem used
            if self._contentTransferType == TransferType.REFERENCE:
                # Create shared memory accessor specific to the client
                self._sharedMemoryManager = SharedMemoryManager(
                    name=self._mediaStreamDescriptor.
                    shared_memory_buffer_transfer_properties.handle_name,
                    size=self._mediaStreamDescriptor.
                    shared_memory_buffer_transfer_properties.length_bytes)
            else:
                self._sharedMemoryManager = None

        except:
            PrintGetExceptionDetails()
            raise
コード例 #2
0
def get_detector_shared_manager(detector_type,
                                device="CPU",
                                precision="FP32",
                                init_shared_mem=True):
    try:
        if init_shared_mem:
            shared_manager = SharedMemoryManager(image_file_handle, shm_size)
        else:
            shared_manager = None
    except:
        logging.warn("Shared memory not present")
        raise

    if detector_type == "opencv":
        from ssd_object_detection import Detector

        detector = Detector(use_gpu=True, people_only=True)
    elif detector_type == "openvino":
        from ssd_object_detection_openvino import OpenVinoDetector

        detector = OpenVinoDetector(device_name=device)
    else:
        raise ValueError("Unknown detector type")

    return shared_manager, detector