Closed zjhthu closed 2 years ago
I find replacing the 'if ... else ' statement with this code can resolve this problem:
valid_projection = sm.Max(0, sm.sign(point_cam_3d[2]))
I'll mention that we also have sm.is_positive(point_cam_3d[2])
as a shorthand for this (and other boolean-logic-type functions you can find in symforce/logic.py
)
thanks, this is usefull
Describe the bug In my residual function, I want to return zero (invalid) reprojection error when the point is behind the camera. The residual function look like this:
But I find the generated C++ code can not handle this case, it returns wrong result when
point_cam_3d[2] <= 0
. Here are test codes: PythonC++