MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / convert_x_to_bbox

Method convert_x_to_bbox

deeplabcut/core/trackingutils.py:360–368  ·  view source on GitHub ↗

Takes a bounding box in the centre form [x,y,s,r] and returns it in the form [x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right.

(x, score=None)

Source from the content-addressed store, hash-verified

358
359 @staticmethod
360 def convert_x_to_bbox(x, score=None):
361 """Takes a bounding box in the centre form [x,y,s,r] and returns it in the form
362 [x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right."""
363 w = np.sqrt(x[2] * x[3])
364 h = x[2] / w
365 if score is None:
366 return np.array([x[0] - w / 2.0, x[1] - h / 2.0, x[0] + w / 2.0, x[1] + h / 2.0]).reshape((1, 4))
367 else:
368 return np.array([x[0] - w / 2.0, x[1] - h / 2.0, x[0] + w / 2.0, x[1] + h / 2.0, score]).reshape((1, 5))
369
370 @staticmethod
371 def convert_bbox_to_z(bbox):

Callers 1

stateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected