JakobEngel / dso

Direct Sparse Odometry
GNU General Public License v3.0
2.27k stars 906 forks source link

segmentation fault on Mac #266

Closed duanyaoguang closed 1 year ago

duanyaoguang commented 1 year ago

at first, I use command to run the test case:

./dso_dataset files=./sequence_26/images calib=./sequence_26/camera.txt gamma=./sequence_26/pcalib.txt vignette=./sequence_26/vignette.png preset=0 mode=0

And then, the output logs is:

loading data from ./sequence_26/images!
loading calibration from ./sequence_26/camera.txt!
loading gammaCalib from ./sequence_26/pcalib.txt!
loading vignette from ./sequence_26/vignette.png!

=============== PRESET Settings: ===============
DEFAULT settings:
- no  real-time enforcing
- 2000 active points
- 5-7 active frames
- 1-6 LM iteration each KF
- original image resolution
==============================================
PHOTOMETRIC MODE WITH CALIBRATION!
Reading Calibration from file ./sequence_26/camera.txt ... found!
found ATAN camera model, building rectifier.
Creating FOV undistorter
Input resolution: 1280 1024
In: 0.535719 0.669567 0.493249 0.500409 0.897966

Found fx=0.535719, fy=0.669567, cx=0.493249, cy=0.500409.
 I'm assuming this is the "relative" calibration file format,and will rescale this by image width / height to fx=685.720714, fy=685.636463, cx=630.858138, cy=511.918472.

Out: Rectify Crop
Output resolution: 640 480
finding CROP optimal new model!
initial range: x: -1.1372 - 1.1901; y: -0.8311 - 0.8292!
iteration 00001: range: x: -1.1315 - 1.1841; y: -0.8311 - 0.8292!
iteration 00002: range: x: -1.1258 - 1.1782; y: -0.8311 - 0.8292!
iteration 00003: range: x: -1.1258 - 1.1782; y: -0.8270 - 0.8251!
iteration 00004: range: x: -1.1258 - 1.1782; y: -0.8228 - 0.8209!
iteration 00005: range: x: -1.1258 - 1.1782; y: -0.8228 - 0.8209!

Rectified Kamera Matrix:
 277.34       0 312.234
      0 291.402 239.777
      0       0       1

Reading Photometric Calibration from file ./sequence_26/pcalib.txt
Reading Vignette Image from ./sequence_26/vignette.png
Successfully read photometric calibration!
got 2760 images and 2760 timestamps and 2760 exposures.!
ImageFolderReader: got 2760 files in ./sequence_26/images!
using pyramid levels 0 to 3. coarsest resolution: 80 x 60!
START PANGOLIN!
Initialization: keep 21.5% (need 2000, have 9284)!
INITIALIZE FROM INITIALIZER (1992 pts)!
SPARSITY:  MinActDist 1.900000 (need 2000 points, have 1992 points)!
OPTIMIZE 1992 pts, 1992 active res, 0 lin res!
Initial Error           A(411141.345536)=(AV inf). Num: A(0) + M(0); ab 0.000000 0.000000!
STEPS: A 0.0; B 0.2; R 4.1; T 14.9.     REJECT 0 (L -1.00, dir nan, ss 1.0):    A(497945.603825)=(AV 6.733). Num: A(1373) + M(0); ab -0.000010 0.013283!
STEPS: A 0.0; B 1.2; R 1.4; T 2.9.  ACCEPT 1 (L -1.60, dir -0.00, ss 1.0):  A(455559.838984)=(AV 6.087). Num: A(1537) + M(0); ab -0.000019 -0.084502!
STEPS: A 0.0; B 0.2; R 1.1; T 2.7.  ACCEPT 2 (L -2.20, dir 0.21, ss 1.0):   A(438268.820377)=(AV 6.000). Num: A(1522) + M(0); ab -0.000018 -0.069871!
STEPS: A 0.0; B 0.3; R 0.5; T 0.6.  ACCEPT 3 (L -2.81, dir 0.09, ss 1.0):   A(435927.779987)=(AV 5.997). Num: A(1515) + M(0); ab -0.000018 -0.048207!
LOG 9: 5.988 fine. Res: 1515 A, 0 L, 0 M; (0 / 0) forceDrop. a=-0.000018, b=-0.048207. Window 9 (2)
Coarse Tracker tracked ab = -0.005093 -0.157469 (exp 33.308071). Res 3.052583!
Coarse Tracker tracked ab = -0.022942 0.404961 (exp 33.308071). Res 3.491163!
Coarse Tracker tracked ab = -0.041404 0.699292 (exp 33.308071). Res 3.905575!
Coarse Tracker tracked ab = -0.051148 0.528661 (exp 33.308071). Res 4.646412!
Coarse Tracker tracked ab = -0.093997 1.353475 (exp 33.308071). Res 5.041538!
Coarse Tracker tracked ab = -0.123556 1.977777 (exp 33.308071). Res 5.496130!
SPARSITY:  MinActDist 1.400000 (need 2000 points, have 1424 points)!
zsh: segmentation fault  ./dso_dataset files=./sequence_26/images calib=./sequence_26/camera.txt  

I find the segmentation fault at last of the log, then I try to use debug mode to run the code.

I use lldb on Mac run dso_dataset in debug mode,

# run command
$ lldb ./dso_dataset
(lldb) run files=./sequence_14/images calib=./sequence_14/camera.txt gamma=./sequence_14/pcalib.txt vignette=./sequence_14/vignette.png preset=0 mode=0

