'Add a grid inside bounding boxes in an image

I have an image with bounding boxes surrounding cones, and I need to put a grid inside each box. How do I extract the bounding box from the image?

Example of the expected result

I can design the grid already inside the entire image.



Solution 1:[1]

First find the color of the bounding boxes. I used the chrome add-on ColorPick eyedropper to extract the RGB colors.

eyedropper result

RGB = (54, 243, 244)

Than extract the Blue channel which has the most prominent values.

image_b = image_rgb[:,:,-1] 

If the image is in the opencv BGR channel order do

image_b = image_rgb[:,:,0] 

Threshold the blue channel to get a binary image with just the bounding boxes.

cv2.threshold(image_b, 200, 255, cv2.THRESH_BINARY)

Then find contours of boxes:

cnts = cv2.findContours(gray_image, cv2.RETR_LIST , cv2.CHAIN_APPROX_NONE)

The next step would be to find the bounding box of the contours.

for cnt in cnts:
    x, y, w, h= cv2.boundingRect(cnt[0])

Solution 2:[2]

You may check your project's Fitness API current limit of in the Google Developer Console. As I've checked my current project, the default limits are:

  • 86,400 Queries per day
  • 500 Queries per 100 seconds per user
  • 1,000 Queries per 100 seconds

Daily quotas reset at midnight Pacific Time (PT). You can request more quota limits or view quotas for your other services on the Quotas page, found in IAM & admin.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 abielita