Reputation: 767
I would like to draw a 2d box around a 3d object and at the end, it should look like the following image:
I have already drawn a 3d Box and determined the corners (red balls) as well, but however I don't know what to do next or which steps should be taken next.
It would be a pleasure if someone could provide an algorithm or the next couple of steps to carry on working on it.
Thanks in advance :)
Upvotes: 1
Views: 4954
Reputation: 6618
Suppose you have 8 coordinates for both x
and y
x=[123,455,544,677,345,333,677,322]
y=[734,543,654,234,132,654,321,123]
and assuming these 2 lists to be the x-y coordinates for a 3D box, then its 2D box can be found by this code:
x_min=min(x)
y_min=min(y)
x_max=max(x)
y_max=max(y)
And if you do something like this
cv2.rectangle(image,(x_min,y_min),(x_max,y_max),(255,0,0),1)
then you will get the result.
Upvotes: 2