You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Cv2.SolvePnP with the overload that takes IEnumerable parameters, the rvec and tvec values passed to the function are overwritten before calling the native OpenCV method. This is normally fine, but when using useExtrinsicGuess, this results in garbage output.
The InputArray overload doesn't have this issue.
The problem is here, where rvec and tvec are created from scratch, instead of using the passed-in values.
Environment
Windows 10
OpenCvSharp4.Windows, Version="4.7.0.20230115"
F# 7
What did you do when you faced the problem?
Replaced code with InputArray overload, which works as expected.
Example code (F#):
// Dummy values because coming up with a real scenario is hard.let mutablervec=nulllet mutabletvec=nullwhiletruedo
Cv2.SolvePnP([Point3f(0f,0f,0f); Point3f(0f,0f,1f); Point3f(0f,1f,0f); Point3f(0f,1f,1f)],[Point2f(0f,0f); Point2f(0f,1f); Point2f(1f,0f); Point2f(1f,1f)],
cameraMatrix = array2D [[1394.6027293299926;0.;995.588675691456];[0.;1394.6027293299926;599.3212928484164];[0.;0.;1.]],
distCoeffs =[0.11;-0.219;0.0012;0.00856;0.1127],
rvec =&rvec,
tvec =&tvec,
useExtrinsicGuess =(not<| isNull rvec),
flags = SolvePnPFlags.Iterative
)
Output:
rvec and tvec have reasonable values, or at least close to what they are with useExtrinsicGuess=false.
What did you intend to be?
rvec and tvec are not even close to correct.
The text was updated successfully, but these errors were encountered:
Summary of your issue
When using
Cv2.SolvePnP
with the overload that takesIEnumerable
parameters, the rvec and tvec values passed to the function are overwritten before calling the native OpenCV method. This is normally fine, but when using useExtrinsicGuess, this results in garbage output.The InputArray overload doesn't have this issue.
The problem is here, where rvec and tvec are created from scratch, instead of using the passed-in values.
Environment
What did you do when you faced the problem?
Replaced code with InputArray overload, which works as expected.
Example code (F#):
Output:
rvec and tvec have reasonable values, or at least close to what they are with useExtrinsicGuess=false.
What did you intend to be?
rvec and tvec are not even close to correct.
The text was updated successfully, but these errors were encountered: