mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-01 02:41:42 +00:00
Add Python test harness for openCVHelp class (#1557)
This commit is contained in:
@@ -24,9 +24,32 @@ class RotTrlTransform3d:
|
||||
def getRotation(self) -> Rotation3d:
|
||||
return self.rot
|
||||
|
||||
def apply(self, trlToApply: Translation3d) -> Translation3d:
|
||||
def applyTranslation(self, trlToApply: Translation3d) -> Translation3d:
|
||||
return trlToApply.rotateBy(self.rot) + self.trl
|
||||
|
||||
def applyRotation(self, rotToApply: Rotation3d) -> Rotation3d:
|
||||
return rotToApply + self.rot
|
||||
|
||||
def applyPose(self, poseToApply: Pose3d) -> Pose3d:
|
||||
return Pose3d(
|
||||
self.applyTranslation(poseToApply.translation()),
|
||||
self.applyRotation(poseToApply.rotation()),
|
||||
)
|
||||
|
||||
def applyTrls(self, rots: list[Rotation3d]) -> list[Rotation3d]:
|
||||
retVal: list[Rotation3d] = []
|
||||
for rot in rots:
|
||||
retVal.append(self.applyRotation(rot))
|
||||
return retVal
|
||||
|
||||
@classmethod
|
||||
def makeRelativeTo(cls, pose: Pose3d) -> Self:
|
||||
return cls(pose.rotation(), pose.translation()).inverse()
|
||||
|
||||
@classmethod
|
||||
def makeBetweenPoses(cls, initial: Pose3d, last: Pose3d) -> Self:
|
||||
return cls(
|
||||
last.rotation() - initial.rotation(),
|
||||
last.translation()
|
||||
- initial.translation().rotateBy(last.rotation() - initial.rotation()),
|
||||
)
|
||||
|
||||
@@ -107,7 +107,7 @@ class TargetModel:
|
||||
retVal = []
|
||||
|
||||
for vert in self.vertices:
|
||||
retVal.append(basisChange.apply(vert))
|
||||
retVal.append(basisChange.applyTranslation(vert))
|
||||
|
||||
return retVal
|
||||
|
||||
|
||||
@@ -226,8 +226,8 @@ class SimCameraProperties:
|
||||
def getVisibleLine(
|
||||
self, camRt: RotTrlTransform3d, a: Translation3d, b: Translation3d
|
||||
) -> typing.Tuple[float | None, float | None]:
|
||||
relA = camRt.apply(a)
|
||||
relB = camRt.apply(b)
|
||||
relA = camRt.applyTranslation(a)
|
||||
relB = camRt.applyTranslation(b)
|
||||
|
||||
if relA.X() <= 0.0 and relB.X() <= 0.0:
|
||||
return (None, None)
|
||||
@@ -279,7 +279,7 @@ class SimCameraProperties:
|
||||
ipts[i] = None
|
||||
break
|
||||
|
||||
if not ipts[i]:
|
||||
if ipts[i] is None:
|
||||
continue
|
||||
|
||||
for j in range(i - 1, 0 - 1):
|
||||
|
||||
Reference in New Issue
Block a user