A very convenient solution to this would be probably to normalize the boxes in a similar way as to YOLO format. In such case, (x,y,w,h) should be processed so as to be relative to width and height of image. Speaking in code  :
# image is not resized yet
normalized_x = absolute_x / image.shape[0] 
normalized_y = absolute_y / image.shape[1]
normalized_width = absolute_width / image.shape[0]
normalized_height = absolute_height / image.shape[1]

Now, as long as you resize the image according to the initial aspect ratio, you will always have access to the proportional coordinates.
Not to mention that you should take care of what x and y represents in you annotation formats, as sometimes they tend to infer to the center whether the top_left corner of the bounding box.
You can also check:
  
      stackoverflow.com
  
  
      
    
  

  Resizing image and its bounding box 121



  python-3.x, numpy, opencv, math



  asked by
  
  
    jejjejd
  
  on 02:46PM - 24 Mar 18 UTC


  
  
    
    
  
  


  
      github.com/AlexeyAB/Yolo_mark
  
  
    
  
	  
  

  
    
      Specific format of annotation 15
    

    
      
        opened 
        
          
        
        Jul 2, 2018
      
      

        
          closed 
        
          
        
        Jul 11, 2018
      
        

      
        
          
          ycui123
        
      
    
  



  Could you please tell me the format of annotation? I generated my own dataset and I want to train it. I...



    Solved