27#include <opencv2/opencv.hpp>
31#include <modal_pipe.h>
50#define CM_CHAR_BUF_SIZE 64
58#define DEG_TO_RAD (M_PI / 180.0)
67#define RAD_TO_DEG (180.0 / M_PI)
111static std::string camera_mode_as_string(
camera_mode cm)
123 return "STEREO_LEFT_ONLY";
127 return "STEREO_RIGHT_ONLY";
143static camera_mode string_camera_mode_to_enum(
const char *str_cm)
145 if (!strncmp(str_cm,
"MONO",
sizeof(
"MONO")))
149 if (!strncmp(str_cm,
"STEREO",
sizeof(
"STEREO")))
153 if (!strncmp(str_cm,
"STEREO_LEFT_ONLY",
sizeof(
"STEREO_LEFT_ONLY")))
157 if (!strncmp(str_cm,
"STEREO_RIGHT_ONLY",
sizeof(
"STEREO_RIGHT_ONLY")))
227static int64_t _apps_time_monotonic_ns()
230 if (clock_gettime(CLOCK_MONOTONIC, &ts))
232 fprintf(stderr,
"ERROR calling clock_gettime\n");
235 return (int64_t)ts.tv_sec * 1000000000 + (int64_t)ts.tv_nsec;
247static double sign(
double x)
249 return x > 0 ? 1.0 : (x < 0 ? -1.0 : 0.0);
265static long getValueFromStatus(
const std::string &fieldName)
267 std::ifstream status(
"/proc/self/status");
269 while (std::getline(status, line))
271 if (line.find(fieldName) == 0)
277 sscanf(line.c_str(),
"%*s %ld %3s", &value, unit);
279 unit[
sizeof(unit) - 1] =
'\0';
281 if (strcmp(unit,
"kB") == 0)
298static void printMemoryUsage(
const std::string &label)
300 const double mb = 1024.0 * 1024.0;
302 long vmSize = getValueFromStatus(
"VmSize:");
303 long vmRSS = getValueFromStatus(
"VmRSS:");
304 long vmData = getValueFromStatus(
"VmData:");
305 long vmStk = getValueFromStatus(
"VmStk:");
307 std::cout <<
"\n=== " << label <<
" ===\n"
308 << std::fixed << std::setprecision(2)
309 <<
"Virtual Memory Size: " << vmSize / mb <<
" MB\n"
310 <<
"Resident Set Size: " << vmRSS / mb <<
" MB\n"
311 <<
"Data Segment Size: " << vmData / mb <<
" MB\n"
312 <<
"Stack Size: " << vmStk / mb <<
" MB\n"
constexpr size_t MAX_IMAGE_SIZE
Maximum size for image data buffer.
camera_mode
Camera operation modes for the VIO system.
@ STEREO_LEFT_ONLY
Stereo setup with only left camera active.
@ MONO
Single camera mode.
@ UNKNOWN
Unknown or invalid camera mode.
@ STEREO_RIGHT_ONLY
Stereo setup with only right camera active.
@ STEREO
Stereo camera mode (both cameras active)
Camera information and calibration data.
char name[128]
Camera name identifier.
bool is_occluded_on_takeoff
Flag indicating if camera is occluded on takeoff.
int width
Image width in pixels.
char tracking_name[128]
Name used for tracking operations.
char preview_name[128]
Name used for preview/display.
int height
Image height in pixels.
camera_mode mode
Camera operation mode.
size_t cam_id
Unique camera identifier.
bool is_fisheye
Flag indicating if camera uses fisheye lens.
Eigen::Matrix< double, 8, 1 > cam_calib_intrinsic
Camera intrinsic calibration parameters.
Eigen::Matrix< double, 7, 1 > cam_wrt_imu
Camera pose relative to IMU (quaternion + position)
Base packet structure for image data fed to trackers.
std::vector< size_t > tracker_ids
Vector of tracker IDs per camera, matching order of images + masks.
int64_t timestamp_ns
Timestamp of image in nanoseconds.
std::vector< cv::Mat > masks
Vector of masks denoting regions of non-interest, in order matching ids vector Mask regions with val ...
std::vector< cv::Mat > images
Vector of images to track across, in order matching ids vector.