Example #1
0
 def _get_packet_content(self, packet_data_type: _PacketDataType,
                         output_packet: packet.Packet) -> Any:
     if packet_data_type == _PacketDataType.STRING:
         return packet_getter.get_str(output_packet)
     elif packet_data_type == _PacketDataType.IMAGE:
         return packet_getter.get_image_frame(output_packet).numpy_view()
     else:
         return getattr(packet_getter,
                        'get_' + packet_data_type.value)(output_packet)
Example #2
0
  def _get_packet_content(self, packet_data_type: _PacketDataType,
                          output_packet: packet.Packet) -> Any:
    """Gets packet content from a packet by type.

    Args:
      packet_data_type: The supported packet data type.
      output_packet: The packet to get content from.

    Returns:
      Packet content by packet data type. None to indicate "no output".

    """

    if output_packet.is_empty():
      return None
    if packet_data_type == _PacketDataType.STRING:
      return packet_getter.get_str(output_packet)
    elif (packet_data_type == _PacketDataType.IMAGE_FRAME or
          packet_data_type == _PacketDataType.IMAGE):
      return getattr(packet_getter, 'get_' +
                     packet_data_type.value)(output_packet).numpy_view()
    else:
      return getattr(packet_getter, 'get_' + packet_data_type.value)(
          output_packet)