OrientedBoxes2D¶
Oriented Boxes 2D is defined by [x, y, w, h, theta] in which:
x, y: center coordinates (could be relative or absolute values)
w, h: width, height (could be relative or absolute values)
theta: rotation angle
Basic usage¶
import numpy as np
import torch
from aloscene import OrientedBoxes2D
boxes = OrientedBoxes2D(
torch.tensor(
[
# [x, y, w, h, theta]
[0.5, 0.5, 0.2, 0.2, 0],
[0.1, 0.1, 0.2, 0.3, np.pi / 6],
[0.1, 0.8, 0.1, 0.3, -np.pi / 3],
[0.6, 0.3, 0.4, 0.2, np.pi / 4],
],
device=torch.device("cuda"),
),
absolute=False, # use relative values for x, y, w, h
)
boxes.get_view().render()
Get coordinates of 4 corners for each boxes:
print(boxes.corners())
Convert to absolute value format with frame size = (300, 300):
abs_boxes = boxes.abs_boxes((300, 300))
print(abs_boxes)
print(abs_boxes.absolute) # True
print(abs_boxes.rel_pos() == boxes) # True
Calucate oriented IoU/GIoU with another set of boxes:
boxes2 = OrientedBoxes2D(
torch.tensor(
[
[1, 1, 2, 2, 0],
[5, 5, 2, 3, np.pi / 6],
[1, 1, 1, 3, -np.pi / 3],
[3, 1, 4, 2, np.pi / 4]
],
device=torch.device("cuda")
)
)
iou = boxes.rotated_iou_with(boxes2)
giou = boxes.rotated_giou_with(boxes2)
print(iou)
print(giou)
API¶
- class aloscene.oriented_boxes_2d.OrientedBoxes2D(x, absolute=True, frame_size=None, labels: Optional[Union[dict, aloscene.labels.Labels]] = None, names=('N', None), *args, **kwargs)¶
Bases:
aloscene.tensors.augmented_tensor.AugmentedTensor
Oriented Boxes 2D is defined by [x, y, w, h, theta] in which: - x, y: center coordinates - w, h: width, height - theta: rotation angle
- GLOBAL_COLOR_SET = array([[1.10596702e-01, 5.97482060e-01, 8.46929039e-01], [2.65147551e-01, 8.21200398e-01, 7.68743685e-01], [9.28976645e-01, 5.42528038e-02, 3.01085460e-01], [2.71457265e-01, 1.73210450e-02, 3.36280255e-01], [5.67186664e-01, 3.13842775e-01, 3.49128421e-01], [4.49940534e-01, 1.89341429e-01, 9.97622434e-01], [5.26236267e-01, 4.64894611e-01, 5.04227657e-01], [6.46008537e-01, 9.32366280e-01, 4.46315707e-01], [7.71382250e-01, 9.72007854e-01, 2.99214877e-01], [7.85120679e-01, 9.71791272e-01, 7.91838632e-01], [7.77441592e-01, 9.56892042e-02, 8.80824122e-01], [6.16145634e-01, 1.88997795e-01, 4.68811191e-01], [7.12538061e-01, 8.10948697e-01, 8.43023087e-01], [7.95397235e-01, 6.61506634e-01, 8.66735310e-01], [3.18192625e-01, 9.37436600e-01, 8.75667244e-01], [5.17488391e-01, 1.92764504e-01, 3.37174634e-01], [4.33465786e-01, 6.35205932e-01, 6.47603517e-01], [3.81639375e-01, 4.49172560e-01, 8.11874017e-01], [7.30263620e-01, 9.45876408e-01, 8.73981643e-01], [4.64870111e-01, 3.17260859e-01, 2.01773214e-01], [1.43075657e-01, 1.18753064e-01, 6.97456217e-01], [2.77486195e-01, 6.03053516e-01, 6.21874327e-01], [2.87143027e-01, 4.80799150e-01, 4.79909151e-01], [1.64701496e-01, 6.12349890e-01, 7.02754232e-01], [2.14319587e-01, 3.37432704e-01, 3.64662324e-01], [1.76610047e-01, 1.37340015e-01, 6.20979209e-01], [5.94207973e-02, 3.82255091e-01, 7.66543838e-01], [3.58765499e-01, 4.06581083e-01, 8.02071244e-01], [6.35584003e-01, 3.43492379e-01, 4.61617961e-01], [8.24157363e-01, 1.33192793e-01, 3.20873807e-01], [2.25226439e-01, 5.02320372e-01, 2.34068612e-02], [2.80249115e-01, 7.62584241e-01, 4.17322725e-01], [3.20973016e-01, 4.98685712e-01, 7.86326450e-01], [1.35719585e-01, 8.35636532e-01, 2.14461673e-01], [9.45811637e-01, 8.34949801e-01, 9.30273065e-01], [4.09149733e-01, 2.99253306e-01, 7.75011383e-01], [6.99061946e-01, 2.93970080e-01, 2.91348126e-01], [3.31877959e-01, 2.84682345e-01, 9.36569415e-01], [6.94024553e-01, 7.67761680e-01, 3.90666433e-01], [3.33112482e-03, 6.93923941e-01, 3.98117998e-01], [5.81749518e-01, 3.67700563e-01, 6.34473480e-01], [4.07924467e-01, 8.59970786e-01, 5.10633622e-01], [3.05301257e-01, 3.91299428e-01, 1.45196455e-01], [9.80164268e-01, 5.15570085e-01, 5.97964669e-01], [6.60351173e-01, 7.42895935e-01, 1.06757526e-01], [4.13351250e-01, 8.54782298e-01, 2.79270662e-01], [8.60788182e-01, 4.11412094e-01, 5.55350342e-01], [5.54862369e-01, 6.22413266e-01, 4.01826448e-01], [4.84538982e-01, 4.49621867e-01, 6.69479280e-01], [2.12544761e-01, 7.01064562e-01, 1.15448396e-01], [2.72939716e-01, 7.13832005e-01, 8.36553374e-03], [2.92827347e-01, 7.53860176e-01, 3.27835129e-01], [5.64166583e-02, 8.24447882e-01, 2.26956763e-01], [8.75753328e-01, 5.46897770e-01, 8.75019079e-01], [9.60250229e-01, 5.94014943e-01, 4.41889615e-01], [8.75101960e-01, 5.82237027e-01, 5.27724104e-01], [7.28959047e-02, 5.15179000e-01, 6.65088251e-01], [4.80484864e-01, 5.89141990e-01, 7.98352541e-02], [5.01117099e-01, 3.97909964e-01, 7.58061958e-01], [6.62728852e-01, 2.56211088e-01, 2.59544810e-01], [4.93404331e-01, 7.69090609e-01, 9.80548756e-01], [3.22140182e-01, 9.69284451e-01, 1.78455093e-01], [7.47907059e-01, 1.51396928e-01, 4.14109694e-01], [7.45654602e-01, 9.94134256e-01, 4.64131004e-01], [2.48213761e-01, 2.70103464e-02, 9.70163010e-01], [5.65483130e-01, 5.56565124e-01, 9.31857782e-01], [6.25394419e-01, 1.22349080e-01, 8.68236094e-01], [6.24974845e-01, 8.23332853e-01, 1.55966798e-02], [3.35117482e-01, 5.97864437e-01, 3.09652805e-01], [6.59014283e-01, 7.95102486e-01, 6.49314570e-01], [2.72187218e-01, 2.01447680e-02, 3.60247861e-01], [1.08308663e-01, 2.58376747e-01, 3.77751604e-01], [9.30190983e-01, 9.04425869e-02, 4.39137950e-01], [2.30646462e-02, 8.20574823e-01, 8.77407023e-01], [6.18546802e-01, 1.71499615e-01, 9.98630104e-01], [7.30773518e-01, 9.84896261e-01, 8.18945779e-01], [5.19628180e-01, 7.29159375e-01, 4.29738768e-01], [3.09036772e-01, 2.15872935e-01, 2.62281202e-01], [4.16817471e-01, 9.89689550e-01, 4.55398361e-02], [3.74192287e-01, 2.86865287e-01, 7.92058403e-01], [9.33531934e-01, 5.79853955e-01, 1.76019975e-01], [5.82357466e-01, 1.81066590e-01, 5.81346552e-01], [6.35765215e-02, 7.95853576e-02, 4.38933458e-01], [1.42312343e-01, 7.54574824e-01, 1.78862323e-01], [4.72028956e-02, 5.68479265e-01, 7.15981518e-01], [8.38698314e-01, 6.92927763e-01, 4.32369469e-02], [3.05273729e-01, 5.82402189e-01, 2.91010232e-01], [7.05756191e-01, 7.73657264e-01, 5.89449456e-02], [8.11509175e-01, 8.34515366e-02, 1.37727856e-01], [8.51292242e-01, 9.45065270e-01, 9.23045578e-02], [6.78869568e-01, 9.87310275e-01, 6.75140731e-01], [3.50085920e-01, 2.18610614e-01, 4.43194812e-01], [9.64600468e-02, 2.67483792e-01, 8.42297352e-01], [7.64421797e-01, 4.75873084e-01, 8.99540086e-01], [5.62143484e-01, 2.04761873e-01, 6.91144374e-01], [5.79162661e-01, 1.41831862e-01, 7.60049439e-01], [3.13658118e-01, 1.06963077e-01, 1.68516922e-01], [5.30647157e-01, 1.70738131e-01, 7.95687222e-01], [1.63692683e-01, 7.64911196e-01, 8.51831804e-01], [1.06026421e-01, 9.52757911e-02, 2.08448056e-02], [4.20330610e-01, 8.40034328e-01, 5.37835736e-01], [2.11300245e-01, 9.88070478e-01, 6.04551275e-01], [7.89874894e-01, 5.13596292e-01, 5.37103539e-01], [7.34146171e-01, 3.02181674e-01, 5.56527501e-01], [8.72271830e-01, 8.49555979e-01, 6.48886058e-01], [1.58785518e-01, 9.05667166e-01, 7.57429174e-01], [9.44939437e-01, 4.70273302e-03, 1.15730277e-01], [4.59758080e-01, 7.00070727e-01, 1.01078656e-01], [4.79491716e-01, 2.77914277e-01, 6.22662459e-01], [6.24813112e-01, 8.22959938e-01, 7.94254100e-01], [9.68046141e-01, 2.86393952e-01, 6.74953936e-01], [8.67567753e-01, 8.00671225e-01, 1.16391443e-01], [4.92103441e-01, 9.67975352e-01, 6.58234590e-01], [8.00265454e-01, 5.64385619e-01, 1.65766207e-04], [6.47917999e-01, 8.03496304e-01, 3.73304404e-01], [1.43636328e-02, 1.79792720e-01, 6.86893799e-01], [8.67653709e-01, 8.56414250e-01, 7.24537933e-01], [2.16421821e-01, 9.83987536e-01, 6.02524928e-02], [1.70921545e-01, 4.45766837e-01, 8.58853357e-01], [2.65098195e-01, 7.32635855e-01, 2.70002547e-01], [9.01715315e-01, 4.17392880e-01, 6.96715933e-01], [8.24232008e-02, 8.53359910e-01, 1.77629993e-01], [5.32080311e-02, 1.10021417e-01, 9.48989136e-02], [9.84845043e-01, 8.03257652e-02, 1.52768676e-01], [3.56884720e-01, 1.95958340e-01, 9.71677147e-01], [5.96790655e-02, 3.53208562e-01, 1.12764148e-01], [1.96186448e-01, 2.44783429e-01, 9.95431976e-01], [7.39148222e-01, 2.35093884e-01, 5.42271943e-01], [7.04680798e-01, 5.31229004e-01, 1.25488366e-01], [9.12997630e-01, 2.73100681e-01, 7.54466717e-01], [9.70087830e-01, 8.86501833e-01, 3.51860355e-01], [7.47594311e-01, 5.78637232e-01, 5.64359957e-01], [4.89365069e-01, 4.76323899e-01, 9.84010504e-02], [8.63707289e-01, 1.15350205e-01, 3.66270462e-01], [1.95883835e-01, 6.94554753e-01, 3.22549850e-01], [6.56978680e-01, 1.45633296e-01, 8.03540064e-01], [9.57303626e-01, 3.13108735e-01, 9.81666755e-01], [9.56051858e-01, 7.56010235e-02, 8.30311304e-01], [1.69224194e-01, 8.76487271e-01, 3.52855277e-01], [7.02099545e-01, 7.57217245e-01, 1.25555607e-01], [7.55354685e-01, 9.92941282e-01, 8.14851037e-02], [2.93014832e-01, 3.84296254e-01, 4.55427503e-01], [7.84388865e-01, 9.17055869e-01, 2.21552847e-01], [1.52747529e-01, 3.59178390e-01, 8.03600335e-01], [5.44732274e-01, 2.95142190e-01, 1.22852834e-01], [1.79143252e-02, 4.15333085e-01, 8.25138723e-01], [1.16156656e-01, 9.83872906e-01, 1.24551036e-01], [3.78091111e-01, 2.78424306e-01, 4.32289133e-01], [1.98457295e-01, 8.31183136e-01, 5.65152192e-01], [5.54110357e-01, 2.97039598e-01, 9.29264704e-01], [2.84749912e-01, 4.74146505e-01, 7.87583674e-01], [5.19818748e-02, 1.44641618e-01, 8.77801385e-01], [5.69515134e-01, 3.21621182e-01, 1.10611510e-01], [2.63399274e-01, 1.13632814e-01, 6.36445537e-01], [4.89131362e-02, 1.55939103e-01, 4.05920354e-01], [4.38256748e-01, 8.56469828e-02, 2.82508046e-01], [4.66971043e-01, 6.91784979e-01, 6.26990011e-02], [7.16018163e-01, 8.32575747e-01, 1.71659425e-01], [4.33678078e-01, 5.44688566e-01, 3.64427192e-01], [2.68732776e-01, 8.61079053e-01, 8.09801983e-01], [5.20627365e-01, 6.71052133e-01, 3.15566470e-01], [5.52902272e-01, 5.32861072e-01, 9.46315548e-01], [7.57948552e-01, 6.86956994e-02, 9.59462401e-01], [7.11817739e-01, 9.54008178e-01, 1.13323163e-01], [5.67928400e-01, 8.70313620e-03, 9.24663319e-01], [8.79979004e-01, 2.83101718e-02, 5.61433931e-02], [1.05185719e-01, 6.71259938e-01, 1.50632170e-01], [5.09124164e-01, 7.55293852e-01, 3.79839197e-01], [5.81817431e-01, 6.34189645e-01, 2.43444735e-01], [8.71434822e-01, 8.86865847e-01, 5.28774609e-01], [7.59054548e-01, 6.95150689e-01, 1.96349881e-01], [1.23990757e-01, 1.35038607e-01, 2.93814590e-01], [6.28435191e-01, 6.80945642e-01, 3.89885559e-01], [5.11133025e-01, 2.34916476e-01, 8.44551811e-01], [4.99098426e-02, 3.96248508e-01, 7.01389831e-01], [9.97223866e-01, 8.43538160e-02, 7.13334349e-01], [8.90623152e-01, 1.88881648e-01, 8.30764343e-01], [2.74985858e-01, 4.31076889e-01, 9.78372089e-01], [9.14911471e-01, 5.98771755e-01, 5.49713774e-01], [2.50006558e-01, 2.63906017e-01, 4.33455423e-01], [3.41820729e-01, 9.12021770e-01, 1.32596057e-01], [2.80379387e-01, 4.27495814e-01, 1.10292364e-01], [9.82470218e-01, 5.90246467e-01, 6.77826693e-02], [6.94516350e-01, 7.89374835e-01, 7.51800828e-01], [2.04947969e-01, 2.67483186e-01, 8.61587099e-01], [1.78463067e-02, 8.52606388e-01, 6.74958449e-01], [4.20592140e-01, 3.93950878e-01, 4.60212139e-01], [7.71614282e-01, 2.41786611e-01, 3.47057405e-01], [6.48030262e-01, 3.52658803e-01, 1.60041588e-01], [4.02542744e-01, 8.86814944e-01, 1.49378200e-01], [8.61773856e-01, 2.03398554e-01, 5.70718343e-01], [2.23904364e-01, 6.99413904e-01, 5.35962038e-02], [9.02609146e-01, 4.27192841e-01, 3.85366584e-01], [4.24997086e-02, 1.13952673e-02, 1.61495355e-01], [7.68971811e-01, 4.66659251e-01, 8.28471761e-01], [2.87415176e-01, 2.30243579e-01, 2.04717023e-01], [4.44810261e-01, 1.62588816e-01, 8.46745001e-01], [4.00051602e-01, 3.02925814e-01, 2.43570700e-01], [2.44081660e-01, 4.78037319e-02, 8.49325455e-01], [2.09057900e-01, 7.49808423e-01, 8.21516043e-01], [9.53381805e-01, 2.53742844e-01, 6.59196241e-01], [2.94652585e-01, 3.19934985e-01, 3.21884820e-01], [8.23298118e-01, 8.11572169e-01, 5.23647925e-01], [1.80576126e-01, 7.85211241e-01, 1.06850095e-01], [3.32765525e-02, 3.92519624e-01, 2.47869084e-01], [7.53979624e-01, 5.28001460e-01, 7.35703430e-01], [7.60587540e-02, 2.64142216e-01, 6.39638784e-01], [7.92020874e-01, 8.35368218e-02, 8.38228521e-01], [4.50727936e-01, 8.55437307e-01, 8.34645829e-01], [4.73661135e-01, 8.03750293e-01, 7.54319462e-01], [3.56804765e-01, 5.16490777e-01, 5.48081258e-01], [5.84146473e-01, 6.34930565e-01, 4.88978771e-01], [3.99775088e-02, 9.06857690e-02, 3.84463618e-01], [6.29956402e-01, 1.88357981e-01, 7.63736254e-01], [4.36199434e-01, 3.83815209e-01, 9.98802021e-01], [2.76438300e-01, 6.50199273e-01, 3.63510266e-01], [8.36231448e-01, 9.52569220e-01, 9.04167677e-01], [5.23381958e-01, 1.70582914e-01, 4.85921243e-01], [9.49187534e-02, 5.32321250e-01, 3.04303905e-01], [1.62679464e-01, 1.27760922e-03, 5.39600003e-01], [8.66723721e-01, 1.72226359e-01, 7.39763363e-01], [5.36827042e-01, 5.43141384e-01, 3.46606147e-01], [9.24025177e-01, 1.18590377e-01, 5.73455615e-01], [7.22236057e-01, 7.09254644e-01, 4.58339510e-01], [7.59693846e-01, 8.11124226e-01, 4.72679423e-01], [9.84866116e-02, 8.14345273e-01, 5.02148027e-01], [8.07880044e-01, 6.55362918e-01, 6.54334671e-01], [5.67499068e-01, 2.79448105e-01, 9.71267741e-01], [7.17129627e-01, 5.79035263e-01, 6.96495936e-01], [8.78496098e-01, 2.98677499e-02, 1.48834808e-01], [9.62787151e-01, 7.70008731e-01, 1.64915846e-01], [9.18845964e-01, 3.63423042e-01, 8.04809226e-01], [6.15506293e-02, 3.69879433e-01, 8.48147176e-01], [6.68211478e-02, 1.81130519e-01, 4.42735322e-01], [7.54512593e-02, 7.38471419e-01, 4.79300919e-01], [7.23621722e-01, 7.44630692e-01, 8.51248612e-01], [2.40962720e-01, 2.66960705e-01, 6.18296965e-01], [3.78129718e-01, 5.55054480e-01, 3.32966981e-01], [7.85671024e-01, 4.07361911e-01, 6.82143918e-01], [9.62274267e-01, 5.66905130e-01, 4.32449319e-01], [7.19658102e-01, 7.89524910e-01, 1.82621410e-01], [5.00416320e-02, 8.18129853e-01, 4.84268810e-01], [4.61564484e-01, 3.51674214e-01, 9.83329206e-01], [5.45021435e-01, 6.94653947e-01, 9.16887195e-01], [9.90313894e-01, 5.94535338e-01, 5.83708934e-01], [6.60610769e-01, 7.66659612e-02, 7.17301763e-01], [6.50293453e-01, 7.57129571e-01, 8.16431226e-01], [1.95393683e-01, 5.12169042e-01, 8.04463429e-01], [7.82177723e-01, 9.46232387e-01, 9.61665926e-01], [4.68928579e-01, 8.58316872e-01, 3.39674161e-01], [1.34851278e-01, 2.56746286e-01, 9.49219411e-01], [6.83109898e-01, 5.32284414e-01, 6.39329815e-01], [3.67527258e-01, 6.54686235e-02, 3.39778635e-01], [8.57783664e-01, 2.26016131e-01, 7.60356952e-01], [4.53631860e-01, 9.97327524e-01, 9.05957368e-01], [9.18762107e-01, 5.18372489e-01, 2.77773580e-01], [8.06210334e-01, 3.91256492e-01, 7.08912699e-01], [3.31930795e-01, 1.78593137e-01, 2.99808706e-01], [1.49493830e-01, 3.61922468e-01, 8.85841072e-01], [8.98065324e-01, 9.24458203e-01, 2.70430650e-01], [1.16886530e-01, 3.79241608e-01, 3.21935562e-01], [5.38641228e-02, 8.33592468e-01, 6.59308577e-02], [8.35338970e-01, 5.96526082e-01, 2.52993649e-04], [6.95774269e-01, 2.35281259e-01, 3.46674042e-01], [9.36276863e-01, 7.00565671e-01, 4.53381575e-01], [6.07346811e-01, 5.33760713e-01, 9.67376126e-01], [9.67979530e-01, 4.02216669e-01, 4.02224198e-01], [7.26040759e-01, 2.52071569e-01, 4.48244354e-01], [6.08317980e-01, 3.31839992e-01, 8.63503936e-01], [1.84090080e-01, 7.44807442e-01, 2.86584065e-01], [2.37594808e-01, 6.47700368e-01, 4.04771734e-01], [5.74129347e-01, 3.05776466e-01, 2.46385916e-01], [7.17480377e-01, 7.25432243e-01, 5.95174015e-01], [8.62633722e-02, 8.44734519e-01, 9.44270017e-01], [3.31128677e-01, 4.37155793e-01, 1.73226457e-01], [3.77586006e-01, 5.36022002e-01, 2.88630857e-01], [2.68507392e-01, 6.76006581e-01, 1.43597600e-01], [3.11347827e-01, 8.42730215e-01, 6.41241494e-01], [9.14770915e-01, 2.23998607e-01, 6.86460032e-01], [8.97425823e-01, 8.23983146e-02, 3.19879779e-01], [9.36165975e-01, 8.31939487e-01, 2.92270963e-01], [2.83091248e-01, 6.73568654e-01, 4.10671862e-01], [2.39018344e-01, 4.01023613e-01, 3.19900324e-01], [7.91153068e-01, 1.95763808e-01, 3.88372827e-01], [9.25409470e-01, 8.25493990e-01, 3.48153055e-01], [9.66285481e-02, 2.12716393e-01, 1.39590570e-01], [6.91977332e-01, 5.63913892e-02, 9.43413371e-01], [4.06702779e-01, 5.48954334e-01, 7.04376091e-01], [3.49626810e-01, 7.20816324e-01, 1.50888647e-01], [8.86910936e-01, 2.46064335e-01, 1.38175275e-01], [3.96657595e-01, 4.09910303e-01, 4.42288814e-01], [5.85393316e-01, 9.50882574e-01, 7.35621356e-02], [9.87451562e-01, 1.13168020e-01, 1.11863718e-01], [4.07561498e-01, 8.90004727e-01, 4.88915652e-01], [7.04852029e-01, 1.93820383e-01, 9.99377370e-01], [1.11456517e-01, 2.15752975e-01, 9.51955247e-01], [7.85620672e-01, 4.28136816e-01, 5.17386789e-01], [1.07209305e-01, 9.68000022e-01, 6.05314606e-01], [6.88312613e-01, 5.41128808e-01, 5.91632384e-01], [7.48855822e-01, 7.23674810e-02, 6.61237738e-01]])¶
- abs_pos(frame_size)¶
Get a new OrientedBoxes2D Tensor with absolute position relative to the given frame_size (H, W)
- Parameters
- frame_sizetuple
(Height, Width)
- Returns
- OrientedBoxes2D
boxes in absolute coordinates
- rtype
- append_labels(labels, name=None)¶
Attach a set of labels to the boxes.
- Parameters
- labelsaloscene.Labels
Set of labels to attached to the frame
- namestr
If none, the label will be attached without name (if possible). Otherwise if no other unnamed labels are attached to the frame, the labels will be added to the set of labels.
- static boxes2abspos(tensor, frame_size)¶
Get a new OrientedBoxes2D Tensor with absolute position relative to the given frame_size (H, W)
- Parameters
- tensor: OrientedBoxes2D
- frame_sizetuple
(Height, Width)
- Returns
- OrientedBoxes2D
boxes in absolute coordinates
- rtype
- static boxes2relpos(tensor)¶
Get a new OrientedBoxes2D Tensor with relative position (between 0 and 1)
- Parameters
- tensorOrientedBoxes2D
- Returns
- OrientedBoxes2D
- corners()¶
Get corners in x, y coordinates
Corners are in counter-clockwise order, started from the top right corner
- Returns
- torch.Tensor
shape (n, 4, 2) for n boxes, 4 vertices, 2 x-y coordinates
- rtype
Tensor
..
- get_view(frame=None, size=None, color=None, labels_set=None, **kwargs)¶
Create a view of the boxes in a frame
- Parameters
- framealoscene.Frame
Tensor of type Frame to display the boxes on. If the frame is None, a blank frame will be created.
- size(tuple)
(height, width) Desired size of the view. None by default
- colortuple
(R, G, B). None by default, a random color will be choosen.
- labels_setstr
If provided, the boxes will rely on this label set to display the boxes color, and color parameter will be ignore. If not provided while the boxes have multiple labels set, the boxes will be display with the same color which can be set with color param.
- rel_pos()¶
Get a new OrientedBoxes2D Tensor with relative position (between 0 and 1)
- Returns
- OrientedBoxes2D
- static rotated_giou(boxes1, boxes2, enclosing_type='smallest', ret_iou=False)¶
Calculate GIoU for 2 sets of rotated boxes in order
- Parameters
- boxes1BoundingBoxes3D
Shape (n, 7)
- boxes2BoundingBoxes3D
Shape (n, 7)
- enclosing_typestr, optional
- Choose the algorithm for finding enclosing box :
aligned # simple and naive. bad performance. fastest
pca # approximated smallest box. slightly worse performance.
smallest # [default]. brute force. smallest box. best performance. slowest
- ret_ioubool, optional
If True, return also rotated IoU , by default False
- Returns
- Tensor or tuple of (Tensor, Tensor)
GIoU, of shape (n,)
IoU, of shape (n,) (if ret_iou3d True)
- rotated_giou_with(boxes2, enclosing_type='smallest', ret_iou=False)¶
Calculate GIoU for 2 sets of rotated boxes in order
- Parameters
- boxes2BoundingBoxes3D
Shape (n, 7)
- enclosing_typestr, optional
- Choose the algorithm for finding enclosing box :
aligned # simple and naive. bad performance. fastest
pca # approximated smallest box. slightly worse performance.
smallest # [default]. brute force. smallest box. best performance. slowest
- ret_ioubool, optional
If True, return also rotated IoU , by default False
- Returns
- Tensor or tuple of (Tensor, Tensor)
GIoU, of shape (n,)
IoU, of shape (n,) (if ret_iou3d True)
- static rotated_iou(boxes1, boxes2, ret_union=False)¶
Compute the IOU between the two set of rotated boxes in order
- Parameters
- boxes1: aloscene.OrientedBoxes2D
(n, 5)
- boxes2: aloscene.OrientedBoxes2D
(n, 5)
- ret_unionbool, optional
If True, return union area, by default False
- Returns
- Tensor or tuple of (Tensor, Tensor)
IoU, shape (n,), rotated IOU between each pair of boxes
Union area, shape (n,), union area between each pair of boxes (if ret_union True)
- rotated_iou_with(boxes2, ret_union=False)¶
Compute the IOU between the two set of rotated boxes in order
- Parameters
- boxes2: aloscene.OrientedBoxes2D
(n, 5)
- ret_unionbool, optional
If True, return union area, by default False
- Returns
- Tensor or tuple of (Tensor, Tensor)
IoU, shape (n,), rotated IOU between each pair of boxes
Union area, shape (n,), union area between each pair of boxes (if ret_union True)