# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from zzz_perception_msgs/DetectionBox2D.msg. Do not edit."""
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct

import zzz_perception_msgs.msg
import protocol.std_msgs.msg as std_msgs
import sensor_msgs.msg

class DetectionBox2D(genpy.Message):
  _md5sum = "f629d8347d66d6fc621496f7299fa8a8"
  _type = "zzz_perception_msgs/DetectionBox2D"
  _has_header = False #flag to mark the presence of a Header object
  _full_text = """# Defines a box-shaped 2D detection result.

# ----------------- Data -----------------

# The 2D data that generated these results (i.e. region proposal cropped out of
#   the image). Not required for all use cases, so it may be empty.
sensor_msgs/Image source_img

# ---------------- Properties --------------------

# Describe several classification result for the object
# This field is required to be sorted in descending order of scores
ObjectClass[] classes

# This field indicates visual (or sound?) signal from the object
ObjectSignals signal

# 2D bounding box surrounding the object.
BoundingBox2D bbox

# This field is for store auxiliary text or data
string comments

================================================================================
MSG: sensor_msgs/Image
# This message contains an uncompressed image
# (0, 0) is at top-left corner of image
#

Header header        # Header timestamp should be acquisition time of image
                     # Header frame_id should be optical frame of camera
                     # origin of frame should be optical center of camera
                     # +x should point to the right in the image
                     # +y should point down in the image
                     # +z should point into to plane of the image
                     # If the frame_id here and the frame_id of the CameraInfo
                     # message associated with the image conflict
                     # the behavior is undefined

uint32 height         # image height, that is, number of rows
uint32 width          # image width, that is, number of columns

# The legal values for encoding are in file src/image_encodings.cpp
# If you want to standardize a new string format, join
# ros-users@lists.sourceforge.net and send an email proposing a new encoding.

string encoding       # Encoding of pixels -- channel meaning, ordering, size
                      # taken from the list of strings in include/sensor_msgs/image_encodings.h

uint8 is_bigendian    # is this data bigendian?
uint32 step           # Full row length in bytes
uint8[] data          # actual matrix data, size is (step * rows)

================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data 
# in a particular coordinate frame.
# 
# sequence ID: consecutively increasing ID 
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
string frame_id

================================================================================
MSG: zzz_perception_msgs/ObjectClass
# The size of (in meters) the bounding box surrounding the object's center pose.

# The unique numeric classification ID of object detected
uint32 classid

# The probability or confidence value of the detected object. By convention, this value should lie in the range 0~1.
float32 score

# Other information about the class (e.g. class name). Only for debug
string comments

##############################################################
###   Here is a hierarchical table of all included types   ###
##############################################################
# Hierarchy is encoded in a 32-bit integer. Each 8 bit stand for a level, and leftmost 8 bit is the top level

uint32 UNKNOWN                          = 0     # 0x0000
uint32 UNKNOWN_DYNAMIC                  = 16    # 0x0010
uint32 UNKNOWN_STATIC                   = 32    # 0x0020

uint32 VEHICLE                          = 1     # 0x0001
uint32 VEHICLE_PASSENGER                = 17    # 0x0011, normal passenger_vehicles
uint32 VEHICEL_VAN                      = 33    # 0x0021
uint32 VEHICLE_TRUCK                    = 49    # 0x0031
uint32 VEHICLE_BUS                      = 65    # 0x0041
uint32 VEHICLE_SCHOOLBUS                = 321   # 0x0141
uint32 VEHICLE_SCHOOLBUS_STOP           = 4417  # 0x1141
uint32 VEHICLE_EMERGENCY                = 81    # 0x0051, emergency vehicles, including 
uint32 VEHICLE_EMERGENCY_POLICE         = 337   # 0x0151
uint32 VEHICLE_EMERGENCY_POLICE_FLASH   = 4433  # 0x1151
uint32 VEHICLE_EMERGENCY_FIRE           = 593   # 0x0251
uint32 VEHICLE_EMERGENCY_FIRE_FLASH     = 4689  # 0x1251
uint32 VEHICLE_EMERGENCY_CIVIL          = 849   # 0x0351, including utility vehicle and tow trucks
uint32 VEHICLE_EMERGENCY_CIVIL_FLASH    = 4945  # 0x1351

uint32 HUMAN                            = 2     # 0x0002
uint32 HUMAN_PEDESTRIAN                 = 18    # 0x0012
uint32 HUMAN_ROADWORKER                 = 34    # 0x0022

uint32 CYCLIST                          = 3     # 0x0003
uint32 CYCLIST_BICYCLE                  = 19    # 0x0013
uint32 CYCLIST_MOTORCYCLE               = 35    # 0x0023
uint32 CYCLIST_TRICYCLE                 = 51    # 0x0033

uint32 ANIMAL                           = 4     # 0x0004
uint32 ANIMAL_DOGLIKE                   = 20    # 0x0014, includes dog, cat, wolf, etc.
uint32 ANIMAL_DEERLIKE                  = 36    # 0x0024, includes deer, etc.
uint32 ANIMAL_COWLIKE                   = 52    # 0x0034, includes cow, horse, pig, etc.

uint32 ROAD_OBJECT                      = 5     # 0x0005, objects in road area
uint32 ROAD_TRAFFIC_CONE                = 21    # 0x0015, traffic cone
uint32 ROAD_TRAFFIC_BLOCKER             = 37    # 0x0025, traffic blocker, e.g. "Road Closed" sign

uint32 ROADSIDE_OBJECT                  = 6     # 0x0006, objects in road side
uint32 ROADSIDE_TRAFFIC_LIGHT           = 22    # 0x0016
uint32 ROADSIDE_TRAFFIC_SIGN            = 38    # 0x0026
uint32 ROADSIDE_TREE                    = 54    # 0x0036, including all roadside vegetation

uint32 LEVEL_MASK_0                     = 15    # 0x000f
uint32 LEVEL_MASK_1                     = 255   # 0x00ff
uint32 LEVEL_MASK_2                     = 4095  # 0x0fff
uint32 LEVEL_MASK_3                     = 65535 # 0xffff

================================================================================
MSG: zzz_perception_msgs/ObjectSignals
# This message is used to represent detected vehicle light signals or human hand signals

# Signal flags. Multiple signal emission can exists in the same time.
uint16 flags

uint16 UNKNOWN                          = 0     # 0x00
uint16 NONE                             = 16    # 0x10

# This field is related to https://en.wikipedia.org/wiki/Automotive_lighting
uint16 VEHICLE_SIGNAL                   = 1     # 0x01
uint16 VEHICLE_SIGNAL_LEFT_TURN         = 17    # 0x11
uint16 VEHICLE_SIGNAL_RIGHT_TURN        = 33    # 0x21
uint16 VEHICLE_SIGNAL_HAZARD            = 49    # 0x31
uint16 VEHICLE_SIGNAL_BRAKE             = 65    # 0x41
uint16 VEHICLE_SIGNAL_REVERSE           = 81    # 0x51

# This field is related to https://en.wikipedia.org/wiki/Traffic_light#Single_aspects
uint16 TRAFFIC_LIGHT                    = 2     # 0x02
uint16 TRAFFIC_LIGHT_RED                = 18    # 0x12
uint16 TRAFFIC_LIGHT_YELLOW             = 34    # 0x22
uint16 TRAFFIC_LIGHT_GREEN              = 50    # 0x32
uint16 TRAFFIC_LIGHT_GREEN_LEFT_TURN    = 66    # 0x42
uint16 TRAFFIC_LIGHT_GREEN_RIGHT_TURN   = 66    # 0x42

# Confidence of the signal detection
float32 score

================================================================================
MSG: zzz_perception_msgs/BoundingBox2D
# A 2D bounding box that can be rotated about its center. All dimensions are in pixels, but represented using floating-point

# The position and orientation of the rigid body center
Pose2DWithCovariance pose

# The size (in meters) of the bounding box surrounding the object relative to the pose of its center.
Dimension2DWithCovariance dimension

================================================================================
MSG: zzz_perception_msgs/Pose2DWithCovariance

float64 x # or u in u-v plane
float64 y # or v in u-v plane
float64 theta

# Row-major representation of the 3x3 covariance matrix
# In order, the parameters are: (x, y, theta)
float64[9] covariance

================================================================================
MSG: zzz_perception_msgs/Dimension2DWithCovariance
# Describing the size object in 2D space (in pixels) with uncertainty

float64 length_x # width
float64 length_y # length

# Row-major representation of the 2x2 covariance matrix
# In order, the parameters are: (length_x, length_y)
float64[4] covariance
"""
  __slots__ = ['source_img','classes','signal','bbox','comments']
  _slot_types = ['sensor_msgs/Image','zzz_perception_msgs/ObjectClass[]','zzz_perception_msgs/ObjectSignals','zzz_perception_msgs/BoundingBox2D','string']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.

    The available fields are:
       source_img,classes,signal,bbox,comments

    :param args: complete set of field values, in .msg order
    :param kwds: use keyword arguments corresponding to message field names
    to set specific fields.
    """
    if args or kwds:
      super(DetectionBox2D, self).__init__(*args, **kwds)
      #message fields cannot be None, assign default values for those that are
      if self.source_img is None:
        self.source_img = sensor_msgs.msg.Image()
      if self.classes is None:
        self.classes = []
      if self.signal is None:
        self.signal = zzz_perception_msgs.msg.ObjectSignals()
      if self.bbox is None:
        self.bbox = zzz_perception_msgs.msg.BoundingBox2D()
      if self.comments is None:
        self.comments = ''
    else:
      self.source_img = sensor_msgs.msg.Image()
      self.classes = []
      self.signal = zzz_perception_msgs.msg.ObjectSignals()
      self.bbox = zzz_perception_msgs.msg.BoundingBox2D()
      self.comments = ''

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      _x = self
      buff.write(_get_struct_3I().pack(_x.source_img.header.seq, _x.source_img.header.stamp.secs, _x.source_img.header.stamp.nsecs))
      _x = self.source_img.header.frame_id
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_2I().pack(_x.source_img.height, _x.source_img.width))
      _x = self.source_img.encoding
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_BI().pack(_x.source_img.is_bigendian, _x.source_img.step))
      _x = self.source_img.data
      length = len(_x)
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(struct.pack('<I%sB'%length, length, *_x))
      else:
        buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.classes)
      buff.write(_struct_I.pack(length))
      for val1 in self.classes:
        _x = val1
        buff.write(_get_struct_If().pack(_x.classid, _x.score))
        _x = val1.comments
        length = len(_x)
        if python3 or type(_x) == unicode:
          _x = _x.encode('utf-8')
          length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_Hf3d().pack(_x.signal.flags, _x.signal.score, _x.bbox.pose.x, _x.bbox.pose.y, _x.bbox.pose.theta))
      buff.write(_get_struct_9d().pack(*self.bbox.pose.covariance))
      _x = self
      buff.write(_get_struct_2d().pack(_x.bbox.dimension.length_x, _x.bbox.dimension.length_y))
      buff.write(_get_struct_4d().pack(*self.bbox.dimension.covariance))
      _x = self.comments
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    :param str: byte array of serialized message, ``str``
    """
    try:
      if self.source_img is None:
        self.source_img = sensor_msgs.msg.Image()
      if self.classes is None:
        self.classes = None
      if self.signal is None:
        self.signal = zzz_perception_msgs.msg.ObjectSignals()
      if self.bbox is None:
        self.bbox = zzz_perception_msgs.msg.BoundingBox2D()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.source_img.header.seq, _x.source_img.header.stamp.secs, _x.source_img.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.source_img.header.frame_id = str[start:end].decode('utf-8')
      else:
        self.source_img.header.frame_id = str[start:end]
      _x = self
      start = end
      end += 8
      (_x.source_img.height, _x.source_img.width,) = _get_struct_2I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.source_img.encoding = str[start:end].decode('utf-8')
      else:
        self.source_img.encoding = str[start:end]
      _x = self
      start = end
      end += 5
      (_x.source_img.is_bigendian, _x.source_img.step,) = _get_struct_BI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      self.source_img.data = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.classes = []
      for i in range(0, length):
        val1 = zzz_perception_msgs.msg.ObjectClass()
        _x = val1
        start = end
        end += 8
        (_x.classid, _x.score,) = _get_struct_If().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        if python3:
          val1.comments = str[start:end].decode('utf-8')
        else:
          val1.comments = str[start:end]
        self.classes.append(val1)
      _x = self
      start = end
      end += 30
      (_x.signal.flags, _x.signal.score, _x.bbox.pose.x, _x.bbox.pose.y, _x.bbox.pose.theta,) = _get_struct_Hf3d().unpack(str[start:end])
      start = end
      end += 72
      self.bbox.pose.covariance = _get_struct_9d().unpack(str[start:end])
      _x = self
      start = end
      end += 16
      (_x.bbox.dimension.length_x, _x.bbox.dimension.length_y,) = _get_struct_2d().unpack(str[start:end])
      start = end
      end += 32
      self.bbox.dimension.covariance = _get_struct_4d().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.comments = str[start:end].decode('utf-8')
      else:
        self.comments = str[start:end]
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e) #most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    :param buff: buffer, ``StringIO``
    :param numpy: numpy python module
    """
    try:
      _x = self
      buff.write(_get_struct_3I().pack(_x.source_img.header.seq, _x.source_img.header.stamp.secs, _x.source_img.header.stamp.nsecs))
      _x = self.source_img.header.frame_id
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_2I().pack(_x.source_img.height, _x.source_img.width))
      _x = self.source_img.encoding
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_BI().pack(_x.source_img.is_bigendian, _x.source_img.step))
      _x = self.source_img.data
      length = len(_x)
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(struct.pack('<I%sB'%length, length, *_x))
      else:
        buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.classes)
      buff.write(_struct_I.pack(length))
      for val1 in self.classes:
        _x = val1
        buff.write(_get_struct_If().pack(_x.classid, _x.score))
        _x = val1.comments
        length = len(_x)
        if python3 or type(_x) == unicode:
          _x = _x.encode('utf-8')
          length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
      _x = self
      buff.write(_get_struct_Hf3d().pack(_x.signal.flags, _x.signal.score, _x.bbox.pose.x, _x.bbox.pose.y, _x.bbox.pose.theta))
      buff.write(self.bbox.pose.covariance.tostring())
      _x = self
      buff.write(_get_struct_2d().pack(_x.bbox.dimension.length_x, _x.bbox.dimension.length_y))
      buff.write(self.bbox.dimension.covariance.tostring())
      _x = self.comments
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    :param str: byte array of serialized message, ``str``
    :param numpy: numpy python module
    """
    try:
      if self.source_img is None:
        self.source_img = sensor_msgs.msg.Image()
      if self.classes is None:
        self.classes = None
      if self.signal is None:
        self.signal = zzz_perception_msgs.msg.ObjectSignals()
      if self.bbox is None:
        self.bbox = zzz_perception_msgs.msg.BoundingBox2D()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.source_img.header.seq, _x.source_img.header.stamp.secs, _x.source_img.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.source_img.header.frame_id = str[start:end].decode('utf-8')
      else:
        self.source_img.header.frame_id = str[start:end]
      _x = self
      start = end
      end += 8
      (_x.source_img.height, _x.source_img.width,) = _get_struct_2I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.source_img.encoding = str[start:end].decode('utf-8')
      else:
        self.source_img.encoding = str[start:end]
      _x = self
      start = end
      end += 5
      (_x.source_img.is_bigendian, _x.source_img.step,) = _get_struct_BI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      self.source_img.data = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.classes = []
      for i in range(0, length):
        val1 = zzz_perception_msgs.msg.ObjectClass()
        _x = val1
        start = end
        end += 8
        (_x.classid, _x.score,) = _get_struct_If().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        if python3:
          val1.comments = str[start:end].decode('utf-8')
        else:
          val1.comments = str[start:end]
        self.classes.append(val1)
      _x = self
      start = end
      end += 30
      (_x.signal.flags, _x.signal.score, _x.bbox.pose.x, _x.bbox.pose.y, _x.bbox.pose.theta,) = _get_struct_Hf3d().unpack(str[start:end])
      start = end
      end += 72
      self.bbox.pose.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=9)
      _x = self
      start = end
      end += 16
      (_x.bbox.dimension.length_x, _x.bbox.dimension.length_y,) = _get_struct_2d().unpack(str[start:end])
      start = end
      end += 32
      self.bbox.dimension.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=4)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.comments = str[start:end].decode('utf-8')
      else:
        self.comments = str[start:end]
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e) #most likely buffer underfill

