diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e2a760..8e6d546 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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) diff --git a/README.md b/README.md index 82a1077..9c25757 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 9496527..72e2487 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; @@ -208,7 +213,7 @@ int main(int argc, char **argv) { "fov value.", cxxopts::value(), "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(), "long_min,long_max,lat_min,lat_max (radians)") ; @@ -224,7 +229,7 @@ int main(int argc, char **argv) { "fov value.", cxxopts::value(), "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(), "longitude_min,longitude_max,latitude_min,latitude_max") ("rotation", "Specify a rotation", cxxopts::value()->default_value("0.0"), "pan, pitch, roll (degrees)")