Skip to content

Commit

Permalink
Merge branch '362-corrections_notebooks' into 'release_branch_1_6_0'
Browse files Browse the repository at this point in the history
Resolve "Corrections notebooks pandora"

See merge request 3d/PandoraBox/pandora!303
  • Loading branch information
lecontm committed Nov 3, 2023
2 parents aef6040 + b556860 commit 319fa9b
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 98 deletions.
13 changes: 7 additions & 6 deletions notebooks/introduction_and_basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"import numpy as np\n",
"import os\n",
"from pathlib import Path\n",
"from pprint import pprint\n",
"import rasterio"
]
},
Expand Down Expand Up @@ -392,8 +393,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg['input']['disp_left'][0]\n",
"disp_max = user_cfg['input']['disp_left'][1]"
]
},
{
Expand Down Expand Up @@ -422,7 +423,7 @@
"outputs": [],
"source": [
"pipeline_cfg = checked_cfg['pipeline']\n",
"print(pipeline_cfg)"
"pprint(pipeline_cfg)"
]
},
{
Expand Down Expand Up @@ -604,8 +605,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg['input']['disp_left'][0]\n",
"disp_max = user_cfg['input']['disp_left'][1]"
]
},
{
Expand Down Expand Up @@ -633,7 +634,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(checked_cfg)"
"pprint(checked_cfg)"
]
},
{
Expand Down
108 changes: 54 additions & 54 deletions notebooks/statistical_and_visual_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg_zncc['input']['disp_left'][0]\n",
"disp_max = user_cfg_zncc['input']['disp_left'][1]"
]
},
{
Expand Down Expand Up @@ -432,8 +432,8 @@
"source": [
"print(\"Threshold = {}\".format(threshold))\n",
"print(\"Total bad error point percentage = {:.2f}\".format(total_bad_percentage))\n",
"print(\"Mean error = {:.2f}\".format(total_bad_percentage))\n",
"print(\"Std error = {:.2f}\".format(mean_error))\n",
"print(\"Mean error = {:.2f}\".format(mean_error))\n",
"print(\"Std error = {:.2f}\".format(std_error))\n",
"print(\"Invalid point percentage = {:.2f}%\".format(invalid_percentage))"
]
},
Expand Down Expand Up @@ -473,24 +473,24 @@
"metadata": {},
"outputs": [],
"source": [
"user_cfg_census = {\n",
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
"user_cfg_census_sgm = {\n",
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
"\n",
" },\n",
" 'pipeline': { \n",
" 'matching_cost': {'matching_cost_method': 'census', 'window_size': 5, 'subpix': 1},\n",
" 'optimization' : {'optimization_method': 'sgm'},\n",
" 'disparity': {'disparity_method':'wta', \"invalid_disparity\": \"NaN\"},\n",
" 'filter': {'filter_method': 'median'},\n",
" 'refinement': {'refinement_method': 'vfit'},\n",
" 'validation': {'validation_method': 'cross_checking_accurate'},\n",
" }\n",
" }"
" },\n",
" 'pipeline': { \n",
" 'matching_cost': {'matching_cost_method': 'census', 'window_size': 5, 'subpix': 1},\n",
" 'optimization' : {'optimization_method': 'sgm'},\n",
" 'disparity': {'disparity_method':'wta', \"invalid_disparity\": \"NaN\"},\n",
" 'filter': {'filter_method': 'median'},\n",
" 'refinement': {'refinement_method': 'vfit'},\n",
" 'validation': {'validation_method': 'cross_checking_accurate'},\n",
" }\n",
"}"
]
},
{
Expand All @@ -515,8 +515,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg_census_sgm['input']['disp_left'][0]\n",
"disp_max = user_cfg_census_sgm['input']['disp_left'][1]"
]
},
{
Expand All @@ -525,9 +525,9 @@
"metadata": {},
"outputs": [],
"source": [
"metadata_left = get_metadata(user_cfg_census[\"input\"][\"img_left\"], (disp_min, disp_max))\n",
"metadata_right = get_metadata(user_cfg_census[\"input\"][\"img_right\"], disparity=None)\n",
"user_cfg_pipeline = get_config_pipeline(user_cfg_census)\n",
"metadata_left = get_metadata(user_cfg_census_sgm[\"input\"][\"img_left\"], (disp_min, disp_max))\n",
"metadata_right = get_metadata(user_cfg_census_sgm[\"input\"][\"img_right\"], disparity=None)\n",
"user_cfg_pipeline = get_config_pipeline(user_cfg_census_sgm)\n",
"cfg_pipeline_census_sgm = check_pipeline_section(user_cfg_pipeline, metadata_left, metadata_right, pandora_machine)['pipeline']"
]
},
Expand All @@ -537,7 +537,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run_prepare(user_cfg_census, img_left, img_right)"
"pandora_machine.run_prepare(user_cfg_census_sgm, img_left, img_right)"
]
},
{
Expand All @@ -553,7 +553,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('matching_cost', user_cfg_census)\n",
"pandora_machine.run('matching_cost', user_cfg_census_sgm)\n",
"left_cv_census = copy.deepcopy(pandora_machine.left_cv)\n",
"right_cv_census = copy.deepcopy(pandora_machine.right_cv)"
]
Expand All @@ -571,7 +571,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('optimization', user_cfg_census)\n",
"pandora_machine.run('optimization', user_cfg_census_sgm)\n",
"left_cv_census_sgm = copy.deepcopy(pandora_machine.left_cv)\n",
"right_cv_census_sgm = copy.deepcopy(pandora_machine.right_cv)"
]
Expand All @@ -589,7 +589,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('disparity', user_cfg_census)\n",
"pandora_machine.run('disparity', user_cfg_census_sgm)\n",
"left_disparity_map_census_sgm = copy.deepcopy(pandora_machine.left_disparity)\n",
"right_disparity_map_census_sgm = copy.deepcopy(pandora_machine.right_disparity)"
]
Expand Down Expand Up @@ -624,7 +624,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('filter', user_cfg_census)\n",
"pandora_machine.run('filter', user_cfg_census_sgm)\n",
"left_disparity_map_census_sgm_filtered = copy.deepcopy(pandora_machine.left_disparity)\n",
"right_disparity_map_census_sgm_filtered = copy.deepcopy(pandora_machine.right_disparity)"
]
Expand Down Expand Up @@ -658,7 +658,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('refinement', user_cfg_census)\n",
"pandora_machine.run('refinement', user_cfg_census_sgm)\n",
"left_disparity_map_census_sgm_refined = copy.deepcopy(pandora_machine.left_disparity)\n",
"right_disparity_map_census_sgm_refined = copy.deepcopy(pandora_machine.right_disparity)"
]
Expand Down Expand Up @@ -692,7 +692,7 @@
"metadata": {},
"outputs": [],
"source": [
"pandora_machine.run('validation', user_cfg_census)\n",
"pandora_machine.run('validation', user_cfg_census_sgm)\n",
"left_disparity_map_census_sgm_validated = copy.deepcopy(pandora_machine.left_disparity)\n",
"right_disparity_map_census_sgm_validated = copy.deepcopy(pandora_machine.right_disparity)"
]
Expand Down Expand Up @@ -759,23 +759,23 @@
"metadata": {},
"outputs": [],
"source": [
"user_cfg_census_sgm = {\n",
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
"user_cfg_census = {\n",
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
"\n",
" },\n",
" 'pipeline': {\n",
" 'matching_cost': {'matching_cost_method': 'census', 'window_size': 5, 'subpix': 1},\n",
" 'disparity': {'disparity_method':'wta', \"invalid_disparity\": \"NaN\"},\n",
" 'filter': {'filter_method': 'median'},\n",
" 'refinement': {'refinement_method': 'vfit'},\n",
" 'validation': {'validation_method': 'cross_checking_accurate'},\n",
" }\n",
" }"
" },\n",
" 'pipeline': {\n",
" 'matching_cost': {'matching_cost_method': 'census', 'window_size': 5, 'subpix': 1},\n",
" 'disparity': {'disparity_method':'wta', \"invalid_disparity\": \"NaN\"},\n",
" 'filter': {'filter_method': 'median'},\n",
" 'refinement': {'refinement_method': 'vfit'},\n",
" 'validation': {'validation_method': 'cross_checking_accurate'},\n",
" }\n",
"}"
]
},
{
Expand All @@ -800,8 +800,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg_census['input']['disp_left'][0]\n",
"disp_max = user_cfg_census['input']['disp_left'][1]"
]
},
{
Expand All @@ -810,9 +810,9 @@
"metadata": {},
"outputs": [],
"source": [
"metadata_left = get_metadata(user_cfg_census_sgm[\"input\"][\"img_left\"], (disp_min, disp_max))\n",
"metadata_right = get_metadata(user_cfg_census_sgm[\"input\"][\"img_right\"], disparity=None)\n",
"user_cfg_pipeline = get_config_pipeline(user_cfg_census_sgm)\n",
"metadata_left = get_metadata(user_cfg_census[\"input\"][\"img_left\"], (disp_min, disp_max))\n",
"metadata_right = get_metadata(user_cfg_census[\"input\"][\"img_right\"], disparity=None)\n",
"user_cfg_pipeline = get_config_pipeline(user_cfg_census)\n",
"cfg_pipeline_census = check_pipeline_section(user_cfg_pipeline, metadata_left, metadata_right, pandora_machine)['pipeline']"
]
},
Expand Down
77 changes: 39 additions & 38 deletions notebooks/usage_with_multiscale.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"import io\n",
"import rasterio\n",
"from pathlib import Path\n",
"from IPython.display import Image, display"
"from IPython.display import Image, display\n",
"from pprint import pprint"
]
},
{
Expand Down Expand Up @@ -417,8 +418,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg['input']['disp_left'][0]\n",
"disp_max = user_cfg['input']['disp_left'][1]"
]
},
{
Expand Down Expand Up @@ -464,7 +465,7 @@
"outputs": [],
"source": [
"pipeline_cfg = checked_cfg['pipeline']\n",
"print(pipeline_cfg)"
"pprint(pipeline_cfg)"
]
},
{
Expand Down Expand Up @@ -594,37 +595,37 @@
"outputs": [],
"source": [
"user_cfg = {\n",
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
" },\n",
" 'pipeline': {\n",
" \"matching_cost\" : {\n",
" \"matching_cost_method\": \"zncc\",\n",
" \"window_size\": 5,\n",
" \"subpix\": 4\n",
" },\n",
" \"disparity\": {\n",
" \"disparity_method\": \"wta\",\n",
" \"invalid_disparity\": \"NaN\"\n",
" },\n",
" \"filter\": {\n",
" \"filter_method\": \"median\"\n",
" },\n",
" \"validation\": {\n",
" \"validation_method\": \"cross_checking_accurate\"\n",
" },\n",
" \"multiscale\": {\n",
" \"multiscale_method\": \"fixed_zoom_pyramid\",\n",
" \"num_scales\": 2,\n",
" \"scale_factor\": 2,\n",
" \"marge\": 1\n",
" }}\n",
" \n",
" }"
" 'input': {\n",
" \"img_left\": img_left_path,\n",
" \"img_right\": img_right_path,\n",
" \"disp_left\": [-60, 0],\n",
" \"left_mask\": left_mask_path,\n",
" \"right_mask\": right_mask_path\n",
" },\n",
" 'pipeline': {\n",
" \"matching_cost\" : {\n",
" \"matching_cost_method\": \"zncc\",\n",
" \"window_size\": 5,\n",
" \"subpix\": 4\n",
" },\n",
" \"disparity\": {\n",
" \"disparity_method\": \"wta\",\n",
" \"invalid_disparity\": \"NaN\"\n",
" },\n",
" \"filter\": {\n",
" \"filter_method\": \"median\"\n",
" },\n",
" \"validation\": {\n",
" \"validation_method\": \"cross_checking_accurate\"\n",
" },\n",
" \"multiscale\": {\n",
" \"multiscale_method\": \"fixed_zoom_pyramid\",\n",
" \"num_scales\": 2,\n",
" \"scale_factor\": 2,\n",
" \"marge\": 1\n",
" },\n",
" },\n",
"}"
]
},
{
Expand All @@ -640,8 +641,8 @@
"metadata": {},
"outputs": [],
"source": [
"disp_min = -60\n",
"disp_max = 0"
"disp_min = user_cfg['input']['disp_left'][0]\n",
"disp_max = user_cfg['input']['disp_left'][1]"
]
},
{
Expand Down Expand Up @@ -687,7 +688,7 @@
"outputs": [],
"source": [
"pipeline_cfg = checked_cfg['pipeline']\n",
"print(checked_cfg)"
"pprint(checked_cfg)"
]
},
{
Expand Down

0 comments on commit 319fa9b

Please sign in to comment.