tools: so nguon z tren doc (G3) -- vslam_vo_bench (F2M RTAB-Map tren IR+depth, hang tham chieu ds*sin(pitch) bang GravityAlign, num IMU Hz/bias/truot/nhieu IR), slope_eval/slope_fuse/slope_summary/slope_bakeoff.sh (3 muc giong that, DM-VIO ngoai repo); vslam_vsr_export them bias/nhieu IR; vslam_record --gl-headlight/--gl-ambient
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// vslam_vsr_export --in X.vsr --out DIR [--robot robot.yaml]
|
||||
// [--imu-hz 0] [--imu-offset-ms 0]
|
||||
// [--gyro-noise 0] [--accel-noise 0] [--seed 1]
|
||||
// [--accel-bias x,y,z] [--gyro-bias x,y,z] [--ir-noise 0]
|
||||
//
|
||||
// Ra (DM-VIO doc theo src/dso/util/DatasetReader.h):
|
||||
// DIR/cam0/images/<ns>.png anh IR 8 bit. DM-VIO ghep anh voi times.txt
|
||||
@@ -28,6 +29,8 @@
|
||||
// --imu-offset-ms D CONG D ms vao stamp IMU: lech dong ho camera-IMU ma
|
||||
// DM-VIO khong tu uoc luong
|
||||
// --gyro-noise S, --accel-noise S them nhieu trang (sigma moi mau)
|
||||
// --accel-bias / --gyro-bias x,y,z cong bias co dinh (m/s^2, rad/s)
|
||||
// --ir-noise S nhieu Gauss tren anh IR (muc xam)
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -120,7 +123,8 @@ ImuS Lerp(const ImuS& a, const ImuS& b, int64_t t) {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string in, out, robot_yaml;
|
||||
double imu_hz = 0.0, offset_ms = 0.0, gyro_noise = 0.0, accel_noise = 0.0;
|
||||
double imu_hz = 0.0, offset_ms = 0.0, gyro_noise = 0.0, accel_noise = 0.0, ir_noise = 0.0;
|
||||
double accel_bias[3] = {0, 0, 0}, gyro_bias[3] = {0, 0, 0};
|
||||
// Nhieu SAN co trong ban ghi (sigma moi mau) -- de ghi mat do nhieu dung vao
|
||||
// imu_noise.yaml. vslam_record ghi chung vao header cua kich ban doc; am =
|
||||
// chua biet, lay tu header.
|
||||
@@ -139,6 +143,14 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--sim-gyro-sigma") sim_gyro_sigma = std::atof(next().c_str());
|
||||
else if (a == "--sim-accel-sigma") sim_accel_sigma = std::atof(next().c_str());
|
||||
else if (a == "--seed") seed = static_cast<uint32_t>(std::atoi(next().c_str()));
|
||||
else if (a == "--ir-noise") ir_noise = std::atof(next().c_str());
|
||||
else if (a == "--accel-bias" || a == "--gyro-bias") {
|
||||
double* v = a == "--accel-bias" ? accel_bias : gyro_bias;
|
||||
if (std::sscanf(next().c_str(), "%lf,%lf,%lf", &v[0], &v[1], &v[2]) != 3) {
|
||||
std::fprintf(stderr, "%s can x,y,z\n", a.c_str());
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::fprintf(stderr, "tham so la: %s (xem dau file)\n", a.c_str());
|
||||
return 2;
|
||||
@@ -259,6 +271,8 @@ int main(int argc, char** argv) {
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
if (gyro_noise > 0.0) s.w[k] += gyro_noise * n01(rng);
|
||||
if (accel_noise > 0.0) s.a[k] += accel_noise * n01(rng);
|
||||
s.w[k] += gyro_bias[k];
|
||||
s.a[k] += accel_bias[k];
|
||||
}
|
||||
q.push_back(s);
|
||||
}
|
||||
@@ -283,10 +297,21 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
FILE* ft = std::fopen((out + "/cam0/times.txt").c_str(), "w");
|
||||
std::mt19937 rng_img(seed + 7); // rieng: doi --ir-noise khong doi nhieu IMU
|
||||
std::vector<uint8_t> noisy;
|
||||
for (const Frame* f : used) {
|
||||
char name[64];
|
||||
std::snprintf(name, sizeof(name), "/cam0/images/%019lld.png", static_cast<long long>(f->t));
|
||||
const cv::Mat m(f->h, f->w, CV_8UC1, const_cast<uint8_t*>(f->px.data()));
|
||||
const uint8_t* px = f->px.data();
|
||||
if (ir_noise > 0.0) {
|
||||
noisy.resize(f->px.size());
|
||||
for (size_t i = 0; i < noisy.size(); ++i) {
|
||||
const double v = f->px[i] + ir_noise * n01(rng_img);
|
||||
noisy[i] = static_cast<uint8_t>(std::min(255.0, std::max(0.0, std::round(v))));
|
||||
}
|
||||
px = noisy.data();
|
||||
}
|
||||
const cv::Mat m(f->h, f->w, CV_8UC1, const_cast<uint8_t*>(px));
|
||||
cv::imwrite(out + name, m);
|
||||
std::fprintf(ft, "%lld %.9f\n", static_cast<long long>(f->t), f->t * 1e-9);
|
||||
}
|
||||
@@ -372,10 +397,12 @@ int main(int argc, char** argv) {
|
||||
std::fprintf(fj,
|
||||
"{\"in\":\"%s\",\"robot\":\"%s\",\"images\":%zu,\"imu_src_hz\":%.3f,"
|
||||
"\"imu_out_hz\":%.3f,\"imu_offset_ms\":%.3f,\"gyro_noise\":%.3g,"
|
||||
"\"accel_noise\":%.3g,\"seed\":%u,\"fx\":%.4f,\"fy\":%.4f,\"cx\":%.4f,"
|
||||
"\"accel_noise\":%.3g,\"accel_bias\":[%g,%g,%g],\"gyro_bias\":[%g,%g,%g],"
|
||||
"\"ir_noise\":%.3g,\"seed\":%u,\"fx\":%.4f,\"fy\":%.4f,\"cx\":%.4f,"
|
||||
"\"cy\":%.4f,\"width\":%d,\"height\":%d}\n",
|
||||
in.c_str(), robot_yaml.c_str(), used.size(), src_hz, out_hz, offset_ms,
|
||||
gyro_noise, accel_noise, seed, fx, fy, cx, cy, W, H);
|
||||
gyro_noise, accel_noise, accel_bias[0], accel_bias[1], accel_bias[2], gyro_bias[0],
|
||||
gyro_bias[1], gyro_bias[2], ir_noise, seed, fx, fy, cx, cy, W, H);
|
||||
std::fclose(fj);
|
||||
|
||||
std::printf("xuat %zu anh %dx%d, %zu mau IMU (%.1f Hz -> %.1f Hz, lech %.1f ms), %zu su that "
|
||||
|
||||
Reference in New Issue
Block a user