# Sparse Indoor Camera Positioning with Fiducial Markers
## 3 Proposed Method
### Metagroup Pose Graph Optimization  
The previous process is repeated independently for each one of the groups \(g^{k}\in G\), obtaining their poses relative to a local reference. Our goal now is to obtain the poses of both cameras and markers of all groups in a common reference system, e.g., centered at marker \(m_{1}^{g^{1}}\). As already explained, there is a connection between some groups \(g^{k}\) and \(g^{t}\), i.e., there is a subset of markers,  
\[C(g^{k},g^{t})=\{m_{i}\}, \tag{17}\]  
between them that have not been moved. If \(C(g^{k},g^{t})\) is known, it is possible to obtain the transform \(\gamma^{k,t}\in SE(3)\) that moves from one group to another. Then, it is true that  
\[\varphi_{m_{i}}^{g^{k}}=\gamma^{k,t}\varphi_{m_{i}}^{g^{t}},\ \forall m_{i}\in C(g^{k},g^{t}). \tag{18}\]The subset can be manually annotated when collecting the images or automatically obtained, as explained later in Section 3.4. In either case, it allows us to build the metagroup pose graph, where nodes are groups and edges their relationship \(\gamma^{k,t}\) (see Figure 4). As in the previous case, we employ [PERSON]'s algorithm to determine the best path from any marker to group \(g^{1}\). Then, we shall denote  
\[\hat{\varphi}_{m_{i}}=\gamma^{1,2}\ldots\ \gamma^{t,k}\varphi_{m_{i}}^{g^{k}} \tag{19}\]  
as the pose \(\varphi_{m_{i}}^{g^{k}}\) transformed to the global reference system (i.e., \(g^{1}\)). The same is applied to obtain the transformed image poses:  
\[\hat{\varphi}_{f_{j}}=\gamma^{1,2}\ldots\ \gamma^{t,k}\varphi_{f_{j}}^{g^{k}}. \tag{20}\]  
Now, the poses are referred to in the reference system of the first group, \(g^{1}\). However, in practical scenarios, it is often preferable to express these poses relative to a CAD model or map of the building. To achieve this, control points can be utilized. A control point \(p_{c_{j}}\in R^{3}\) represents the known position of a marker or a camera within the map, and \(\Pi_{cp}\) denotes the collection of these points. By applying the Horn [38] algorithm with at least three control points, we determine the optimal rigid transformation \(\varphi_{cp}\) that aligns the image and marker poses with the map's reference system:  
\[\varphi_{m_{i}}=\varphi_{cp}\hat{\varphi}_{m_{i}}, \tag{21}\]  
and  
\[\varphi_{f_{j}}=\varphi_{cp}\hat{\varphi}_{f_{i}}. \tag{22}\]  
Our final optimization function combines multiple objectives into a single global error:  
\[E_{g}=E_{rp}+E_{cp}+E_{cc}+E_{cm}. \tag{23}\]  
The global error \(E_{g}\) represents the global reprojection error of the metagraph:  
\[E_{rp}=w_{rp}\sum_{g^{k}\in G}\ \sum_{(m_{i},f_{j})\in O(g^{k})}\ \sum_{l=1}^{4}\|m_{i,l}^{f_{j}}- \Psi\left(\delta_{f_{j^{\prime}}}\left(\varphi_{f_{j}}\right)^{-1}\varphi_{m_ {i}},c_{l}\right)\|^{2}, \tag{24}\]  
Figure 4: **Metagroup pose graph creation**. Group \(g^{3}\) is linked to \(g^{2}\) using the subset of markers \(\{m_{3},m_{4},m_{7},m_{8}\}\). Group \(g^{2}\) is linked to \(g^{1}\) using the subset of markers \(\{m_{1},m_{2},m_{5},m_{6}\}\). where \(w_{rp}\) serves as a normalization factor such that \(E_{rp}=1\) when each individual error equals one. This is computed as the inverse of the total number of projected points, i.e.,  
\[w_{rp}=1/\left(\sum_{g^{c}\in\mathcal{C}}\ \ \sum_{(m_{i},f_{j})\in\mathcal{O}(g^{ c})}\ \ \sum_{i=1}^{4}1\right). \tag{25}\]  
The normalization factor \(w_{rp}\) allows us to combine the different error terms independently of the number of markers, images, or control points optimized. The optional error term \(E_{cc}\) ensures that cameras known to be on the same plane remain coplanar. This is particularly relevant in indoor settings, where cameras are often installed on the ceiling. We define \(\Theta_{o}=\{f_{j}\}\) as the set of fixed cameras that share a single plane. In scenarios with multiple planes, such as buildings with several floors, each plane is associated with its own \(\Theta_{o}\) group. The collection of all these groups is represented as \(\Theta=\{\Theta_{o}\}\).