Skip to content

Commit

Permalink
Version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcourteaux committed Oct 26, 2023
1 parent 446b5cc commit be77725
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ jobs:
- name: Cache vcpkg libraries
if: runner.os == 'Windows'
uses: actions/cache@v3
env:
cache-name: cache-vcpkg-packages
with:
path: |
C:/vcpkg/installed
C:/vcpkg/vcpkg
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('C:/vcpkg/**/vcpkg.json') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install libjpeg-turbo (Windows)
Expand Down
103 changes: 71 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,98 @@ git submodule update

```
Usage:
./reproject [OPTION...]
./bin/reproject [OPTION...]
Color processing options:
--exposure EV Exposure compensation in stops (EV) to brigthen or
--exposure EV Exposure compensation in stops (EV) to brigthen or
darken the pictures. (default: 0.0)
--reinhard max Use reinhard tonemapping with given maximum value
(after exposure processing) on the output images.
--reinhard max Use reinhard tonemapping with given maximum value
(after exposure processing) on the output images.
(default: 1.0)
Filter files options:
--filter-prefix prefix Only include files starting with (default:
"")
--filter-suffix suffix Only include files ending with (default: "")
Input optics.
These are usually inferred by the config JSONs. When specifying
--no-configs, lens information needs to be passed through these
command line options options:
--i-rectilinear focal_length,sensor_width
Input rectilinear images with given
focal_length,sensor_width tuple.
--i-equisolid focal_length,sensor_width,fov
Input equisolid images with given
focal_length,sensor_width,fov tuple.
--i-equidistant fov Input equidistant images with given fov
value.
--i-equirectangular long_min,long_max,lat_min,lat_max (radians)
Input equirectangular images with given
longitude min,max and latitude min,max
value or 'full'.
Input/output options:
--input-cfg json-file Input JSON file containing lens and camera
settings of the input images.
--output-cfg json-file Output JSON file containing lens and camera
settings of the input images.
-i, --input-dir file Input directory containing images to
reproject.
--single file A single input file to convert.
-o, --output-dir file Output directory to put the reprojected
images.
--exr Output EXR files. Color and depth.
--png Output PNG files. Color only.
--input-cfg json-file Input JSON file containing lens and camera
settings of the input images.
--output-cfg json-file Output JSON file containing lens and camera
settings of the output images.
--no-configs width,height
Work without reading and writing config
files. Requires you to specify the input
lens through the input-optics flags
(staring with -i-...) and the expected
resolution of the input images here.
-i, --input-dir file Input directory containing images to
reproject.
--single file A single input file to convert.
-o, --output-dir file Output directory to put the reprojected
images.
--exr Output EXR files. Color and depth.
--png Output PNG files. Color only.
Output optics options:
--no-reproject Do not reproject at all.
--rectilinear focal_length,sensor_width
Output rectilinear images with given
Output rectilinear images with given
focal_length,sensor_width tuple.
--equisolid focal_length,sensor_width,fov
Output equisolid images with given
Output equisolid images with given
focal_length,sensor_width,fov tuple.
--equidistant fov Output equidistant images with given fov
--equidistant fov Output equidistant images with given fov
value.
--equirectangular longitude_min,longitude_max,latitude_min,latitude_max
Output equirectangular images with given
longitude min,max and latitude min,max
value or 'full'.
--rotation pan, pitch, roll (degrees)
Specify a rotation (default: 0.0)
Runtime options:
-j, --parallel threads Number of parallel images to process. (default:
--skip-if-exists Skip if the output file already exists.
-j, --parallel threads Number of parallel images to process. (default:
1)
--dry-run Do not actually reproject images. Only produce
--dry-run Do not actually reproject images. Only produce
config.
-h, --help Show help
Sampling options:
-s, --samples number Number of samples per dimension for interpolating
(default: 1)
--nn Nearest neighbor interpolation
--bl Bilinear interpolation
--bc Bicubic interpolation (default)
--scale percentage Output scale, as a fraction of the input size. It
is recommended to increase --samples to prevent
aliassing in case you are downscaling. Eg:
--scale 0.5 --samples 2 or --scale 0.33334
--samples 3 or --scale 0.25 --samples 4. Final
dimensions are rounded towards zero. (default:
1.0)
-s, --samples number Number of samples per dimension for
interpolating (default: 1)
--nn Nearest neighbor interpolation
--bl Bilinear interpolation
--bc Bicubic interpolation (default)
--scale percentage Output scale, as a fraction of the input
size. It is recommended to increase
--samples to prevent aliassing in case you
are downscaling. Eg: --scale 0.5 --samples
2 or --scale 0.33334 --samples 3 or --scale
0.25 --samples 4. Final dimensions are
rounded towards zero. (default: 1.0)
--output-resolution width,height
A fixed output resolution. Overwrites the
behavior of the 'scale' parameter.
```

### Configuration JSON
Expand Down
43 changes: 24 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,36 @@ int parse_equirectangular(const std::string &lstr, float res_x, float res_y,
reproject::LensInfo &li) {
auto &lier = li.equirectangular;
li.type = reproject::EQUIRECTANGULAR;
int argidx = 0;
for (size_t b = 0, e = lstr.find(",");;
b = e + 1, e = lstr.find(",", e + 1)) {
std::string arg = lstr.substr(b, e - b);
std::printf("argidx: %d, arg: %s, b: %zu, e: %zu\n", argidx, arg.c_str(), b,
e);
double fa = std::atof(arg.c_str());
// clang-format off
if (lstr == "full") {
lier.longitude_min = -M_PI;
lier.longitude_max = M_PI;
lier.latitude_min = -M_PI * 0.5f;
lier.latitude_max = M_PI * 0.5f;
} else {
int argidx = 0;
for (size_t b = 0, e = lstr.find(",");;
b = e + 1, e = lstr.find(",", e + 1)) {
std::string arg = lstr.substr(b, e - b);
double fa = std::atof(arg.c_str());
// clang-format off
switch (argidx) {
case 0: lier.longitude_min = fa; break;
case 1: lier.longitude_max = fa; break;
case 2: lier.latitude_min = fa; break;
case 3: lier.latitude_max = fa; break;
}
// clang-format on
}

argidx++;
if (e == std::string::npos) {
break;
argidx++;
if (e == std::string::npos) {
break;
}
}
if (argidx != 4) {
std::printf("Error: expected 4 arguments for equirectangular, got %d.\n",
argidx);
return 1;
}
}
if (argidx != 4) {
std::printf("Error: expected 4 arguments for equirectangular, got %d.\n",
argidx);
return 1;
}
li.sensor_width = li.sensor_height = 0;
return 0;
Expand Down Expand Up @@ -208,7 +213,7 @@ int main(int argc, char **argv) {
"fov value.",
cxxopts::value<std::string>(), "fov")
("i-equirectangular", "Input equirectangular images with given longitude "
"min,max and latitude min,max value.",
"min,max and latitude min,max value or 'full'.",
cxxopts::value<std::string>(), "long_min,long_max,lat_min,lat_max (radians)")
;

Expand All @@ -224,7 +229,7 @@ int main(int argc, char **argv) {
"fov value.",
cxxopts::value<std::string>(), "fov")
("equirectangular", "Output equirectangular images with given longitude "
"min,max and latitude min,max value.",
"min,max and latitude min,max value or 'full'.",
cxxopts::value<std::string>(), "longitude_min,longitude_max,latitude_min,latitude_max")
("rotation", "Specify a rotation",
cxxopts::value<std::string>()->default_value("0.0"), "pan, pitch, roll (degrees)")
Expand Down

0 comments on commit be77725

Please sign in to comment.