Notes de lecture : Vision géométrique entraînable de bout en bout par rétropropagation à travers l’optimisation PnP
Cet article étudie comment combiner la méthode PnP classique avec l’apprentissage profond. L’idée générale est assez simple : il s’agit surtout de rétropropager les résidus de la méthode PnP dans le réseau neuronal pour permettre un entraînement End2End, et de résoudre le problème sans connaître à l’avance les correspondances entre les données (Blind PnP).
1 Rétropropagation à travers un solveur PnP (BPnP)
Commençons par formuler le problème PnP en termes mathématiques.
On définit g comme un solveur PnP dont la sortie y est la pose à 6DoF estimée :
\boldsymbol{y}=g(\boldsymbol{x}, \boldsymbol{z}, \mathbf{K})\tag{1}Ici, x représente les coordonnées 2D observées des points caractéristiques dans l’image, z représente les coordonnées des points 3D dans l’espace, les points 2D et 3D se correspondent un à un, et K désigne les paramètres intrinsèques de la caméra :
\begin{array}{l}\boldsymbol{x}=\left[\begin{array}{llll}\boldsymbol{x}_{1}^{T} & \boldsymbol{x}_{2}^{T} & \ldots & \boldsymbol{x}_{n}^{T}\end{array}\right]^{T} \in \mathbb{R}^{2 n \times 1} \\\boldsymbol{z}=\left[\begin{array}{llll}\boldsymbol{z}_{1}^{T} & \boldsymbol{z}_{2}^{T} & \ldots & \boldsymbol{z}_{n}^{T}\end{array}\right]^{T} \in \mathbb{R}^{3 n \times 1}\end{array}\tag{2}
Résoudre le problème PnP revient à résoudre le problème d’optimisation suivant :
\boldsymbol{y}=\underset{\boldsymbol{y} \in S E(3)}{\arg \min } \sum_{i=1}^{n}\left\|\boldsymbol{r}_{i}\right\|_{2}^{2}\tag{3}
où \boldsymbol{\pi}_{i}=\pi\left(\boldsymbol{z}_{i} \mid \boldsymbol{y}, \mathbf{K}\right) désigne la projection et \boldsymbol{r}_{i}=\boldsymbol{x}_{i}-\boldsymbol{\pi}_{i} l’erreur de reprojection.
On peut alors adopter la notation abrégée suivante :
\boldsymbol{y}=\underset{\boldsymbol{y} \in S E(3)}{\arg \min } \quad\|\boldsymbol{x}-\boldsymbol{\pi}\|_{2}^{2}\tag{4}
où :
1.1 Dérivation implicite
1.2 Construction de la fonction de contrainte f
On définit la fonction objectif du problème PnP comme suit :
o(\boldsymbol{x}, \boldsymbol{y}, \boldsymbol{z}, \mathbf{K})=\sum_{i=1}^{n}\left\|\boldsymbol{r}_{i}\right\|_{2}^{2}\tag{6}
Lorsque la fonction objectif atteint un minimum, on a :
\left.\frac{\partial o(\boldsymbol{x}, \boldsymbol{y}, \boldsymbol{z}, \mathbf{K})}{\partial \boldsymbol{y}}\right|_{\boldsymbol{y}=g(\boldsymbol{x}, \boldsymbol{z}, \mathbf{K})}=\mathbf{0}\tag{7}
On pose alors :
f(\boldsymbol{x}, \boldsymbol{y}, \boldsymbol{z}, \mathbf{K})=\left[f_{1}, \ldots, f_{m}\right]^{T}\tag{8}
où :
\begin{aligned}f_{j} &=\frac{\partial o(\boldsymbol{x}, \boldsymbol{y}, \boldsymbol{z}, \mathbf{K})}{\partial y_{j}} \\&=2 \sum_{i=1}^{n}\left\langle\boldsymbol{r}_{i}, \frac{\partial \boldsymbol{r}_{i}}{\partial y_{j}}\right\rangle \\&=\sum_{i=1}^{n}\left\langle\boldsymbol{r}_{i}, \boldsymbol{c}_{i j}\right\rangle \\\boldsymbol{c}_{i j} &=-2 \frac{\partial \boldsymbol{\pi}_{i}}{\partial y_{j}}\end{aligned}\tag{9}
1.3 Propagation avant et rétropropagation
On commence par réécrire la fonction du solveur PnP en introduisant une pose initiale y^{(0)} :
\boldsymbol{y}=g\left(\boldsymbol{x}, \boldsymbol{z}, \mathbf{K}, \boldsymbol{y}^{(0)}\right)\tag{10}
Par dérivation implicite, on obtient :
\begin{aligned}\frac{\partial g}{\partial \boldsymbol{x}} &=-\left[\frac{\partial f}{\partial \boldsymbol{y}}\right]^{-1}\left[\frac{\partial f}{\partial \boldsymbol{x}}\right] \\\frac{\partial g}{\partial \boldsymbol{z}} &=-\left[\frac{\partial f}{\partial \boldsymbol{y}}\right]^{-1}\left[\frac{\partial f}{\partial \boldsymbol{z}}\right] \\\frac{\partial g}{\partial \mathbf{K}} &=-\left[\frac{\partial f}{\partial \boldsymbol{y}}\right]^{-1}\left[\frac{\partial f}{\partial \mathbf{K}}\right]\end{aligned}\tag{11}
Pour le réseau neuronal, on dispose du gradient en sortie \nabla \boldsymbol{y}. On obtient alors les gradients par rapport à chaque entrée :
1.4 Notes d’implémentation
2 Apprentissage de bout en bout avec BPnP
2.1 Estimation de la pose
Cette section décrit comment estimer la pose y à partir des coordonnées observées x des points clés, lorsque la carte z et les paramètres intrinsèques K de la caméra sont connus. Voici les étapes :
La fonction de perte s’écrit :
l(\boldsymbol{x}, \boldsymbol{y})=\left\|\pi(\boldsymbol{z} \mid \boldsymbol{y}, \mathbf{K})-\pi\left(\boldsymbol{z} \mid \boldsymbol{y}^{*}, \mathbf{K}\right)\right\|_{2}^{2}+\lambda R(\boldsymbol{x}, \boldsymbol{y})\tag{13}Dans les étapes ci-dessus, un gradient essentiel à la mise à jour se calcule comme suit :
\frac{\partial \ell}{\partial \boldsymbol{\theta}}=\frac{\partial l}{\partial \boldsymbol{y}} \frac{\partial g}{\partial \boldsymbol{x}} \frac{\partial h}{\partial \boldsymbol{\theta}}+\frac{\partial l}{\partial \boldsymbol{x}} \frac{\partial h}{\partial \boldsymbol{\theta}}\tag{14}Les figures ci-dessous illustrent la convergence dans deux cas. Dans chacune, la première ligne correspond à \lambda = 1 et la seconde à \lambda = 0.
La figure 1 correspond à h(I; \theta) = \theta
La figure 2 correspond à une version modifiée du réseau VGG11
Ces deux expériences montrent que les deux configurations convergent avec ou sans terme de régularisation, mais que la convergence est meilleure dans les deux cas lorsque \lambda = 1.
2.2 SfM avec des caméras calibrées
La fonction de perte est définie comme suit :
l\left(\left\{\boldsymbol{y}^{(j)}\right\}_{j=1}^{N}, \boldsymbol{z}\right)=\sum_{j=1}^{N}\left\|\boldsymbol{x}^{(j)}-\pi\left(\boldsymbol{z}^{(j)} \mid \boldsymbol{y}^{(j)}, \mathbf{K}\right)\right\|_{2}^{2}\tag{15}
Le gradient se calcule comme suit :
\frac{\partial \ell}{\partial \boldsymbol{\theta}}=\sum_{j=1}^{N}\left(\frac{\partial l}{\partial \boldsymbol{z}^{(j)}} \frac{\partial \boldsymbol{z}^{(j)}}{\partial \boldsymbol{\theta}}+\frac{\partial l}{\partial \boldsymbol{y}^{(j)}} \frac{\partial \boldsymbol{y}^{(j)}}{\partial \boldsymbol{z}^{(j)}} \frac{\partial \boldsymbol{z}^{(j)}}{\partial \boldsymbol{\theta}}\right)\tag{16}
La figure ci-dessous illustre la convergence dans un exemple de SfM :
2.3 Calibration de la caméra
Voici les étapes de la calibration de la caméra :

La fonction de perte est définie comme suit :
l(\mathbf{K}, \boldsymbol{y})=\|\boldsymbol{x}-\pi(\boldsymbol{z} \mid \boldsymbol{y}, \mathbf{K})\|_{2}^{2}\tag{17}
Le gradient se calcule comme suit :
\frac{\partial \ell}{\partial \boldsymbol{\theta}}=\frac{\partial l}{\partial \mathbf{K}} \frac{\partial \mathbf{K}}{\partial \boldsymbol{\theta}}+\frac{\partial l}{\partial \boldsymbol{y}} \frac{\partial g}{\partial \mathbf{K}} \frac{\partial \mathbf{K}}{\partial \boldsymbol{\theta}}\tag{18}
3 Estimation de la pose d’un objet avec BPnP
Enfin, les auteurs proposent une méthode d’estimation de la pose d’un objet fondée sur BPnP :

Article et code source
Article :https://arxiv.org/abs/1909.06043
Code source :https://github.com/BoChenYS/BPnP
Vidéo :https://www.youtube.com/watch?v=eYmoAAsiBEE