_struct_I = genpy.struct_I
def _get_struct_I():
    global _struct_I
    return _struct_I
_struct_9d = None
def _get_struct_9d():
    global _struct_9d
    if _struct_9d is None:
        _struct_9d = struct.Struct("<9d")
    return _struct_9d
_struct_BI = None
def _get_struct_BI():
    global _struct_BI
    if _struct_BI is None:
        _struct_BI = struct.Struct("<BI")
    return _struct_BI
_struct_2d = None
def _get_struct_2d():
    global _struct_2d
    if _struct_2d is None:
        _struct_2d = struct.Struct("<2d")
    return _struct_2d
_struct_3I = None
def _get_struct_3I():
    global _struct_3I
    if _struct_3I is None:
        _struct_3I = struct.Struct("<3I")
    return _struct_3I
_struct_4d = None
def _get_struct_4d():
    global _struct_4d
    if _struct_4d is None:
        _struct_4d = struct.Struct("<4d")
    return _struct_4d
_struct_Hf3d = None
def _get_struct_Hf3d():
    global _struct_Hf3d
    if _struct_Hf3d is None:
        _struct_Hf3d = struct.Struct("<Hf3d")
    return _struct_Hf3d
_struct_2I = None
def _get_struct_2I():
    global _struct_2I
    if _struct_2I is None:
        _struct_2I = struct.Struct("<2I")
    return _struct_2I
_struct_If = None
def _get_struct_If():
    global _struct_If
    if _struct_If is None:
        _struct_If = struct.Struct("<If")
    return _struct_If
