我认为这是基本的三角函数任务,但我的三角函数不太好。我校准了相机,所以我知道相机矩阵和失真系数。我还能够检测到aruco板(使用opencv的aruco contrib模块)及其位置,所以我有一个旋转矢量和板的平移向量(在相机空间?)。所以我还能够使用相对于板的坐标在板中心周围定义这个黄色圆圈,并使用函数cv::projectPoints(yellowMarkerPoints,rvec,tvec,camMatrix,distCoeffs,imagePoints)绘制它们;和cv :: circle。现在我需要计算最接近相机的圆圈。我不明白该怎么做!
所以我拥有:
Mat camMatrix, distCoeffs;
Vec3d rvec, tvec;//board pose
vector< Point3f > yellowMarkerPoints;//yellow circles positions
或者类似的问题:从这些数据中我可以得到一个相对于相机的板角(也就是'偏航'旋转角度)?
答案 0 :(得分:1)
来自solvePnP()
doc:
该图表示姿势估计问题,您希望估计旋转和平移,以便将世界框架中表示的坐标转换为相机框架。
您需要的是将Aruco电路板框架中表示的每个wrapperMain( { argv, argv + argc } ); // @suppress("Invalid arguments")
转换为相机框架并计算到相机框架的距离。类似的东西:
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let fromVC = transitionContext.viewController(forKey: .from) as! ViewController
let toVC = transitionContext.viewController(forKey: .to) as! SecondViewController
let container = transitionContext.containerView
toVC.view.frame = fromVC.view.frame
container.addSubview(toVC.view)
toVC.view.layoutIfNeeded()
let animatedFromView = fromVC.label!
let animatedToView = toVC.label!
let initialFrame = container.convert(animatedFromView.frame,
from: animatedFromView.superview)
let finalFame = container.convert(animatedToView.frame,
to: animatedToView.superview)
let snapshot = animatedToView.snapshotView(afterScreenUpdates: true)!
snapshot.frame = initialFrame
container.addSubview(snapshot)
animatedFromView.alpha = 0
animatedToView.alpha = 0
UIView.animate(withDuration: 2,
animations: {
snapshot.frame = finalFame
}) { (_) in
snapshot.removeFromSuperview()
fromVC.label.alpha = 1
toVC.label.alpha = 1
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
相当于: