2021-07-07 17:46:11 +02:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
2021-08-25 18:29:10 +02:00
|
|
|
from .policy import SingleViewPolicy
|
|
|
|
from vgn.utils import look_at
|
2021-07-07 17:46:11 +02:00
|
|
|
|
|
|
|
|
2021-08-25 18:29:10 +02:00
|
|
|
class InitialView(SingleViewPolicy):
|
2021-08-03 18:11:30 +02:00
|
|
|
def update(self, img, extrinsic):
|
2021-08-25 18:29:10 +02:00
|
|
|
self.target = extrinsic
|
|
|
|
super().update(img, extrinsic)
|
2021-07-07 17:46:11 +02:00
|
|
|
|
|
|
|
|
2021-08-25 18:29:10 +02:00
|
|
|
class FrontView(SingleViewPolicy):
|
2021-07-07 17:46:11 +02:00
|
|
|
def activate(self, bbox):
|
|
|
|
super().activate(bbox)
|
2021-08-25 18:29:10 +02:00
|
|
|
l, theta = 0.25, np.deg2rad(30)
|
|
|
|
eye = np.r_[
|
|
|
|
self.center[0] - l * np.sin(theta),
|
|
|
|
self.center[1],
|
|
|
|
self.center[2] + l * np.cos(theta),
|
|
|
|
]
|
2021-07-07 17:46:11 +02:00
|
|
|
up = np.r_[1.0, 0.0, 0.0]
|
2021-08-03 18:11:30 +02:00
|
|
|
self.target = look_at(eye, self.center, up)
|
2021-07-07 17:46:11 +02:00
|
|
|
|
2021-07-08 09:36:51 +02:00
|
|
|
|
2021-08-25 18:29:10 +02:00
|
|
|
class TopView(SingleViewPolicy):
|
2021-07-08 09:36:51 +02:00
|
|
|
def activate(self, bbox):
|
|
|
|
super().activate(bbox)
|
2021-08-25 18:29:10 +02:00
|
|
|
eye = np.r_[self.center[:2], self.center[2] + 0.25]
|
2021-07-08 09:36:51 +02:00
|
|
|
up = np.r_[1.0, 0.0, 0.0]
|
2021-08-03 18:11:30 +02:00
|
|
|
self.target = look_at(eye, self.center, up)
|