diff --git a/.vscode/launch.json b/.vscode/launch.json index b097c07..620cc8d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,21 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "(gdb) Attach", + "type": "cppdbg", + "request": "attach", + "program": "/home/matt/github/mrcal-java/cmake_build/lib/libmrcal_jni.so", + "processId": "${command:pickProcess}", + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + }, { "name": "Python debug calibrate cameras", "type": "debugpy", @@ -12,8 +27,19 @@ "console": "integratedTerminal", "cwd": "/home/matt/mrcal_debug_tmp/output_will/images-trimmed", "args": [ - "--corners-cache","corners.vnl","--lensmodel","LENSMODEL_OPENCV8","--focal","1200", - "--object-spacing","0.03","--object-width-n","18","--object-height-n","13","*.png" + "--corners-cache", + "corners.vnl", + "--lensmodel", + "LENSMODEL_OPENCV8", + "--focal", + "1200", + "--object-spacing", + "0.03", + "--object-width-n", + "18", + "--object-height-n", + "13", + "*.png" ], "justMyCode": false }, @@ -63,4 +89,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/CMakeLists.txt b/CMakeLists.txt index b8cd135..2799550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ if (WITH_ASAN) add_compile_options(-fsanitize=address -g -Wall -fsanitize=undefined) endif () - find_package(JNI) if (JNI_FOUND) # Fixes odd AWT dependency diff --git a/src/mrcal_wrapper.cpp b/src/mrcal_wrapper.cpp index 40ce2f8..28d9cc3 100644 --- a/src/mrcal_wrapper.cpp +++ b/src/mrcal_wrapper.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) Photon Vision. - * + * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. * @@ -115,7 +115,9 @@ static std::unique_ptr mrcal_calibrate( // Copy from board/point pool above, using some code borrowed from // mrcal-pywrap - mrcal_observation_board_t c_observations_board[Nobservations_board]; + std::vector observations_board_data; + observations_board_data.resize(Nobservations_board); + auto c_observations_board = observations_board_data.data(); // Try to make sure we don't accidentally make a zero-length array or // something stupid mrcal_observation_point_t @@ -176,8 +178,13 @@ static std::unique_ptr mrcal_calibrate( // call optimize // Residuals - double c_b_packed_final[Nstate]; - double c_x_final[Nmeasurements]; + std::vector b_packed_final; + b_packed_final.resize(Nstate); + auto c_b_packed_final = b_packed_final.data(); + + std::vector x_final; + x_final.resize(Nmeasurements); + auto c_x_final = x_final.data(); // Seeds double *c_intrinsics = intrinsics.data();