Wednesday, June 10, 2020

Multi-byte vs. Unicode

 Multi-byteUnicode
 char TCHAR
 strcat_s()_tcscaft_s()
 strcpy_s()_tcscpy_s()
 strncpy_s()_tcsncpy_s()
 strien()_tcsien()
 sprinif_s()_stprintf_s()

Friday, May 29, 2020

How to get paths defined in the system environment

char path[_MAX_PATH];
const char* varName = "[system environment variable name]";
size_t len;
getenv_s(&len, path, 80, varName);

Print out a (decimal) number as a hexadecimal number

int decNum = 123456;
char hexNum[16];

// decimal number to hexadecimal number
sprintf_s(hexNum, 16, "%X", decNum);
printf("%d -> %s \n", decNum, hexNum);

// hexadecimal number to decimal number
sprintf_s(hexNum, 16, "FF");
decNum = (int)strtol(hexNum, nullptr, 16);
printf(" %s -> %d \n", hexNum, decNum);

Monday, January 27, 2020

Reduced normal matrix for solving fast photogrammetric bundle adjustment

Reduced normatrix for photogrammetric bundle adjustment based on the collinearity equations

Note: There are $m_1$ photos and $m_2$ object points, and the number of EOPs is 6. If 6*$m_1$ is less than 3*$m_2$, solve unknowns related with EOPs. If not, solve object points coordinates, first. This post shows only the first case, 3*$m_2$ > 6*$m_1$.

[Fig. Normal matrix sample]

$$ \begin{pmatrix} N_1 & N_{12} \\ N_{12}^T & N_2 \end{pmatrix}\begin{pmatrix} X_1 \\ X_2 \end{pmatrix} = \begin{pmatrix} C_1 \\ C_2 \end{pmatrix} $$ $$ N_1 X_1 + N_{12} X_2 = C_1$$ $$ N_{12}^T X_1 + N_2 X_2 = C_2$$ In case $6m_1<3m_2$, let's slove $X_1$ first.
$$ X_2 = N_2^{-1} C_2 - N_2^{-1} N_{12}^T X_1$$, therefore
$$ (N_1 - N_{12} N_2^{-1} N_{12}^T) X_1 = C_1 - N_{12} N_2^{-1} C_2$$ $$ X_1 = (N_1 - N_{12} N_2^{-1} N_{12}^T)^{-1}(C_1 - N_{12} N_2^{-1} C_2)$$ And
$$ X_2 = N_2^{-1}(C_2 - N_{12}^T X_1) $$ For $X_2$, we can avoid solving the inverse matrix of $3m \times 3m$ .
For $i_{th}$ point,
$$ X_{2_i} = N_{2_{i}}^{-1}(C_{2_i} - N_{12_i}^T X_1) $$