diff --git a/MMVII/Doc/Session-0324-Sat-Bundle-Adj/IntroMicMac.tex b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/IntroMicMac.tex similarity index 100% rename from MMVII/Doc/Session-0324-Sat-Bundle-Adj/IntroMicMac.tex rename to MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/IntroMicMac.tex diff --git a/MMVII/Doc/Session-0324-Sat-Bundle-Adj/SerialDeriv.tex b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/SerialDeriv.tex similarity index 100% rename from MMVII/Doc/Session-0324-Sat-Bundle-Adj/SerialDeriv.tex rename to MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/SerialDeriv.tex diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/IGN.tex b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/IGN.tex new file mode 100644 index 0000000000..6211b633da --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/IGN.tex @@ -0,0 +1,132 @@ +\usetheme{default} +%\useinnertheme{rounded} + +%\useoutertheme[left,hideothersubsections]{IGNsidebar} +\useoutertheme[left,hideothersubsections]{IGNsidebar} + + + + +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemedefault.sty +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemeprofessionalfonts.sty +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemeserif.sty +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemestructurebold.sty +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemestructureitalicserif.sty +%/usr/share/texmf/tex/latex/beamer/themes/font/beamerfontthemestructuresmallcapsserif.sty +\usefonttheme{structurebold} + +\RequirePackage{tikz} + +\definecolor{IGNVert}{RGB}{148, 192, 22} +\definecolor{IGNGris}{RGB}{112, 119, 122} + +\definecolor{IGNRouge}{RGB}{255, 100, 100} + +%PUCES +\setbeamercolor{item projected}{bg=IGNGris!70} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COLOR +\setbeamercolor*{normal text}{fg=IGNGris} + +\setbeamercolor{title}{fg=IGNGris} +\setbeamercolor{subtitle}{fg=IGNVert} +\setbeamercolor{item}{fg=IGNVert} + +\setbeamercolor{caption name}{ fg=IGNGris} + +%\setbeamercolor{author in head/foot}{ fg=IGNGris} +%\setbeamercolor{institute in head/foot}{fg=IGNGris} +\setbeamercolor{title in head/foot}{ fg=IGNGris} +\setbeamercolor{date in head/foot}{ fg=IGNGris} +\setbeamercolor{page in head/foot}{ fg=IGNGris} +\setbeamercolor{section in toc}{ fg=IGNGris} +\setbeamercolor{subsection in toc}{ fg=IGNGris} + +\setbeamercolor*{block title alerted}{bg=IGNRouge!70} +\setbeamercolor*{block body alerted}{bg=IGNRouge!20} + +\setbeamercolor*{block title example}{bg=IGNVert!70} +\setbeamercolor*{block body example}{bg=IGNVert!20} + +\setbeamercolor*{block title}{bg=IGNGris!50} +\setbeamercolor*{block body}{bg=IGNGris!20} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NAVIGATION SYMBOLS +\setbeamertemplate{navigation symbols}{} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SIDE BAR +\setbeamersize{sidebar width left=1.5cm} +\setbeamercolor{section in sidebar}{fg=IGNGris} +\setbeamercolor{subsection in sidebar}{fg=IGNGris} + +\setbeamercolor{section in sidebar shaded}{fg=IGNVert} +\setbeamercolor{subsection in sidebar shaded}{fg=IGNVert} + + +\defbeamertemplate*{sidebar}{SSB}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HEAD LINE +\defbeamertemplate*{frametitle}{}{ + \begin{tikzpicture}[scale=0.503] + \filldraw[color=white] (0,0) rectangle(0.1,0.54); + \end{tikzpicture} + + \textcolor{IGNGris}{ \textbf{\insertframetitle}} + \begin{tikzpicture} + \draw[very thick,color=IGNVert] (0,1)--(\paperwidth- 2.24,1); + \end{tikzpicture} +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HEAD LINE +%\defbeamertemplate*{headline}{AH}{ +%} + +\defbeamertemplate*{headline}{}{} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BACKGROUND + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FOOT LINE +\defbeamertemplate*{footline}{} +{ +\leavevmode% + \begin{tikzpicture} + \draw (0,0) node {}; + \draw (0.5,0) node[right] { \textcolor{IGNGris}{\insertshorttitle}}; + \draw (5,0) node[right] { \textcolor{IGNVert}{$\blacksquare$} \textcolor{IGNGris}{\insertshortdate{} } }; + \draw (7.5,0) node { \textcolor{IGNVert}{$\blacksquare$} \textcolor{IGNGris}{\insertframenumber{} / \inserttotalframenumber\hspace*{2ex} }}; + %\draw (9.75,0) node { \textcolor{IGNGris}{ \insertinstitute }}; + \draw (12,0) node[right] { \includegraphics[height=0.25cm]{img/LOGO_IGN_p.png} }; + \end{tikzpicture} + +}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AT BEGIN SECTION + + +\AtBeginSection[] +{ +\setbeamercolor{section in sidebar}{fg=white } +\setbeamercolor{subsection in sidebar}{fg=white } + +\setbeamercolor{section in sidebar shaded}{fg=white } +\setbeamercolor{subsection in sidebar shaded}{fg=white } + + + +\begin{frame}{ + \begin{tikzpicture}[scale=0.503] + \draw[color=IGNGris,fill=IGNGris] (0,0) rectangle (23,9); + \draw (1,1) node [right,text width=10cm,text justified] { \textcolor{white}{\insertsection}}; + \end{tikzpicture} +} +\end{frame} + + +\setbeamercolor{section in sidebar}{fg=IGNGris} +\setbeamercolor{subsection in sidebar}{fg=IGNGris} + +\setbeamercolor{section in sidebar shaded}{fg=IGNVert} +\setbeamercolor{subsection in sidebar shaded}{fg=IGNVert} + +\addtocounter{framenumber}{-1} + +} + diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamer.tex b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamer.tex new file mode 100644 index 0000000000..6d42f4bd38 --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamer.tex @@ -0,0 +1,219 @@ +\documentclass[11pt]{beamer} +\include{IGN} +\usepackage[english]{babel} +\RequirePackage{tikz} +\usetikzlibrary{arrows} +\usepackage[utf8]{inputenc} +\usepackage{listings} +\usepackage{longtable,booktabs} +%\setbeameroption{show notes} + +% from pandoc standalone ------------------ +\usepackage{lmodern} +\usepackage{amssymb,amsmath} +\usepackage{ifxetex,ifluatex} +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[T1]{fontenc} + \usepackage[utf8]{inputenc} + \usepackage{textcomp} % provide euro and other symbols +\else % if luatex or xetex + \usepackage{unicode-math} + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} +\fi +% Use upquote if available, for straight quotes in verbatim environments +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} +\IfFileExists{microtype.sty}{% use microtype if available + \usepackage[]{microtype} + \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts +}{} +\makeatletter +\@ifundefined{KOMAClassName}{% if non-KOMA class + \IfFileExists{parskip.sty}{% + \usepackage{parskip} + }{% else + \setlength{\parindent}{0pt} + \setlength{\parskip}{6pt plus 2pt minus 1pt}} +}{% if KOMA class + \KOMAoptions{parskip=half}} +\makeatother +\usepackage{xcolor} +\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available +\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} +\hypersetup{ + hidelinks, + pdfcreator={LaTeX via pandoc}} +\urlstyle{same} % disable monospaced font for URLs +\newif\ifbibliography +\usepackage{color} +\usepackage{fancyvrb} +\newcommand{\VerbBar}{|} +\newcommand{\VERB}{\Verb[commandchars=\\\{\}]} +\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} +% Add ',fontsize=\small' for more characters per line +\usepackage{framed} +\definecolor{shadecolor}{RGB}{248,248,248} +%\newenvironment{Shaded}{\begin{snugshade}\footnotesize}{\end{snugshade}} +\newenvironment{Shaded}{\begin{snugshade}\small}{\end{snugshade}} +%\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}} +\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}} +\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}} +\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\BuiltInTok}[1]{#1} +\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}} +\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}} +\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}} +\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}} +\newcommand{\ExtensionTok}[1]{#1} +\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\ImportTok}[1]{#1} +\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}} +\newcommand{\NormalTok}[1]{#1} +\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}} +\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}} +\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}} +\newcommand{\RegionMarkerTok}[1]{#1} +\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\setlength{\emergencystretch}{3em} % prevent overfull lines +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +\setcounter{secnumdepth}{-\maxdimen} % remove section numbering +% ---------------------------------- + + + +\def\tightlist{} + +%% DONNES UTILES A LA PAGE DE TITRE ET AU PIED DE PAGE... +\graphicspath{{../../images_template/}} + +\title[]{Python API for MMVII} +\subtitle{IGN - 2024} +%~ \author[shortname]{Jean-Michaël Muller} +%\author[shortname]{Muller J.M. \inst{1} \and Poyard J.C. \inst{1} \and \\Collilieux X. \inst{2}} +%\institute[shortinst]{\inst{1} IGN SGN, Saint-Mandé, France \and % +% \inst{2} IGN LAREG, Université Paris Diderot - Sorbonne Paris Cité, Paris, France} +\date{JMM} + +\newenvironment{smallverbatim}% + {\verbatim\small}% + {\endverbatim} + + +\begin{document} + + +\usebackgroundtemplate{ + \begin{tikzpicture} + %\draw (0,0.5) node[right] { \includegraphics[width=12.5cm]{img/fondClair.png} }; + \draw (0,5) node[right] { \includegraphics[height=1.5cm]{img/LOGO_IGN2.png} }; + %\draw (4,5) node[right] { \includegraphics[height=1.5cm]{img/hrao.png} }; + %\draw (11,5) node[right] { \includegraphics[height=1.5cm]{img/IAG.png} }; + %\draw (7.2,5) node[right] { \includegraphics[height=1.5cm]{img/logoISPRS2016.png} }; + %\draw (11,5) node[right] { \includegraphics[height=1.5cm]{img/LOGO_MATIS.png} }; +% \draw (1.5,4.95) node[right] { \includegraphics[width=3.5cm]{fondD.jpg} }; + \end{tikzpicture} +} + +\begin{frame}[plain,c] +\begin{columns} +\begin{column}{10cm} +\begin{center} +\vspace{2cm} +{ +%\tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge, \Huge. +\LARGE +\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle} + +\vspace{0.3cm} + +{\small \insertsubtitle} + +\vspace{0.3cm} + +\normalsize + +\insertauthor + + + +\normalsize +\vspace{0.5cm} + +\insertinstitute + + +\vspace{0.5cm} + +\insertdate + + +\end{center} +\end{column} +\begin{column}{1cm} +\end{column} +\end{columns} + +\end{frame} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DEBUT DE LA PRESENTATION +% BACKGROUND POUR AVOIR LE HAUT DE PAGE QUI VA BIEN +\usebackgroundtemplate{ + \begin{tikzpicture}[scale=0.503] + \filldraw[color=IGNGris] (0,0) rectangle(2.62,0.54); + \filldraw[color=IGNGris] (4.77,0) rectangle(2.62+4.77,0.54); + + \filldraw[color=IGNVert] (9.50+0.27,0) -- (9.50,0.54)-- (9.50+7.41-0.27,0.54)-- (9.50+7.41,0)--cycle; + + \filldraw[color=IGNGris] (19.50,0) rectangle(2.62+19.50,0.54); + \filldraw[color=IGNGris] (23.11,0.54)--(23.11+0.54,0)--(2.3+23.11,0)--(2.3+23.11,0.54)--cycle;; + \end{tikzpicture} +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% PLAN +\setbeamercolor{section in sidebar}{fg=white } %LIGNE NECESSAIRE POUR EFFACER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{subsection in sidebar}{fg=white }%LIGNE NECESSAIRE POUR EFFACER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{section in sidebar shaded}{fg=white }%LIGNE NECESSAIRE POUR EFFACER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{subsection in sidebar shaded}{fg=white }%LIGNE NECESSAIRE POUR EFFACER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\begin{frame} + \begin{columns}[T] + \begin{column}{7cm} + \tableofcontents[sections={1-5},hideallsubsections] + \end{column} + %\begin{column}{5cm} + %\tableofcontents[sections={6-10},hideallsubsections] + %\end{column} + \end{columns} + +\end{frame} +\setbeamercolor{section in sidebar}{fg=IGNGris}%LIGNE NECESSAIRE POUR AFFICHER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{subsection in sidebar}{fg=IGNGris}%LIGNE NECESSAIRE POUR AFFICHER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{section in sidebar shaded}{fg=IGNVert}%LIGNE NECESSAIRE POUR AFFICHER LE PLAN DE LA SIDEBAR (PAS MIEUX) +\setbeamercolor{subsection in sidebar shaded}{fg=IGNVert}%LIGNE NECESSAIRE POUR AFFICHER LE PLAN DE LA SIDEBAR (PAS MIEUX) + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\input{"presentation.tex"} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\end{document} diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamerouterthemeIGNsidebar.sty b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamerouterthemeIGNsidebar.sty new file mode 100644 index 0000000000..ab24c283ee --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/beamerouterthemeIGNsidebar.sty @@ -0,0 +1,189 @@ +% Copyright 2007 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/licenses/LICENSE for more details. + +\ProvidesPackageRCS $Header: /cvsroot/latex-beamer/latex-beamer/themes/outer/beamerouterthemeIGNsidebar.sty,v 1.9 2007/01/28 20:48:30 tantau Exp $ + + +\newdimen\beamer@sidebarwidth +\newdimen\beamer@headheight +\usebeamerfont{frametitle} +\beamer@sidebarwidth=2.5\baselineskip +\beamer@headheight=2.5\baselineskip +\reset@font + +\def\beamer@lefttext{left} + +\DeclareOptionBeamer{hideothersubsections}[]{\beamer@nav@subsectionstyle{show/show/hide}} +\DeclareOptionBeamer{hideallsubsections}[]{\beamer@nav@subsectionstyle{hide}} + +\DeclareOptionBeamer{width}{\beamer@sidebarwidth=#1} +\DeclareOptionBeamer{height}{\beamer@headheight=#1} +\DeclareOptionBeamer{left}{\def\beamer@sidebarside{left}} +\DeclareOptionBeamer{right}{\def\beamer@sidebarside{right}} +\ExecuteOptionsBeamer{left} +\ProcessOptionsBeamer + + +\mode<presentation> + +\ifdim\beamer@headheight>0pt +% if head height is 0pt, use default frame title + + \setbeamercolor*{frametitle}{parent=sidebar} + + \defbeamertemplate*{frametitle}{sidebar theme} + {% + \nointerlineskip% + \vskip-\beamer@headheight% + \vbox to \beamer@headheight{% + \vfil + \leftskip=-\beamer@leftmargin% + \advance\leftskip by0.3cm% + \rightskip=-\beamer@rightmargin% + \advance\rightskip by0.3cm plus1fil% + {\usebeamercolor[fg]{frametitle}\usebeamerfont{frametitle}\insertframetitle\par}% + {\usebeamercolor[fg]{framesubtitle}\usebeamerfont{framesubtitle}\insertframesubtitle\par}% + \vbox{}% + \vskip-1em% + \vfil + }% + } + + \defbeamertemplate*{headline}{sidebar theme} + {% + \begin{beamercolorbox}[wd=\paperwidth]{frametitle} + \ifx\beamer@sidebarside\beamer@lefttext% + \else% + \hfill% + \fi% + \ifdim\beamer@sidebarwidth>0pt% + \usebeamercolor[bg]{logo}% + \vrule width\beamer@sidebarwidth height \beamer@headheight% + \hskip-\beamer@sidebarwidth% + \hbox to \beamer@sidebarwidth{\hss\vbox to + \beamer@headheight{\vss\hbox{\color{fg}\insertlogo}\vss}\hss}% + \else% + \vrule width0pt height \beamer@headheight% + \fi% + \end{beamercolorbox} + } +\fi + + +\def\beamer@sidebarformat#1#2#3{% + \begin{beamercolorbox}[wd=\beamer@sidebarwidth,leftskip=#1,rightskip=1ex plus1fil,vmode]{#2} + \vbox{}% + #3\par% + \vbox{}% + \vskip-1.5ex% + \end{beamercolorbox} +} + +\defbeamertemplate*{section in sidebar}{sidebar theme} +{% + \vbox{% + \vskip1ex% + \beamer@sidebarformat{3pt}{section in sidebar}{\textbf{\tiny{$\blacktriangleright$}\insertsectionhead}}% + }% +} + +\defbeamertemplate*{section in sidebar shaded}{sidebar theme} +{% + \vbox{% + \vskip1ex% + \beamer@sidebarformat{3pt}{section in sidebar shaded}{ \insertsectionhead}% + }% +} + +\defbeamertemplate*{subsection in sidebar}{sidebar theme} +{% + \beamer@sidebarformat{5pt}{subsection in sidebar}{$\blacktriangleright$\insertsubsectionhead}% +} + +\defbeamertemplate*{subsection in sidebar shaded}{sidebar theme} +{% + \beamer@sidebarformat{5pt}{subsection in sidebar shaded}{\insertsubsectionhead}% +} + +\defbeamertemplate*{subsubsection in sidebar}{sidebar theme} +{% + \beamer@sidebarformat{7pt}{subsubsection in sidebar}{\insertsubsubsectionhead}% +} + +\defbeamertemplate*{subsubsection in sidebar shaded}{sidebar theme} +{% + \beamer@sidebarformat{7pt}{subsubsection in sidebar shaded}{\insertsubsubsectionhead}% +} + + +\ifdim\beamer@sidebarwidth>0pt + + % Sidebar + \setbeamersize{sidebar width \beamer@sidebarside=\beamer@sidebarwidth} + \defbeamertemplate*{sidebar \beamer@sidebarside}{sidebar theme} + { + \beamer@tempdim=\beamer@sidebarwidth% + \advance\beamer@tempdim by -6pt% + { + \vskip5em% + \begin{tikzpicture} + \draw(0,0) node[above] {\includegraphics[height=1.2cm]{img/LOGO_IGN.png}}; + \draw(0,0) node[below] {\insertverticalnavigation{\beamer@sidebarwidth}}; + %\draw(0,-6) node {\includegraphics[height=1.2cm]{ISPRS2012.png}}; + \end{tikzpicture} + } +% {\usebeamerfont{title in sidebar}% +% \vskip1.5em% +% \hskip3pt% +% \usebeamercolor[fg]{title in sidebar}% +% \insertshorttitle[width=\beamer@tempdim,center,respectlinebreaks]\par% +% \vskip1.25em% +% }% +% {% +% \hskip3pt% +% \usebeamercolor[fg]{author in sidebar}% +% \usebeamerfont{author in sidebar}% +% \insertshortauthor[width=\beamer@tempdim,center,respectlinebreaks]\par% +% \vskip1.25em% +% }% + + \vskip5em% + %\hskip0.2cm\hyperlinkdocumentstart{ \includegraphics[height=1.2cm]{LOGO_MATIS.png}} + \vskip2em% + %~ \insertverticalnavigation{\beamer@sidebarwidth}% + \vskip20em% + %\hskip0.2cm \includegraphics[height=1.2cm]{ISPRS2012.png} + + \vfill + \ifx\beamer@sidebarside\beamer@lefttext% + \else% + \usebeamercolor{normal text}% + \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}% + \vskip2pt% + + \fi% + }% + + \ifx\beamer@sidebarside\beamer@lefttext% + \defbeamertemplate*{sidebar right}{sidebar theme} + {% + \vfill% + \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}% + \vskip2pt} + \fi + % Margins + \setbeamersize{text margin left=0.5cm,text margin right=0.5cm} +\fi + +\mode +<all> + +%%% Local Variables: +%%% TeX-master: "~/texmf/tex/latex/beamer/test/test.tex" +%%% End: diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/CMakeLists.txt b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/CMakeLists.txt new file mode 100644 index 0000000000..4c0e157d2d --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.15) +project(mini2007 VERSION 0.1.0) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(MICMAC_PATH $ENV{HOME}/micmac) +set(MMVII_SOURCE_DIR $ENV{HOME}/micmac/MMVII) + +set(mmv2_include_dir "${MMVII_SOURCE_DIR}/include") +set(mmv2_external_include_dir "${MMVII_SOURCE_DIR}/ExternalInclude") +set(EIGEN3_INCLUDE_PATH "${mmv2_external_include_dir}/eigen-3.4.0") + +add_executable(${CMAKE_PROJECT_NAME} main.cpp) +include_directories(${mmv2_include_dir} ${mmv2_external_include_dir} ${EIGEN3_INCLUDE_PATH}) +target_link_libraries(${PROJECT_NAME} ${MICMAC_PATH}/MMVII/bin/libP2007.a) +target_link_libraries(${PROJECT_NAME} ${MICMAC_PATH}/lib/libelise.a) +target_link_libraries(${PROJECT_NAME} ${MICMAC_PATH}/lib/libANN.a) +target_link_libraries(${PROJECT_NAME} pthread X11 stdc++fs -fopenmp) diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/main.cpp b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/main.cpp new file mode 100644 index 0000000000..64086458c1 --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_cpp/main.cpp @@ -0,0 +1,25 @@ +#include <iostream> +#include <MMVII_PCSens.h> + +namespace MMVII { + void CloseRandom(); +} + +int main() +{ + MMVII::cMMVII_Appli::InitMMVIIDirs(std::string(getenv("HOME")) + + "/micmac/MMVII/"); + MMVII::InitStandAloneAppli("mimi2007"); + + std::string oripath = std::string(getenv("HOME")) + + "/micmac/MMVII/MMVII-TestDir/Input/Saisies-MMV1/" + + "MMVII-PhgrProj/Ori/toto/Ori-PerspCentral-IMGP4168.JPG.xml"; + MMVII::cSensorCamPC *aCam; + aCam = MMVII::cSensorCamPC::FromFile(oripath); + std::cout<<"Center: "<<aCam->Center()<<".\n"; + + delete aCam; + MMVII::CloseRandom(); + std::cout<<"done."<<std::endl; + return 0; +} diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_py/ex_mmv2_circcodetargets.py b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_py/ex_mmv2_circcodetargets.py new file mode 100644 index 0000000000..846aab9fef --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/ex_py/ex_mmv2_circcodetargets.py @@ -0,0 +1,37 @@ +import MMVII +from pathlib import Path + + +pt2dSet = MMVII.SetMesPtOf1Im.fromFile('/home/JMMuller/tmp/Circ-Code-Target/MMVII-PhgrProj/PointsMeasure/Filt/MesIm-043_0005_Scaled.tif.xml') + +print(pt2dSet) + +for mes in pt2dSet.measures(): + print(mes.namePt, mes.pt) + + +pcIntrCalib = MMVII.PerspCamIntrCalib.fromFile('/home/JMMuller/tmp/Circ-Code-Target/MMVII-PhgrProj/Ori/BA_rig/CalibIntr_CamNIKON_D5600_Add043_Foc24000.xml') + + +pp2i = pcIntrCalib.mapPProj2Im() +i2pp = pp2i.mapInverse() + +print(pcIntrCalib.pp, ' -> ', i2pp.value(pcIntrCalib.pp)) + +dist = pcIntrCalib.dir_Dist() +inv_dist = MMVII.DataInvertOfMapping2D(pcIntrCalib.dir_DistInvertible()) + +for mes in pt2dSet.measures(): + pt = mes.pt + print('Pt ', mes.namePt, ' im: ', pt) + print(' -> central with disto: ', i2pp.value(pt)) + print(' -> central no disto: ', inv_dist.value(i2pp.value(pt))) + print(' -> lig/col no disto: ', pp2i.value(inv_dist.value(i2pp.value(pt)))) + + + +for mes in pt2dSet.measures(): + mes.pt = pp2i.value(inv_dist.value(i2pp.value(mes.pt))) + +pt2dSet.toFile('out_no_dist.xml') + diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/IGN.jpg b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/IGN.jpg new file mode 100644 index 0000000000..930fb0c19f Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/IGN.jpg differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN.png b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN.png new file mode 100644 index 0000000000..f5bb98869e Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN.png differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN2.png b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN2.png new file mode 100644 index 0000000000..3742a31328 Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN2.png differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN_p.png b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN_p.png new file mode 100644 index 0000000000..495615cea5 Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/LOGO_IGN_p.png differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/fondClair.png b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/fondClair.png new file mode 100644 index 0000000000..d2a5ccb78b Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/fondClair.png differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/uml_mes_im1.png b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/uml_mes_im1.png new file mode 100644 index 0000000000..026d5b59c0 Binary files /dev/null and b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/img/uml_mes_im1.png differ diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/main.cpp b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/main.cpp new file mode 100644 index 0000000000..5eba37b2e8 --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/main.cpp @@ -0,0 +1,25 @@ +#include <iostream> +#include <chrono> +#include <opencv2/opencv.hpp> +using namespace std::chrono; +using ClockType = std::chrono::steady_clock; +#define SIMPLE +int main(int argc, char** argv ) +{ + cv::Mat im = cv::imread( "in.png", cv::IMREAD_GRAYSCALE ); + + auto start = ClockType::now(); + uint8_t* im_data = (uint8_t*)im.data; + + for (int l=0; l<im.rows; ++l) + for (int c=0; c<im.cols; ++c) + im_data[l*im.cols+c] = im_data[l*im.cols+c] * c / im.cols; + + auto end = ClockType::now(); + auto duration = (end - start); + auto ms = duration_cast<milliseconds>(duration).count(); + std::cout << "duration: " << ms << " ms " << '\n'; + + cv::imwrite("out.png", im); + return 0; +} diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/makefile b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/makefile new file mode 100644 index 0000000000..f5b3039af6 --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/makefile @@ -0,0 +1,9 @@ +#voir https://github.com/jeromyanglim/rmarkdown-rmeetup-2012/tree/master/talk + +pdf: + pandoc presentation.md --slide-level 3 -t beamer -o presentation.tex + pdflatex beamer.tex + pdflatex beamer.tex + +clean: + rm -f *.aux *.log *.out *.toc *.snm *.nav diff --git a/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/presentation.md b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/presentation.md new file mode 100644 index 0000000000..30b224fc82 --- /dev/null +++ b/MMVII/Doc/Programming-Session-2024-03-Sat-Bundle-Adj/apipy_mmvii/presentation.md @@ -0,0 +1,597 @@ +# Introduction + +### + +MMVII is easily scriptable thanks to its command line interface. + +\ +How to read/write MMVII files for a custom usage? + +\ +How to use MMVII classes and functions? + +### + + +You can add features to MMVII by modifying its sources (the doc helps!): + + - it's in C++ + - fork or pushing right to MMVII repository + - quality and reasonable follow-up should be ensured + - adding commands for some very specific cases makes MMVII more complex for all users + +\ + +You can make your own C++ project using the *libP2007.a* library... + + +### Standalone C++: source (read Ori) + + +``` {.cpp} +#include <MMVII_PCSens.h> +namespace MMVII { void CloseRandom(); } +int main() +{ + MMVII::cMMVII_Appli::InitMMVIIDirs( + std::string(getenv("HOME"))+"/micmac/MMVII/" ); + MMVII::InitStandAloneAppli("mini2007"); + std::string oriPath = + "Ori-PerspCentral-IMGP4168.JPG.xml"; + MMVII::cSensorCamPC *aCam; + aCam = MMVII::cSensorCamPC::FromFile(oriPath); + std::cout<<"Center: "<<aCam->Center()<<"\n"; + delete aCam; + MMVII::CloseRandom(); + return 0; +} +``` + +### Standalone C++: CMakeLists +``` {.cmake} +cmake_minimum_required(VERSION 3.15) +project(mini2007 VERSION 0.1.0) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(MICMAC_PATH $ENV{HOME}/micmac) +set(MMVII_SOURCE_DIR $ENV{HOME}/micmac/MMVII) +set(mmv2_include_dir "${MMVII_SOURCE_DIR}/include") +set(mmv2_external_include_dir + "${MMVII_SOURCE_DIR}/ExternalInclude") +set(EIGEN3_INCLUDE_PATH + "${mmv2_external_include_dir}/eigen-3.4.0") +``` + +### Standalone C++: CMakeLists +``` {.cmake} +add_executable(${CMAKE_PROJECT_NAME} main.cpp) + +include_directories(${mmv2_include_dir} + ${mmv2_external_include_dir} + ${EIGEN3_INCLUDE_PATH}) +target_link_libraries(${PROJECT_NAME} + ${MICMAC_PATH}/MMVII/bin/libP2007.a) +target_link_libraries(${PROJECT_NAME} + ${MICMAC_PATH}/lib/libelise.a) +target_link_libraries(${PROJECT_NAME} + ${MICMAC_PATH}/lib/libANN.a) +target_link_libraries(${PROJECT_NAME} + pthread X11 stdc++fs -fopenmp) +``` + +### + +... or use the Python API! + +\ +MMVII Python API (aka *apib11*) is based on *pybind11* ([https://github.com/pybind/pybind11](https://github.com/pybind/pybind11)): + +\vspace{0.5cm} + +> pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. + +### + +A selection of MMVII classes and functions is made usable in Python, with some adjustments: + + - differences between C++ and Python synthax (e.g.: no overloading, no templates...) + - simplification if possible + - pythonization: + - define *\_\_repr\_\_()* etc. + - automatic conversion from lists or *np.array* into MMVII points objects etc. + - memory management: *return value policy* + +### Other tools + +Other tools to generate a Python API: + + - *SWIG*: universal, can make APIs for many languages, but uses a specific synthax and not easy to use with modern C++. Used in an unofficial Python API for MM3D. + + - *Boost.Python*: close to *pybind11*, but depends on *Boost*... + +### Why pybind11? + + - rather simple C++ syntax + - good documentation + - home-made automatic integration of *Doxygen* comments into Python doc + +### Documentation + + - this presentation + - *MMVII/apib11/README.md* + - MMVII documentation chapter 17 + - examples in *MMVII/apib11/examples* + + +# Compilation + +### Sources + +All sources are in *MMVII/apib11/*. + +The main files are: + + - *py_MMVII.cpp* / *py_MMVII.h*: initialization, closing and error handling, calling all the other files + - *MMVII.py*: Python-side initialization + - *makedoc.py*: automatic C++ *Doxygen* comments conversion into Python doc + - *setup.py*: description of the MMVII module and its compilation + +### Sources + +Some MMVII C++ class bindings: + + - *py_MMVII_Matrix.cpp*, *py_MMVII_Geom3D.cpp*: matrix, 3d rotation and isometry + - *py_MMVII_Images.cpp*, *py_MMVII_Image2D.cpp*: data from images + - *py_MMVII_MeasuresIm.cpp*: 2D and 3D measures, sets of measures + - *py_MMVII_PCSens.cpp*, *py_MMVII_Mappings.cpp*: cameras and mappings + +### Building + +The build system is based on a *makefile* calling *Setuptools*. + +For now, it only works on GNU/Linux. + +Extract from *MMVII/apib11/README.md*: + +``` {.markdown} +Dependencies + sudo apt install python3-pip doxygen + pip3 install pybind11 wheel + +First, compile MMv1 and MMv2. +Then, in 'apib11' directory: + make + +Installation: + make install +``` + +# Usage + +### Installation + +The *wheel* file \textit{dist/MMVII-*.whl}, created at compilation, can be distributed to machines with the same OS, architecture, python version... + + +- it contains all the necessary files to run the module: +MMVII does not have to be installed on the machine to use the python module. + +- it can be installed with: + + ``` {.bash} + pip3 install MMVII-*.whl + ``` + +### Import + +``` {.bash} +>>> import MMVII +MMVII path: /home/Toto/.local/MMVII/MMVII +MMVII initialized. +>>> MMVII. +MMVII.AimeDescriptor( MMVII.Mes1GCP( +MMVII.AimePCAR( MMVII.MesIm1Pt( +MMVII.Box2dr( MMVII.PerspCamIntrCalib( +MMVII.Box3di( MMVII.Rect1( +MMVII.Box3dr( MMVII.Rect2( +MMVII.DataIm2Df( MMVII.Rect3( +MMVII.DataIm2Di( MMVII.Rotation3D( +MMVII.DataIm2Dr( MMVII.SensorCamPC( +MMVII.DataIm2Duc( MMVII.Set2D3D( +... +``` + +### Example + +Let's read a 2D measurements file, correct the image coordinates +from distortion and export them. + +The data is in: + +``` {.python} +path = 'MMVII/MMVII-TestDir/' \ + 'Input/Saisies-MMV1/MMVII-PhgrProj/' +``` + +- the 2D measurements file: + +*PointsMeasure/ Saisies_MMVII/MesIm-IMGP4167.JPG.xml* + +- the calibration file: + +*Ori/toto/ Calib-PerspCentral-Foc-28000_Cam-PENTAX_K5.xml* + +### 2D measurements file + +``` {.haskell} +<Root> + <Type>"MMVII_Serialization"</Type> + <Version>"0.0.0"</Version> + <Data> + <SetMesIm> + <NameIm>"IMGP4167.JPG"</NameIm> + <Measures> + <el> + <Name>"Stone-6"</Name> + <Pt>644.2863 232.6833</Pt> + <Sigma2>1 0 1</Sigma2> + </el> + [...] + </Measures> + </SetMesIm> + </Data> +</Root> +``` + +### C++ classes diagram + + \begin{center} + \includegraphics[height = 7cm]{img/uml_mes_im1.png} + \end{center} + + +### Reading the file + +``` {.python} +pt2dSet = MMVII.SetMesPtOf1Im.fromFile(path + +'PointsMeasure/Saisies_MMVII/' + +'MesIm-IMGP4167.JPG.xml') +``` + +``` {.bash} +>>> pt2dSet +SetMesPtOf1Im MesIm-IMGP4167.JPG.xml +Stone-6 644.28631 232.68332 +Stone-7 1265.3681 735.26883 +Grille 322.0761 766.81187 +``` + +``` {.bash} +>>> dir(pt2dSet) +['AddMeasure', '__class__', [...], '__str__', + '__subclasshook__', 'fromFile', 'measures', + 'measuresOfName', 'nameHasMeasure', 'nameIm', + 'nearestMeasure', 'stdNameFile', 'toFile'] +``` + +### Python integration + +``` {.bash} +>>> type(pt2dSet.measures()) +<class 'list'> +>>> type(pt2dSet.measures()[0]) +<class '_MMVII.MesIm1Pt'> +>>> type(pt2dSet.measures()[0].pt) +<class 'numpy.ndarray'> +``` + +``` {.bash} +>>> for mes in pt2dSet.measures(): +... print(mes.namePt, mes.pt) +... +Stone-6 [644.286308 232.68331645] +Stone-7 [1265.36807144 735.2688294 ] +Grille [322.07609729 766.81186618] +``` + +### Errors handling + +``` {.bash} +>>> MMVII.SetMesPtOf1Im.fromFile('xxx.xml') + + +############## Python API error handler ###### + +Level=[UserEr:OpenFile] +Mes=[Cannot open file : xxx.xml in mode read] +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +RuntimeError: UserEr:OpenFile Cannot open file : + xxx.xml in mode read +>>> +``` + +### Errors handling + +``` {.bash} +>>> try: +... tmp = MMVII.SetMesPtOf1Im.fromFile('no.xml') +... print('read OK') +... except: +... tmp = 79 +... print('error when reading') +... + +############### Python API error handler ###### + +Level=[UserEr:OpenFile] +Mes=[Cannot open file : error.xml in mode read] +error when reading +>>> tmp +79 +``` + +### Calibration + +Get the perspective camera internal calibration object: + +``` {.python} +pcIntrCalib = MMVII.PerspCamIntrCalib.fromFile(path + +'Ori/toto/' + +'Calib-PerspCentral-Foc-28000_Cam-PENTAX_K5.xml') +``` + +``` {.bash} +>>> dir(pcIntrCalib) +[[...], 'dir_Dist', 'dir_DistInvertible', + 'f', 'fromFile', 'infoParam', 'invProjIsDef', + 'inv_Proj', 'mapPProj2Im', 'name', 'pp', + 'szPix', 'toFile', 'value', 'values'] + +>>> pcIntrCalib.pp +array([856.86700874, 577.61365093]) +>>> pcIntrCalib.f +2112.2179520972604 +``` + +### Mappings + +Mapping between photogrammetric/PP and pixel/image frames: +$$ Q_{Im} = PP + F * Q_{PP}$$ + +``` {.python} +pp2i = pcIntrCalib.mapPProj2Im() + +i2pp = pp2i.mapInverse() +``` + +``` {.bash} +>>> pt = pcIntrCalib.pp +>>> print(pt, ' -> ', i2pp.value(pt)) +[856.8670 577.6136] -> [0. 0.] +``` + +``` {.bash +>>> pt = pcIntrCalib.pp + [1000, 100] +>>> print(pt, ' -> ', i2pp.value(pt)) +[1856.8670 677.6136] -> [0.4734 0.0473 ] +``` + +### Distorsion + +Distorsion is also a mapping: + +``` {.python} +dist = pcIntrCalib.dir_Dist() +``` + +But not easily invertible: + +``` {.bash} +>>> type(pcIntrCalib.dir_Dist()) +<class '_MMVII.DataMapping2D'> + +>>> type(pcIntrCalib.dir_DistInvertible()) +<class '_MMVII.DataInvertibleMapping2D'> +``` + +``` {.python} +inv_dist = MMVII.DataInvertOfMapping2D( + pcIntrCalib.dir_DistInvertible()) +``` + +Do not use *pcIntrCalib.dir\_DistInvertible()* directly! + +### +``` {.bash} +>>> for mes in pt2dSet.measures(): +... pt = mes.pt +... print('Pt', mes.namePt, 'im:', pt) +... print(' -> central with disto: ', + i2pp.value(pt)) +... print(' -> central no disto: ', + inv_dist.value(i2pp.value(pt))) +... print(' -> lig/col no disto: ', + pp2i.value(inv_dist.value(i2pp.value(pt)))) +... +Pt Stone-6 im: [644.286308 232.68331645] + -> central with disto: [-0.10064335 -0.16330243] + -> central no disto: [-0.10100147 -0.1638833 ] + -> lig/col no disto: [643.52988797 231.45641165] +[...] +``` + +### Full script + +``` {.python} +import MMVII + +pt2dSet = MMVII.SetMesPtOf1Im.fromFile( + 'MesIm-XXXX.JPG.xml') +pcIntrCalib = MMVII.PerspCamIntrCalib.fromFile( + 'Calib-PerspCentral-Foc-28000_Cam-PENTAX_K5.xml') + +pp2i = pcIntrCalib.mapPProj2Im() +i2pp = pp2i.mapInverse() +inv_dist = MMVII.DataInvertOfMapping2D( + pcIntrCalib.dir_DistInvertible()) + +for mes in pt2dSet.measures(): + mes.pt = pp2i.value( + inv_dist.value( + i2pp.value(mes.pt))) + +pt2dSet.toFile('out_no_dist.xml') +``` + + +# Development + +### Documentation + +The basic documentation: + +[https://pybind11.readthedocs.io/en/stable/basics.html](https://pybind11.readthedocs.io/en/stable/basics.html) + +\ +Classes manipulation documentation: + +[https://pybind11.readthedocs.io/en/stable/classes.html](https://pybind11.readthedocs.io/en/stable/classes.html) + + + +### How to bind *cMesIm1Pt* + +*cMesIm1Pt* class is declared in +*MMVII/include/ MMVII_MeasuresIm.h*: + +``` {.cpp} + +class cMesIm1Pt +{ + public : + cMesIm1Pt(const cPt2dr & aPt, + const std::string & aNamePt, + tREAL4 aSigma2); + cMesIm1Pt(); + cPt2dr mPt; + std::string mNamePt; + tREAL4 mSigma2[3]; // xx xy yy +}; +``` + +### + +The Python-accessible version is in *MMVII/apib11/ py_MMVII_MeasuresIm.cpp*: + +``` {.cpp} + +void pyb_init_MeasuresIm(py::module_ &m) { + py::class_<cMesIm1Pt>(m, "MesIm1Pt", + DOC(MMVII_cMesIm1Pt)) + .def(py::init<>(), + DOC(MMVII_cMesIm1Pt,cMesIm1Pt)) + .def(py::init<const cPt2dr &, + const std::string &,tREAL4>(), + DOC(MMVII_cMesIm1Pt,cMesIm1Pt)) + .def_readwrite("pt", &cMesIm1Pt::mPt, + DOC(MMVII_cMesIm1Pt,mPt)) + .def_readwrite("namePt", &cMesIm1Pt::mNamePt, + DOC(MMVII_cMesIm1Pt,mNamePt)) + +``` + +The _DOC_ part is the doxygen comment. + +### +``` {.cpp} + + .def_property("sXX", + [](const cMesIm1Pt& m) + {return m.mSigma2[0];}, + [](cMesIm1Pt& m, tREAL8 sXX) + { m.mSigma2[0] = sXX;}, + "Sigma2 of x coordinate") + [...] + .def("__repr__", + [](const cMesIm1Pt &m) { + std::ostringstream ss; + ss.precision(8); + ss << "MesIm1Pt " << m.mNamePt << " " + << m.mPt << ", sigma2 (xx,xy,yy): " + << m.mSigma2[0] << ", " + << m.mSigma2[1] << ", " + << m.mSigma2[2] << ")"; + return ss.str(); + }) + ; +``` + +### SetMesPtOf1Im + +``` {.cpp} +class cSetMesPtOf1Im : public cMemCheck +{ +public : + cSetMesPtOf1Im(const std::string & aNameIm); + cSetMesPtOf1Im(); + static cSetMesPtOf1Im FromFile(const std::string&); + void AddMeasure(const cMesIm1Pt &); + void AddData(const cAuxAr2007 & anAux); + void ToFile(const std::string & aNameFile) const; + [...] + const std::vector<cMesIm1Pt> & Measures() const; + std::vector<cMesIm1Pt> & Measures() ; + [...] +private : + [...] + std::string mNameIm; + std::vector<cMesIm1Pt> mMeasures; +}; +``` + +### + +*SetMesPtOf1Im::Measures()* returns a reference to the *mMeasures* attribute. +The *cSetMesPtOf1Im* object must not be destroyed while the reference is still used. + +This function *return value policy* must be adjusted to avoid crashes and memory corruption: +[pybind11.readthedocs.io/en/stable/advanced/functions.html](https://pybind11.readthedocs.io/en/stable/advanced/functions.html) + +``` {.cpp} +py::class_<cSetMesPtOf1Im>(m, "SetMesPtOf1Im", + DOC(MMVII_cSetMesPtOf1Im)) + [...] + .def("measures", + py::overload_cast<>(&cSetMesPtOf1Im::Measures), + py::return_value_policy::reference_internal, + DOC(MMVII_cSetMesPtOf1Im,Measures)) + [...] +``` +*py::overload_cast* is mandatory since *Measures()* is overloaded. + + +### Future developments + + - Distribution: + - modernize *setup.py* project + - integrate in main *cmake* build system + - automatize compilation on several targets + - integrate in *github actions* + - distribute on *Python Package Index* ([https://pypi.org/](https://pypi.org/)) + - API design: + - based on users needs + - with users help: tests, documentation, development + +### Examples of API improvements + + - fix *SetMesGCP.\_\_repr\_\_()*, points name missing + + - add *cPerspCamIntrCalib.Undist()* + + - fix *SetMesPtOf1Im.measuresOfName()* which crashes with an error message beyond understanding + + - add *measuresOfName()* to *SetMesGCP* + + - add *cBlocOfCamera* class