title: How Can I Compare Detected Objects with Each Other
body: <p>I want to take my .json file with all of the objects that my object detection model detected and then see if any of them are within x pixels of each other, and then group them together to make decisions. I have tried just looping over the detected objects but I can't seem to compare them with each other individually. Any help would be appreaciated.</p>
  <p>Python Code:</p>
  <pre><code>input_file_path = 'C:\\Yolo_v4\\darknet\\build\\darknet\\x64\\result.json'
  input_file = open(input_file_path, 'r')
  
  results = json.load(input_file)
  
  for data in results:                        # Loops over processed images
      file_path = data['filename']
      print(&quot;Processing image: &quot; + file_path)
  
      objects = data['objects']
      for o in objects:                         # Loops over detected objects in image
          class_id = o['class_id']
          class_name = o['name']
          coords = o['relative_coordinates']
          xmid = coords['center_x']
          ymid = coords['center_y']
          width = coords['width']
          height = coords['height']
          confidence = o['confidence']
  </code></pre>
  <p>.Json File(Some of it)</p>
  <pre><code>[
  {
   &quot;frame_id&quot;:1, 
   &quot;filename&quot;:&quot;C:\\Yolo_v4\\darknet\\build\\darknet\\x64\\f003.png&quot;, 
   &quot;objects&quot;: [ 
    {&quot;class_id&quot;:41, &quot;name&quot;:&quot;z&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.082398, &quot;center_y&quot;:0.647144, &quot;width&quot;:0.135836, &quot;height&quot;:0.048884}, &quot;confidence&quot;:0.971427}, 
    {&quot;class_id&quot;:4, &quot;name&quot;:&quot;3&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.225985, &quot;center_y&quot;:0.466635, &quot;width&quot;:0.097890, &quot;height&quot;:0.050788}, &quot;confidence&quot;:0.925511}, 
    {&quot;class_id&quot;:5, &quot;name&quot;:&quot;4&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.226959, &quot;center_y&quot;:0.422191, &quot;width&quot;:0.093029, &quot;height&quot;:0.043420}, &quot;confidence&quot;:0.617335}, 
    {&quot;class_id&quot;:30, &quot;name&quot;:&quot;q&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.173545, &quot;center_y&quot;:0.115036, &quot;width&quot;:0.115037, &quot;height&quot;:0.058313}, &quot;confidence&quot;:0.992148}, 
    {&quot;class_id&quot;:9, &quot;name&quot;:&quot;8&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.252416, &quot;center_y&quot;:0.226164, &quot;width&quot;:0.092615, &quot;height&quot;:0.042916}, &quot;confidence&quot;:0.804773}, 
    {&quot;class_id&quot;:31, &quot;name&quot;:&quot;r&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.160054, &quot;center_y&quot;:0.168695, &quot;width&quot;:0.116981, &quot;height&quot;:0.035077}, &quot;confidence&quot;:0.536827}, 
    {&quot;class_id&quot;:8, &quot;name&quot;:&quot;7&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.232647, &quot;center_y&quot;:0.272744, &quot;width&quot;:0.142288, &quot;height&quot;:0.049401}, &quot;confidence&quot;:0.595207}, 
    {&quot;class_id&quot;:33, &quot;name&quot;:&quot;s&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.152255, &quot;center_y&quot;:0.222577, &quot;width&quot;:0.085914, &quot;height&quot;:0.043117}, &quot;confidence&quot;:0.595850}, 
    {&quot;class_id&quot;:7, &quot;name&quot;:&quot;6&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.235020, &quot;center_y&quot;:0.323665, &quot;width&quot;:0.117890, &quot;height&quot;:0.042035}, &quot;confidence&quot;:0.877499}, 
    {&quot;class_id&quot;:34, &quot;name&quot;:&quot;t&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.140156, &quot;center_y&quot;:0.264790, &quot;width&quot;:0.080172, &quot;height&quot;:0.040785}, &quot;confidence&quot;:0.813210}, 
    {&quot;class_id&quot;:6, &quot;name&quot;:&quot;5&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.226594, &quot;center_y&quot;:0.370981, &quot;width&quot;:0.146503, &quot;height&quot;:0.047302}, &quot;confidence&quot;:0.985635}, 
    {&quot;class_id&quot;:35, &quot;name&quot;:&quot;u&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.129700, &quot;center_y&quot;:0.317942, &quot;width&quot;:0.098264, &quot;height&quot;:0.050219}, &quot;confidence&quot;:0.714703}, 
    {&quot;class_id&quot;:5, &quot;name&quot;:&quot;4&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.225035, &quot;center_y&quot;:0.465708, &quot;width&quot;:0.122361, &quot;height&quot;:0.039988}, &quot;confidence&quot;:0.682546}, 
    {&quot;class_id&quot;:3, &quot;name&quot;:&quot;2&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.224760, &quot;center_y&quot;:0.517733, &quot;width&quot;:0.136648, &quot;height&quot;:0.049830}, &quot;confidence&quot;:0.993929}, 
    {&quot;class_id&quot;:37, &quot;name&quot;:&quot;w&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.102568, &quot;center_y&quot;:0.442717, &quot;width&quot;:0.129250, &quot;height&quot;:0.070414}, &quot;confidence&quot;:0.968482}, 
    {&quot;class_id&quot;:2, &quot;name&quot;:&quot;1&quot;, &quot;relative_coordinates&quot;:{&quot;center_x&quot;:0.229039, &quot;center_y&quot;:0.612601, &quot;width&quot;:0.126908, &quot;height&quot;:0.026894}, &quot;confidence&quot;:0.967374}, 
   ] 
  }
  ]
  </code></pre>