CNES / cars

CARS is a dedicated and open source 3D tool to produce Digital Surface Models from satellite imaging by photogrammetry.
https://cars.readthedocs.io/
Apache License 2.0
256 stars 30 forks source link

Error: disp_to_alt_ratio = 1 / baseline --> ZeroDivisionError: float division by zero #14

Closed lionlai1989 closed 1 year ago

lionlai1989 commented 2 years ago

Hi team of CARS: I used CARS to process a stereo satellite image pair and encountered the following error:

docker run -w /data -v /home/lai/LiveEO/09_photogrammetry/test_cars_output/superview:/output_dir -v /home/lai/LiveEO/09_photogrammetry/superview:/data cnes/cars:0.5.1 /data/cars_superview_1765.json 
22-10-14 03:58:29 :: WARNING :: Could not import pygraphviz backend. Will try graphviz backend next
WARNING ossimRpcModel::lineSampleHeightToWorld: 
Max number of iterations reached in ground point solution. Results are inaccurate.
Computing epipolar grids ...: 100% [**************************************************] (4s)

Processing Tiles : [  ] ...: 0it [00:00, ?it/s]
22-10-14 03:58:34 :: ERROR :: CARS terminated with following error
Traceback (most recent call last):
  File "/cars/venv/lib/python3.8/site-packages/cars/cars.py", line 172, in main_cli
    used_pipeline.run()
  File "/cars/venv/lib/python3.8/site-packages/cars/pipelines/sensor_to_full_resolution_dsm/sensor_to_full_resolution_dsm_pipeline.py", line 281, in run
    ) = self.epipolar_grid_generation_application.run(
  File "/cars/venv/lib/python3.8/site-packages/cars/applications/grid_generation/epipolar_grid_generation.py", line 224, in run
    ) = grids.generate_epipolar_grids(
  File "/cars/venv/lib/python3.8/site-packages/cars/applications/grid_generation/grids.py", line 147, in generate_epipolar_grids
    return geometry_loader.generate_epipolar_grids(
  File "/cars/venv/lib/python3.8/site-packages/cars/core/geometry/otb_geometry.py", line 338, in generate_epipolar_grids
    disp_to_alt_ratio = 1 / baseline
ZeroDivisionError: float division by zero

The generated content.json:

{
  "version": "0.5.1",
  "pipeline": "sensor_to_full_resolution_dsm_pipeline",
  "inputs": {
    "sensors": {
      "one": {
        "image": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN1.tiff",
        "geomodel": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN1.rpb",
        "no_data": 0,
        "color": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN1.tiff",
        "geomodel_filters": null,
        "mask": null,
        "mask_classes": {
          "ignored_by_dense_matching": null,
          "set_to_ref_alt": null,
          "ignored_by_sparse_matching": null
        }
      },
      "two": {
        "image": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN2.tiff",
        "geomodel": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN2.rpb",
        "no_data": 0,
        "color": "/data/2022-08-15/1765/2022-08-23/1765_SV1-03_20220823_L2A0001265559_6042200530120042_01-PAN2.tiff",
        "geomodel_filters": null,
        "mask": null,
        "mask_classes": {
          "ignored_by_dense_matching": null,
          "set_to_ref_alt": null,
          "ignored_by_sparse_matching": null
        }
      }
    },
    "pairing": [
      [
        "one",
        "two"
      ]
    ],
    "initial_elevation": "/data/2022-08-15/1765_srtm",
    "epsg": null,
    "default_alt": 0,
    "roi": null,
    "check_inputs": false,
    "geoid": "/cars/venv/lib/python3.8/site-packages/cars/pipelines/sensor_to_full_resolution_dsm/../../conf/geoid/egm96.grd"
  }
}

The geomodel looks:

satId = "XXX";
bandId = "MUX";
SpecId = "RPB";
BEGIN_GROUP = IMAGE
    errBias =   1.0;
    errRand =    0.0;
    lineOffset = 4126.890982503364285;
    sampOffset = 3788.402422611036400;
    latOffset =   -21.642167122016708;
    longOffset =  148.548336996612051;
    heightOffset = 301.850444940811428;
    lineScale = 4051.109017496635715;
    sampScale = 3788.402422611036400;
    latScale =    0.074000990421123;
    longScale =    0.072863433972657;
    heightScale = 588.000000000032401;
    lineNumCoef = (
            -5.317223269299340E-05,
            +9.279413064335247E-03,
            -1.011168764691023E+00,
            -1.676271321299624E-02,
            -1.401946638486660E-05,
            +2.513145881701756E-04,
            -2.772569215115550E-05,
            +2.184583238007870E-04,
            +2.883742155070635E-05,
            +8.519501776848075E-07,
            +2.213369867509103E-06,
            +4.125753363915225E-09,
            +4.711622912809601E-08,
            +2.042513733200153E-07,
            -1.753971790020367E-07,
            -4.977443436219330E-06,
            +1.187466237184192E-05,
            -3.227678409702318E-07,
            +5.817159287677402E-07,
            +1.962874044442377E-07);
    lineDenCoef = (
            +1.000000000000000E+00,
            -1.154945125269999E-05,
            -2.439445415433178E-05,
            -2.804176872780332E-05,
            -3.086218361718158E-08,
            -2.053808297592181E-06,
            -1.048429960624843E-06,
            -4.245114854982897E-07,
            +4.919207544243893E-06,
            -1.180022308430092E-05,
            -1.321603607077808E-07,
            +2.110985759127296E-11,
            -9.395709564919536E-11,
            -3.143428000524254E-09,
            +3.489142779250303E-10,
            +1.882315415323664E-11,
            -6.896251528913045E-09,
            -2.950265271855433E-08,
            -2.181537499304206E-07,
            +4.800718277483865E-10);
    sampNumCoef = (
            -2.219015328658193E-06,
            +9.953754417393476E-01,
            +1.077935769575769E-02,
            -9.166329140588179E-04,
            +2.545884070631647E-04,
            +5.892178597842259E-04,
            -2.658985509115448E-04,
            +6.548292235772031E-06,
            -2.033209040323469E-05,
            -4.965916978557951E-06,
            +5.372369406946471E-06,
            +4.964408626753763E-07,
            +1.244304882059571E-04,
            +3.128921353551809E-06,
            -2.448846350491169E-06,
            +1.359555659614748E-06,
            -1.185662633406333E-07,
            -2.849282641435908E-07,
            +5.188526120065396E-08,
            -4.888556130364966E-09);
    sampDenCoef = (
            +1.000000000000000E+00,
            -6.016313900528059E-06,
            -2.543120902255549E-04,
            -5.844136365295069E-04,
            -2.494253142949024E-06,
            -3.150317085850933E-07,
            +5.316271658300229E-06,
            +3.009756871363758E-07,
            +1.259973099110860E-04,
            +2.492016751941515E-06,
            +6.083551839168575E-09,
            -1.695276131959017E-11,
            -7.632997174847906E-10,
            +1.274145797933524E-09,
            -7.005999304318357E-10,
            -6.613084975227342E-08,
            -8.984221040799053E-09,
            -1.160542466340236E-08,
            -1.748532371364333E-07,
            -3.646473924065071E-09);
END_GROUP = IMAGE
END;

My questions are:

  1. CARS is a new software to me. I don't really know what's happening under the hood. Like what does it mean if baseline is 0. Does it mean CARS is not able to read in the geomodel or does it mean that the geomodel can be read but the geomodel doesn't make sense to CARS? I would like to know what does this error mean and the root cause of this error.

  2. In the paper of CARS, it mentions that

    It should be noted that bundle adjustment is excluded from the scope of our pipeline, as it is performed beforehand by an in-house tool. However, our pipeline is tolerant to lack of or imprecise bundle adjustment.
    I didn't do bundle adjustment beforehand on the data in this issue. Is it related to the issue here?

Thanks for reading.

dyoussef commented 2 years ago

Hello @lionlai1989,

I think CARS (and OTB) does not know how to read your geomodel format. Can you send me your data to help you to format its for CARS ? > david.youssefi@cnes.fr

Thank you in advance, David

lionlai1989 commented 2 years ago

Hi: Due to the data agreement with the data provider (Airbus), I can't send the problematic data to you. I am still trying to figure out a way to solve this. Thanks for your attention.

dyoussef commented 1 year ago

I think OTB does not know read your geomodel. You can try to convert it ? You can use this data as example : https://github.com/CNES/cars/blob/master/tests/data/input/phr_reunion/left_image.geom. Do we close this issue ? Because, it will be difficult to help you without the data.

dyoussef commented 1 year ago

I close this issue : @lionlai1989 If you require any further information, please feel free to (re) open it.