Functions for evluation if the labeling is good/done
%load_ext autoreload
%autoreload 2
/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)

leave_one_out_F_validation[source]

leave_one_out_F_validation(corrs:ndarray, error:str='symepi')

/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)

leave_one_out_H_validation[source]

leave_one_out_H_validation(corrs:ndarray, error:str='symtransfer')

/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)

get_error_stat_string[source]

get_error_stat_string(errors)

/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)

get_big_errors_string[source]

get_big_errors_string(errors, th=3.0)

/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)

The function estimates the fundamental matrix or homography using (n-1) correspondences and returns error on that leaved-out correspondence (corr). The operation is repeated for every corr and the output is dict with those errors, together with min, mean, max and max_idx. I have got the idea from the VSAC paper

import matplotlib.pyplot as plt
corrs = np.loadtxt('sample_project/petrzin/corrs.txt')
errors = leave_one_out_F_validation(corrs, 'symepi')
print (errors.keys())
print (f'Symmetrical epipolar distance, min error = {errors["min"]:.4f}, max_error={errors["max"]:.4f}, at {errors["max_idx"]}, mean_error={errors["mean"]:.4f}')
errors = leave_one_out_F_validation(corrs, 'sampson')
print (f'Sampson error, min error = {errors["min"]:.4f}, max_error={errors["max"]:.4f}, at {errors["max_idx"]}, mean_error={errors["mean"]:.4f}')
print (get_error_stat_string(errors))

print (get_big_errors_string(errors))
dict_keys(['min', 'max', 'mean', 'all', 'max_idx'])
Symmetrical epipolar distance, min error = 0.0941, max_error=16.8127, at 38, mean_error=2.0064
Sampson error, min error = 0.0463, max_error=7.8037, at 38, mean_error=0.9528
Errors: min = 0.05, max=7.80, at 38, mean=0.95
Error > 3.0 px, idxs: [38]
/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
import matplotlib.pyplot as plt
corrs = np.loadtxt('sample_project/petrzin/corrs.txt')
errors = leave_one_out_H_validation(corrs)
print (errors.keys())
print (f'Symmetrical transfer distance, min error = {errors["min"]:.4f}, max_error={errors["max"]:.4f}, at {errors["max_idx"]}, mean_error={errors["mean"]:.4f}')
print (get_error_stat_string(errors))
dict_keys(['min', 'max', 'mean', 'all', 'max_idx'])
Symmetrical transfer distance, min error = 0.8725, max_error=152.3928, at 16, mean_error=50.3009
Errors: min = 0.87, max=152.39, at 16, mean=50.30
/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)