## 1. 问题背景

### 1.2. Minimal problem

Many problems in computer vision, especially problems of computing camera geometry, can be formulated using systems of polynomial equations. Such systems of polynomial equations can have an infinite number of solutions, i.e. are under-determined, no solution, i.e. are overdetermined, or these systems can have a finite number of solutions.

In the case of problems of computing camera geometry, the number of equations in the system and the corresponding number of its solutions depend on the number of geometric constraints and the number of input data (usually 2D-2D, 2D-3D or 3D-3D point or line correspondences) used to formulate the problem. The problems solved from a minimal number of input data and using all the possible geometric constrains that lead to a finite number of solutions are often called “minimal problems” or “minimal cases”. Most of these minimal problems are named according to the smallest number of correspondences that are required to solve these problems and to obtain a finite number of possible solutions, e.g., the five point relative pose problem or the six point focal length problem.

## 2. Propose method

HC之所以慢，就是因为它要从多个起始点开始追踪，以保证能覆盖所有的解，并且最后也要从大量伪解中选出真实解。但如果我们已经知道了真实解附近的一个起始点，那幺只需要跟踪一条路径即可，这样也避免了伪解的干扰。

## 3. 具体细节

image

### 3.2. 神经网络

```class Net(nn.Module):
def __init__(self, anchors):
super(Net, self).__init__()
self.fc1 = nn.Linear(24, 100)
self.relu1 = nn.PReLU(100, 0.25)
self.fc2 = nn.Linear(100, 100)
self.relu2 = nn.PReLU(100, 0.25)
self.fc4 = nn.Linear(100, 100)
self.relu4 = nn.PReLU(100, 0.25)
self.fc5 = nn.Linear(100, 100)
self.relu5 = nn.PReLU(100, 0.25)
self.fc6 = nn.Linear(100, 100)
self.relu6 = nn.PReLU(100, 0.25)
self.fc7 = nn.Linear(100, 100)
self.relu7 = nn.PReLU(100, 0.25)
self.drop3 = nn.Dropout(0.5)
self.fc3 = nn.Linear(100, anchors + 1)
def forward(self, x):
x = self.relu1(self.fc1(x))
x = self.relu2(self.fc2(x))
x = self.relu4(self.fc4(x))
x = self.relu5(self.fc5(x))
x = self.relu6(self.fc6(x))
x = self.relu7(self.fc7(x))
x = self.drop3(x)
return self.fc3(x)```

### 3.3. 流形假设

image-20220721151604974

## 4. 推理流程

image-20220721162331654

1. 将输入点转化为问题向量

1. 通过神经网络选择合适的anchor

1. 构建同伦映射

1. 从 跟踪到 得到最终解

## 5. 实验结果

image-20220721163142822

MINUS是通过HC全局跟踪所有解，最终的成功率为 95%，一次的时间为

## 6. 代码实测

```./BIN/anchors
first commit```

image-20220721172138865

image-20220721172408329

image-20220721174659332

```set -euf
DATA="SyntheticData"
rm -rf \$DATA
mkdir -p \$DATA
TrainDATA="data/multi_view_training_dslr_undistorted"
TestDATA="data/multi_view_test_dslr_undistorted"
# 生成train_data
python3 sample_data.py \$TrainDATA/courtyard/dslr_calibration_undistorted  \$DATA/train_data_courtyard.txt 4000
python3 sample_data.py \$TrainDATA/playground/dslr_calibration_undistorted  \$DATA/train_data_playground.txt 1000
# 生成test_data
python3 sample_data.py \$TrainDATA/relief/dslr_calibration_undistorted \$DATA/test_data.txt 10000
# 生成anchor_data
python3 sample_data.py \$TrainDATA/courtyard/dslr_calibration_undistorted \$DATA/anchor_data.txt 10000
#如果同伦延续能够从一个问题跟踪到另一个问题，则连接两个anchor的边
./BIN/connectivity ./\$DATA/anchor_data.txt ./MODEL ./MODEL/trainParam.txt
#输入是上一步生成的连接图和anchor_data，输出为最终的anchor
#./BIN/anchors ./\$DATA/anchor_data.txt ./MODEL ./MODEL/trainParam.txt
# label 是生成数据集
# X_train.txt 包含训练数据的 14 维向量
# Y_train.txt 为对应的anchor的id
# 生成训练集
./BIN/labels ./\$DATA/train_data_courtyard.txt ./MODEL ./\$DATA train_courtyard ./MODEL/trainParam.txt
./BIN/labels ./\$DATA/train_data_playground.txt ./MODEL ./\$DATA train_playground ./MODEL/trainParam.txt
# 将来自不同数据集的训练集合并
cat ./\$DATA/X_train_courtyard.txt ./\$DATA/X_train_playground.txt > ./model/X_train.txt
cat ./\$DATA/Y_train_courtyard.txt ./\$DATA/Y_train_playground.txt > ./model/Y_train.txt
# 生成测试集
./BIN/labels ./\$DATA/test_data.txt ./MODEL ./MODEL val ./MODEL/trainParam.txt
# 训练
python3 train_nn.py ./MODEL ./MODEL/trainParam.txt
# 验证
./BIN/evaluate ./\$DATA/test_data.txt ./MODEL/ ./MODEL/trainParam.txt```