mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Populate classId and confidence level for object detection in Java simulation (#2372)
## Description compute confidence level based on target area in total image size and populate classId and confidence level in Java (while building the PhotonTrackedTarget) ## Changes - Add new VisionTargetSim constructor for object detection - If class ID specified but confidence = -1, estimate based on total area --------- Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
This commit is contained in:
@@ -368,6 +368,15 @@ class PhotonCameraSim:
|
||||
noisyTargetCorners,
|
||||
)
|
||||
|
||||
# Compute object detection confidence if this is an obj det target
|
||||
classId = tgt.objDetClassId
|
||||
conf = tgt.objDetConf
|
||||
if classId >= 0 and conf < 0:
|
||||
# Simulate confidence using sqrt-scaled area for a more realistic
|
||||
# curve. Raw areaPercent/100 is tiny for most targets; sqrt scaling
|
||||
# gives reasonable values even for small-but-visible objects.
|
||||
conf = max(0.0, min(1.0, math.sqrt(areaPercent / 100.0) * 2.0))
|
||||
|
||||
smallVec: list[TargetCorner] = []
|
||||
for corner in minAreaRectPts:
|
||||
smallVec.append(TargetCorner(corner[0], corner[1]))
|
||||
@@ -381,6 +390,8 @@ class PhotonCameraSim:
|
||||
area=areaPercent,
|
||||
skew=math.degrees(centerRot.X()),
|
||||
fiducialId=tgt.fiducialId,
|
||||
objDetectId=classId,
|
||||
objDetectConf=conf,
|
||||
detectedCorners=cornersFloat,
|
||||
minAreaRectCorners=smallVec,
|
||||
bestCameraToTarget=pnpSim.best if pnpSim else Transform3d(),
|
||||
|
||||
Reference in New Issue
Block a user