centreborelli / s2p

Satellite Stereo Pipeline
GNU Affero General Public License v3.0
208 stars 67 forks source link

Error Running on 2 images #64

Closed MiladGhorbaniG closed 2 years ago

MiladGhorbaniG commented 4 years ago

Hi, I have run stereo matching with config.json from the pair input folder. My input images are GeoTIFF images. I face the following error:

WARNING: out_dir is a relative path. It is interpreted with respect to config.json location (not cwd)
out_dir is: /home/miladg/output_pair
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  return _prepare_from_string(" ".join(pjargs))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:294: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  projstring = _prepare_from_string(" ".join((projstring, projkwargs)))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  return _prepare_from_string(" ".join(pjargs))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:294: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  projstring = _prepare_from_string(" ".join((projstring, projkwargs)))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  return _prepare_from_string(" ".join(pjargs))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:294: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  projstring = _prepare_from_string(" ".join((projstring, projkwargs)))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  return _prepare_from_string(" ".join(pjargs))
/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/pyproj/crs/crs.py:294: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  projstring = _prepare_from_string(" ".join((projstring, projkwargs)))
tile size: 300 299
total number of tiles: 10320 (86 x 120)

discarding masked tiles...
done 10320 / 10320 tiles
Elapsed time: 0:19:43.085913

correcting pointing locally...
done 10320 / 10320 tiles
Elapsed time: 2:30:59.742639

correcting pointing globally...
Elapsed time: 0:00:03.790607

rectifying tiles...
done 10320 / 10320 tiles
Elapsed time: 0:07:54.447574

running stereo matching...
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/parallel.py", line 43, in tilewise_wrapper
    out = fun(*args)
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/__init__.py", line 205, in stereo_matching
    disp_max)
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/block_matching.py", line 182, in compute_disparity_map
    timeout=timeout,
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/common.py", line 93, in run
    env=env, timeout=timeout, check=True)
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['mgm', '-r', '-209', '-R', '1086', '-s', 'vfit', '-t', 'census', '-O', '8', '-confidence_consensusL', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_disp_confidence.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_ref.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_sec.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_disp.tif']' died with <Signals.SIGKILL: 9>.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/miladg/miniconda3/envs/s2p/bin/s2p", line 8, in <module>
    sys.exit(main())
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/cli.py", line 22, in main
    s2p.main(user_cfg)
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/__init__.py", line 607, in main
    parallel.launch_calls(stereo_matching, tiles_pairs, nb_workers)
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/site-packages/s2p/parallel.py", line 100, in launch_calls
    outputs.append(r.get(600))  # wait at most 10 min per call
  File "/home/miladg/miniconda3/envs/s2p/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
subprocess.CalledProcessError: Command '['mgm', '-r', '-209', '-R', '1086', '-s', 'vfit', '-t', 'census', '-O', '8', '-confidence_consensusL', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_disp_confidence.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_ref.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_sec.tif', '/home/miladg/output_pair/tiles/row_0004784_height_299/col_0023700_width_300/pair_1/rectified_disp.tif']' died with <Signals.SIGKILL: 9>.

What is the cause of this issue?

carlodef commented 4 years ago

There is a tile where the estimated disparity range is very large (-209 to 1086), which causes mgm to use a lot of memory. Your system probably ran out of memory and killed the process.

A few suggestions:

oleg-alexandrov commented 2 years ago

The disparity range, -209 to 1086, is just totally outrageous, given that the tile size is 300 and local alignment per tile was applied. Likely there is an outlier somewhere in the search range determination. I ran into such a thing in a different context. After epipolar alignment in the tile, the interest points in the two images are on lines parallel to each other, and some 1D filtering can be done on them.

gfacciol commented 2 years ago

Sorry if my clarification come a bit too late.

S2P has different mechanisms for estimating the disparity range:

# method to compute the disparity range: "sift", "exogenous", "wider_sift_exogenous", "fixed_pixel_range", "fixed_altitude_range"
cfg['disp_range_method'] = "wider_sift_exogenous"
cfg['use_srtm'] = False

However, if no exogenous dem is provided, and srtm is used (by defaulf cfg['use_srtm'] = False), then the behavior is to estimate the disparity from the rpc bounds.

For some image providers, these bounds are set to +-5km around the Earth's surface (for instance, last time I checked Skysat was doing so). So a solution would be to use the following config, which forces the use of SIFT and SRTM to estimate the disparity range:

 "disp_range_method" : "wider_sift_exogenous",
 "use_srtm" : True