title: Drawing Scaled grid system using openCV and python
body: <p>What I want to do is draw a grid on an image that has smaller squares at the top and larger ones near the bottom.  I am lost on how to do this though. I figured out how to draw a grid on the image using open cv but don't know how to fine turn it to get the results I want.</p>
  <p>What I will be using this for is to find where a bounding box point is for a detected object. I will need a smaller bounding box at the top and a larger one closer to the bottom of the image.</p>
  <p>This is what I want to do:
  <a href="https://i.stack.imgur.com/kX5Fb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kX5Fb.jpg" alt="enter image description here" /></a></p>
  <p>But I cannot figure out how to get the curves in the code.
  This is what I have so far:
  <a href="https://i.stack.imgur.com/WLtJv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WLtJv.png" alt="enter image description here" /></a></p>
  <p>And this the is code that I am using.</p>
  <pre><code>'''
  #This method draws simple grid overthe image based on the passed step
  #The pxstep controls the size of the grid
  '''
  def drawBasicGrid(image, pxstep, midX, midY):
      x = pxstep
      y = pxstep
      #Draw all x lines
      while x &lt; img.shape[1]:
          cv2.line(img, (x, 0), (x, img.shape[0]), color=(255, 0, 255), thickness=1)
          x += pxstep
      
      while y &lt; img.shape[0]:
          cv2.line(img, (0, y), (img.shape[1], y), color=(255, 0, 255),thickness=1)
          y += pxstep
      
  </code></pre>
  <p>This draws the basic grid.
  and this creates thebounding boxes that I use for detection of the bounding points of a detected object.</p>
  <pre><code>def makeBoundingBox(h,w, step):
      #BBox is 100*100 square or step which is defied
      y = 0
      bbox = []
      while y &lt; h:
          #print(&quot;Y value&quot;, y)
          x=0
          while x &lt; w:
              #print(&quot;X Value&quot;, x)
              bbox.append([(x,y), (x+step, y+step)])
              x += step
          y += step
      
      return bbox
  </code></pre>
  <p>And this is how I am using it.</p>
  <pre><code>#Prepare Images
  img = cv2.imread(image)
  #img = imutils.resize(img, width=300)
  #gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  (H,W) = img.shape[:2]
  #Create bounding boxes for the image
  '''
  #Creates the boxes for people detection 
  #It will look for which bounding boxes the person is in and then 
  #Draw a box around their feet
  '''
  #People Detection
  blob = cv2.dnn.blobFromImage(cv2.resize(img, (300, 300)),0.007843,(300, 300), 127.5)
  net.setInput(blob)
  detections = net.forward()
  '''
  #Get the center point of the image
  '''
  midY = H//2
  midX = W//2
  print(&quot;Middle Y pixel&quot;, midY)
  #Draw center line
  cv2.line(img, (0, midY), (W, midY), color=green, thickness=2)
  cv2.line(img, (midX, 0), (midX, H), color=green, thickness=2)
  
  #Visual grid drawn
  drawBasicGrid(img, step, midX,midY)
  bbox = makeBoundingBox(H, W, step) #Used for finding where the endx and startx BBOX  points are
  </code></pre>
  <p>Any help on this will be appreciated.</p>