I have developed two detectors based on deep learning (Faster R-CNN).
The first detector detects one image and returns the coordinates of bigger rectangles. For example:
rectangles1 = [[10, 10, 50, 50], [60, 10, 150, ,150], [180, 180, 250, 250], [180, 400, 450, 450], [...]] # xmin, ymin, xmax, ymax
The second detector detects one image, which is same as above, and returns smaller rectangle.
rectangles2 = [[10, 10, 30, 30], [60, 20, 150, 120], [160, 200, 270, 270], [200, 450, 425, 425], [...]] # xmin, ymin, xmax, ymax
If I plot these two (rectangles1, rectangles2), it can be shown like the picture below:
So, each coordinate of rectangle1 has only one corresponding coordinate of rectangle2.
But, the returned coordinates of rectangles are not in order. For example,
rectangle1 = [rectangle1[0], rectangle1[2], rectangle1[4], rectangle1[3], rectangle1[1], rectangle[…]]
rectangle2 = [rectangle2[1], rectangle2[3], rectangle2[2], rectangle2[0], rectangle1[4], rectangle[…]]
What I want is that each coordinate of rectangle1 and one corresponding coordinate of rectangle2 are returned together. For example:
final = [[rectangle1[0], rectangle2[0]], [rectangle1[1], rectangle2[1]], [rectangle1[2], rectangle2[2], rectangle1[…], rectangle2[…]]
How could I make this code? Could you please give me a hint? I have watched some code in stackoverflow but they can only receive two rectangles. Thank you.
For making an image, you can use the code below:
import numpy as np
import cv2
img = np.zeros((800, 800, 3), np.uint8)
img1 = cv2.rectangle(img, (10, 10), (50, 50), (255, 0, 0), 3)
img1 = cv2.rectangle(img, (60, 10), (150, 150), (255, 0, 0), 3)
img1 = cv2.rectangle(img, (180, 180), (250, 250), (255, 0, 0), 3)
img1 = cv2.rectangle(img, (180, 400), (450, 450), (255, 0, 0), 3)
img2 = cv2.rectangle(img, (10, 10), (30, 30), (0, 0, 255), 3)
img2 = cv2.rectangle(img, (60, 20), (150, 120), (0, 0, 255), 3)
img2 = cv2.rectangle(img, (160, 200), (270, 270), (0, 0, 255), 3)
img2 = cv2.rectangle(img, (200, 450), (425, 425), (0, 0, 255), 3)
cv2.imshow('rectangle', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thank you.