and it throw a error: stop reason = EXC_BAD_ACCESS (code=1, address=0xd8)

Process 35046 launched: '/Users/lannisite/dso-slam/dso/build/bin/dso_dataset' (x86_64)
loading data from ./sequence_14/images!
loading calibration from ./sequence_14/camera.txt!
loading gammaCalib from ./sequence_14/pcalib.txt!
loading vignette from ./sequence_14/vignette.png!

=============== PRESET Settings: ===============
DEFAULT settings:
- no  real-time enforcing
- 2000 active points
- 5-7 active frames
- 1-6 LM iteration each KF
- original image resolution
==============================================
PHOTOMETRIC MODE WITH CALIBRATION!
Reading Calibration from file ./sequence_14/camera.txt ... found!
found ATAN camera model, building rectifier.
Creating FOV undistorter
Input resolution: 1280 1024
In: 0.349153 0.436593 0.493140 0.499021 0.933271

Found fx=0.349153, fy=0.436593, cx=0.493140, cy=0.499021.
 I'm assuming this is the "relative" calibration file format,and will rescale this by image width / height to fx=446.915840, fy=447.071232, cx=630.719200, cy=510.497504.

Out: 0.400000 0.530000 0.500000 0.500000 0.000000
Output resolution: 640 480

Rectified Kamera Matrix:
  256     0 319.5
    0 254.4 239.5
    0     0     1

Reading Photometric Calibration from file ./sequence_14/pcalib.txt
Reading Vignette Image from ./sequence_14/vignette.png
Successfully read photometric calibration!
got 1550 images and 1550 timestamps and 1550 exposures.!
ImageFolderReader: got 1550 files in ./sequence_14/images!
using pyramid levels 0 to 3. coarsest resolution: 80 x 60!
START PANGOLIN!
2023-08-02 22:47:59.741294+0800 dso_dataset[35046:1218164] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=35046
2023-08-02 22:47:59.741424+0800 dso_dataset[35046:1218164] SecTaskCopyDebugDescription: dso_dataset[35046]/0#-1 LF=0
2023-08-02 22:48:00.081560+0800 dso_dataset[35046:1218164] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-08-02 22:48:00.222154+0800 dso_dataset[35046:1218164] [Window] Warning: Window NSWindow 0x13a405c90 ordered front from a non-active application and may order beneath the active application's windows.
Initialization: keep 21.9% (need 2000, have 9134)!
INITIALIZE FROM INITIALIZER (1985 pts)!
SPARSITY:  MinActDist 1.900000 (need 2000 points, have 1985 points)!
OPTIMIZE 1985 pts, 1985 active res, 0 lin res!
Initial Error           A(478347.302097)=(AV inf). Num: A(0) + M(0); ab 0.000000 0.000000!
STEPS: A 0.0; B 15.7; R 5.9; T 11.3.    REJECT 0 (L -1.00, dir nan, ss 1.0):    A(485636.342187)=(AV 6.439). Num: A(1464) + M(0); ab -0.000087 -1.328218!
STEPS: A 0.0; B 3.9; R 1.0; T 2.9.  ACCEPT 1 (L -1.60, dir 0.37, ss 1.0):   A(463286.125778)=(AV 5.953). Num: A(1634) + M(0); ab -0.000111 -1.658617!
STEPS: A 0.0; B 0.9; R 0.4; T 0.9.  ACCEPT 2 (L -2.20, dir 0.48, ss 1.0):   A(461859.481012)=(AV 5.961). Num: A(1625) + M(0); ab -0.000110 -1.731262!
LOG 9: 5.956 fine. Res: 1625 A, 0 L, 0 M; (0 / 0) forceDrop. a=-0.000110, b=-1.731262. Window 9 (2)
Coarse Tracker tracked ab = -0.020591 3.705850 (exp 18.505003). Res 5.396490!
Coarse Tracker tracked ab = -0.015714 2.823935 (exp 18.505003). Res 5.100263!
Coarse Tracker tracked ab = -0.009973 1.754565 (exp 18.505003). Res 5.484550!
Coarse Tracker tracked ab = -0.009745 1.973367 (exp 18.505003). Res 6.067480!
Coarse Tracker tracked ab = -0.011804 2.672656 (exp 18.505003). Res 6.531821!
Coarse Tracker tracked ab = -0.015430 3.380671 (exp 18.505003). Res 7.405314!
Coarse Tracker tracked ab = -0.010160 2.921784 (exp 18.505003). Res 7.976058!
SPARSITY:  MinActDist 1.700000 (need 2000 points, have 1615 points)!
Process 35046 stopped
* thread #10, stop reason = EXC_BAD_ACCESS (code=1, address=0xd8)
    frame #0: 0x00000001000335b7 dso_dataset`dso::FullSystem::activatePointsMT() [inlined] std::__1::vector<dso::ImmaturePoint*, std::__1::allocator<dso::ImmaturePoint*> >::operator[][abi:v15006](this=0x00000000000000d8 size=0, __n=0) at vector:1457:18 [opt]
   1454 vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
   1455 {
   1456     _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
-> 1457     return this->__begin_[__n];
   1458 }
   1459 
   1460 template <class _Tp, class _Allocator>
Target 0: (dso_dataset) stopped.
warning: dso_dataset was compiled with optimization - stepping may behave oddly; variables may not be available.