title: How to convert Yolo format bounding box coordinates into OpenCV format
body: <p>I have <code>Yolo</code> format bounding box annotations of objects saved in a <code>.txt</code> files. Now I want to load those coordinates and draw it on the image using <code>OpenCV</code>, but I don’t know how to convert those float values into <code>OpenCV</code> format coordinates values</p>
  <p>I tried this <a href="https://stackoverflow.com/questions/56115874/how-to-convert-bounding-box-x1-y1-x2-y2-to-yolo-style-x-y-w-h">post</a> but it didn’t help, below is a sample example of what I am trying to do</p>
  <p><strong>Code and output</strong></p>
  <pre><code>import matplotlib.pyplot as plt
  import cv2
  
  img = cv2.imread(&lt;image_path&gt;)
  dh, dw, _ = img.shape
          
  fl = open(&lt;label_path&gt;, 'r')
  data = fl.readlines()
  fl.close()
          
  for dt in data:
              
      _, x, y, w, h = dt.split(' ')
              
      nx = int(float(x)*dw)
      ny = int(float(y)*dh)
      nw = int(float(w)*dw)
      nh = int(float(h)*dh)
              
      cv2.rectangle(img, (nx,ny), (nx+nw,ny+nh), (0,0,255), 1)
              
  plt.imshow(img)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/rj0T7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rj0T7.png" alt="enter image description here" /></a></p>
  <p><strong>Actual Annotations and Image</strong></p>
  <pre><code>0 0.286972 0.647157 0.404930 0.371237 
  0 0.681338 0.366221 0.454225 0.418060
  </code></pre>
  <p><a href="https://i.stack.imgur.com/jT2Jo.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/jT2Jo.jpg" alt="enter image description here" /></a></p>