English 中文(简体)
在两个用于数学优化的标记之间查找角度
原标题:Finding angle between two markers for use in mathematical optimisation

我试图尽量缩小3D空间的方块的差别,其中含有一组未知参数。

我有一套示范式的这些界碑(由3D职位和轮换代表),在优化结束时,这些界碑应与一套观察到的界碑匹配。

我使用"http://en.wikipedia.org/wiki/Levenberg%E2%80% 93 Marquardt_algorithm" rel=“nofollow”>Levenberg-Marquardt 优化一套未知参数,这些参数将改变模型3d标记的位置和旋转,直到它们与观察到的3d标记位置(或多或少)匹配。

观察到的3D标记来自计算机视距标记检测算法,它给出每个框架所见标记的代号,以及从每个标记的照相机( 使用COplanar sing )的转换。每个框架只能看到总标记组中的少量标记,在转换中也会有不准确之处。

我考虑过如何构建我的最小化功能, 我想尝试比较相对旋转, 并尽量缩小LM优化每次迭代的旋转差异。

ESTESY:

        foreach (Marker m1 in markers)
        {
            foreach (Marker m2 in markers)
            {
                Vector3 eulerRotation = getRotation(m1, m2);
                ObservedMarker observed1 = getMatchingObserved(m1);
                ObservedMarker observed2 = getMatchingObserved(m2);
                Vector3 eulerRotationObserved = getRotation(observed1, observed2);

                double diffX = Math.Abs(eulerRotation.X - eulerRotationObserved.X);
                double diffY = Math.Abs(eulerRotation.Y - eulerRotationObserved.Y);
                double diffZ = Math.Abs(eulerRotation.Z - eulerRotationObserved.Z);
            }
        }

当 diffX、 diffY 和 diffZ 是要最小化的值时 。

我使用以下方法来计算角度:

Vector3 axis = Vector3.Cross(getNormal(m1), getNormal(m2));
axis.Normalize();
double angle = Math.Acos(Vector3.Dot(getNormal(m1), getNormal(m2)));
Vector3 modelRotation = calculateEulerAngle(axis, angle);

ocNormal(标记m)计算方形标记所在的平面的正常值。

我敢肯定,我在这里做错事了。 将这一切扔入LM 优化( 我使用< a href=""http://www. alglib. net/" rel="nofollow" >ALGLib ) 似乎没有做任何事情, 它经过1次循环和结束, 并且没有改变任何未知参数( 最初全部为 0 ) 。

我在想,我试图将最小化的函数有问题。 似乎有时计算的角度( 第3行) 返回 NaN( 我正设置此选项来返回 diffX、 diffY、 diffZ 等值为 0 ) 。 比较上面的流动角度是否有效?

如有任何帮助,将不胜感激。

<强 > 更多信息:

  • Program is written in C#, I am using XNA as well.
  • The model markers are represented by its four corners in 3D coords
  • All the model markers are in the same coordinate space.
  • Observed markers are the four corners as translations from the camera position in camera coordinate space
  • If m1 and m2 markers are the same marker id or if either m1 or m2 is not observed, I set all the diffs to 0 (no difference).
问题回答

起初我想这可能是个打字机, 但后来我意识到这可能是个虫子, 过去曾是类似案件的受害者。

DiffY 和 diffZ 应该:

double diffY = Math.Abs(eulerRotation.Y - eulerRotationObserved.Y);
double diffZ = Math.Abs(eulerRotation.Z - eulerRotationObserved.Z);

我没有足够的名声来发表这个评论,

您是否希望将所有标记组合的所有 diffs 的“ 和” 最小化? 我认为, 如果您想要使用 LM, 您不应该使用 < code> Math. Abs

另一种选择是手动制定您的客观功能,并使用另一个优化器。 我最近将两个非线性优化器移植到 C#, 甚至不需要您计算衍生物 :

  • COBYLA2, supports non-linear constraints but require more iterations.
  • BOBYQA, limited to variable bounds constraints, but provides a considerable more efficient iteration scheme.




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签