Skip to content

Commit

Permalink
Remove non-essential packages from openglgt: removed progress bars, c…
Browse files Browse the repository at this point in the history
…olormap visualizers, unused fast_obj package
  • Loading branch information
araistrick authored and pvl-bot committed Aug 23, 2024
1 parent 7818df2 commit 9732bae
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 308 deletions.
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@
[submodule "infinigen/datagen/customgt/dependencies/cnpy"]
path = infinigen/datagen/customgt/dependencies/cnpy
url = https://github.com/rogersce/cnpy.git
[submodule "infinigen/datagen/customgt/dependencies/indicators"]
path = infinigen/datagen/customgt/dependencies/indicators
url = https://github.com/p-ranav/indicators.git
[submodule "infinigen/datagen/customgt/dependencies/tinycolormap"]
path = infinigen/datagen/customgt/dependencies/tinycolormap
url = https://github.com/yuki-koyama/tinycolormap.git
[submodule "infinigen/datagen/customgt/dependencies/glm"]
path = infinigen/datagen/customgt/dependencies/glm
url = https://github.com/g-truc/glm.git
[submodule "infinigen/datagen/customgt/dependencies/fast_obj"]
path = infinigen/datagen/customgt/dependencies/fast_obj
url = https://github.com/thisistherk/fast_obj.git
[submodule "infinigen/datagen/customgt/dependencies/json"]
path = infinigen/datagen/customgt/dependencies/json
url = https://github.com/nlohmann/json.git
Expand Down
7 changes: 1 addition & 6 deletions infinigen/datagen/customgt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ add_definitions(-D GLM_ENABLE_EXPERIMENTAL)
add_definitions(-D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR})
include_directories(/usr/include/) # on linux
include_directories(dependencies) # for cnpy
include_directories(dependencies/indicators/include)
include_directories(dependencies/argparse/include)
include_directories(dependencies/eigen)
include_directories(dependencies/tinycolormap/include)
include_directories(dependencies/glm)
include_directories(dependencies/json/single_include)
include_directories(dependencies/glad/include)
include_directories(dependencies/scharstein_flow_viz)

add_subdirectory(dependencies/cnpy)
add_subdirectory(dependencies/fast_obj)
add_subdirectory(dependencies/tinycolormap)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -49,7 +44,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
link_libraries(stdc++fs)
endif()

add_executable(customgt ${ADJACENT_SRC_FILES} dependencies/scharstein_flow_viz/colorcode.cpp dependencies/fast_obj/fast_obj.h dependencies/fast_obj/fast_obj.c dependencies/glad/src/glad.c dependencies/glad/src/glad_egl.c)
add_executable(customgt ${ADJACENT_SRC_FILES} dependencies/glad/src/glad.c dependencies/glad/src/glad_egl.c)

set_property(TARGET customgt PROPERTY CXX_STANDARD 17)

Expand Down
1 change: 0 additions & 1 deletion infinigen/datagen/customgt/dependencies/fast_obj
Submodule fast_obj deleted from 85778d
1 change: 0 additions & 1 deletion infinigen/datagen/customgt/dependencies/indicators
Submodule indicators deleted from a5bc05

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion infinigen/datagen/customgt/dependencies/tinycolormap
Submodule tinycolormap deleted from 67198d
2 changes: 1 addition & 1 deletion infinigen/datagen/customgt/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "io.hpp"
#include "utils.hpp"
#include "cnpy/cnpy.h"
#include "colorcode.h"

#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb/stb_image_write.h"

Expand Down
3 changes: 0 additions & 3 deletions infinigen/datagen/customgt/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include <glad/glad.h>
#include <Eigen/Dense>
#include <unsupported/Eigen/CXX11/Tensor>
#include <tinycolormap.hpp>
typedef tinycolormap::ColormapType clrmap;
#include <indicators/progress_bar.hpp>
#include "cnpy/cnpy.h"
#include <array>

Expand Down
21 changes: 5 additions & 16 deletions infinigen/datagen/customgt/load_blender_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@

#include <random>
#include <iostream>
#include <functional> //without .h
#include <indicators/progress_bar.hpp>
#include <functional>
#include <regex>
#include <unordered_map>
#include <unordered_set>

#include "string_tools.hpp"
#include "load_blender_mesh.hpp"
#include "buffer_arrays.hpp"

using json = nlohmann::json;
using namespace indicators;
using namespace indicators::option;

auto parse_json(const fs::path json_path){
const json data = json::parse(std::ifstream(json_path));
Expand All @@ -38,16 +36,6 @@ std::shared_ptr<BaseBlenderObject> load_blender_mesh(const fs::path src_json_pat

// Progress bar
static int object_idx = 0;
static ProgressBar bar{
BarWidth{20}, Start{"["}, End{"]"},
ShowElapsedTime{true}, ShowRemainingTime{true},
ForegroundColor{Color::blue},
FontStyles{std::vector<FontStyle>{FontStyle::bold}}
};
if (object_idx == 0){
bar.set_option(PrefixText{truncate(std::string("Loading..."), 20)});
bar.set_progress(0);
}

static std::unordered_map<std::string, npz> npz_lookup;

Expand Down Expand Up @@ -77,7 +65,8 @@ std::shared_ptr<BaseBlenderObject> load_blender_mesh(const fs::path src_json_pat
const npz &current_npz = npz_lookup.at(current_npz_path.string());
current_buf = BufferArrays(current_npz, current_mesh_id, current_obj.type);

bar.set_option(PrefixText{"Loading " + truncate(current_obj.name, 20) + " " + std::to_string(object_idx++) + "/" + std::to_string(info_lookup.size())});
std::cout << "Loading " << truncate(current_obj.name, 20) << " ";
std::cout << std::to_string(object_idx++) << "/" << std::to_string(info_lookup.size()) << std::endl;

if (next_info_lookup.count(current_mesh_id) > 0){
next_obj = next_info_lookup.at(current_mesh_id);
Expand All @@ -103,7 +92,7 @@ std::shared_ptr<BaseBlenderObject> load_blender_mesh(const fs::path src_json_pat
new_obj = std::shared_ptr<BaseBlenderObject>(new CurvesBlenderObject(current_buf, next_buf, all_instance_ids, current_obj));
current_buf.remove_instances(all_instance_ids);
}
bar.set_progress((object_idx * 100)/info_lookup.size());

RASSERT((object_idx == info_lookup.size()) == (it == info_lookup.end()));
return new_obj;
}
30 changes: 2 additions & 28 deletions infinigen/datagen/customgt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <chrono>
#include <regex>
#include <math.h>
#include <indicators/progress_bar.hpp>
#include <unsupported/Eigen/CXX11/Tensor>
#include "shader.hpp"
#include "blender_object.hpp"
Expand Down Expand Up @@ -367,11 +366,8 @@ int main(int argc, char *argv[]) {
points_3d(o.y, o.x,k) = pixels[o.j+k];
depth(o.y, o.x) = pixels[o.j+2];
}
o.progressbar();
}
if (depth_only || !flow_only) {
auto depth_color = to_color_map(depth, 0.0, 0.90);
imwrite(output_dir / ("Depth_" + cd.frame_string + ".png"), depth_color);
save_npy(output_dir / ("Depth_" + cd.frame_string + ".npy"), depth);
}
if (!depth_only) {
Expand All @@ -387,10 +383,9 @@ int main(int argc, char *argv[]) {
for (int k=0; k<3; k++)
next_points_3d(o.y, o.x,k) = pixels[o.j+k];
}
o.progressbar();
}
flow3d = cd.project(next_points_3d) - cd.project(points_3d);
const auto flow_viz = compute_flow_viz(flow3d);

std::string output_png, output_npy;
if (flow_type == FLOW) {
output_png = "Flow3D_" + cd.frame_string + ".png";
Expand All @@ -409,7 +404,7 @@ int main(int argc, char *argv[]) {
output_npy = "InvPointTraj3D_" + cd.frame_string + ".npy";
}
else assert(0);
imwrite(output_dir / output_png, flow_viz);

save_npy(output_dir / output_npy, flow3d);
}
}
Expand All @@ -424,7 +419,6 @@ int main(int argc, char *argv[]) {
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Geometry Surface Normals")){
for (int k=0; k<3; k++)
geo_normals(o.y/2, o.x/2, k) += pixels[o.j+k];
o.progressbar();
}

Eigen::Tensor<unsigned char, 3> geo_normal_color(output_h, output_w, 3);
Expand All @@ -451,14 +445,8 @@ int main(int argc, char *argv[]) {
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying instance segmentation masks")){
for (int k=0; k<3; k++)
instance_seg(o.y, o.x, k) = pixels[o.j + k];
o.progressbar();
}
save_npy(output_dir / ("InstanceSegmentation_" + cd.frame_string + ".npy"), instance_seg);

Eigen::Tensor<long, 2> instance_seg_2d(buffer_height, buffer_width);
for (const loop_obj &o : image_iterator(buffer_width, buffer_height))
instance_seg_2d(o.y, o.x) = long(instance_seg(o.y, o.x, 0) % 1000) + 1000 * long(instance_seg(o.y, o.x, 1) % 1000) + 1000000 * long(instance_seg(o.y, o.x, 2) % 1000);
imwrite(output_dir / ("InstanceSegmentation_" + cd.frame_string + ".png"), to_color_map(instance_seg_2d));
}

/*
Expand All @@ -470,10 +458,8 @@ int main(int argc, char *argv[]) {
object_seg.setZero();
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying object segmentation masks")){
object_seg(o.y, o.x) = pixels[o.j];
o.progressbar();
}
save_npy(output_dir / ("ObjectSegmentation_" + cd.frame_string + ".npy"), object_seg);
imwrite(output_dir / ("ObjectSegmentation_" + cd.frame_string + ".png"), to_color_map(object_seg.cast<long>()));
}

if (!flow_only && !depth_only) {
Expand All @@ -482,10 +468,8 @@ int main(int argc, char *argv[]) {
tag_seg.setZero();
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying tag segmentation mask")){
tag_seg(o.y, o.x) = pixels[o.j];
o.progressbar();
}
save_npy(output_dir / ("TagSegmentation_" + cd.frame_string + ".npy"), tag_seg);
imwrite(output_dir / ("TagSegmentation_" + cd.frame_string + ".png"), to_color_map(tag_seg.cast<long>()));
}


Expand All @@ -500,7 +484,6 @@ int main(int argc, char *argv[]) {
// for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying face ids from first frame")){
// for (int k=0; k<3; k++)
// faceids(0, o.y, o.x, k) = pixels[o.j+k];
// o.progressbar();
// }
// }
// glBindFramebuffer(GL_FRAMEBUFFER, cd.framebuffer_next_faceids);
Expand All @@ -509,7 +492,6 @@ int main(int argc, char *argv[]) {
// for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying face ids from second frame")){
// for (int k=0; k<3; k++)
// faceids(1, o.y, o.x, k) = pixels[o.j+k];
// o.progressbar();
// }
// }
// Eigen::Array<unsigned char, -1, -1> flow_occlusion(buffer_height, buffer_width);
Expand All @@ -532,7 +514,6 @@ int main(int argc, char *argv[]) {
// }
// }
// flow_occlusion(o.y, o.x) = ((unsigned char)match_exists) * 255;
// o.progressbar();
// }
// imwrite(output_dir / ("Flow3DMask_" + cd.frame_string + ".png"), flow_occlusion);
// }
Expand All @@ -544,21 +525,15 @@ int main(int argc, char *argv[]) {
face_size.setZero();
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying Face-Sizes (in m^2)")){
face_size(o.y/2, o.x/2) = pixels[o.j]/4;
o.progressbar();
}
auto face_size_color = to_color_map(face_size, 0, 0.5, 0);
imwrite(output_dir / ("FaceSizeCM" + cd.frame_string + ".png"), face_size_color);
// Reading/Writing the face size in pixels
read_buffer<float>(GL_COLOR_ATTACHMENT4, pixels, buffer_width, buffer_height);
auto pixel_size = Eigen::Tensor<double, 2>(output_h,output_w);
pixel_size.setZero();
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying Face-Sizes (in pixels)")){
pixel_size(o.y/2, o.x/2) = pixels[o.j]/4;
o.progressbar();
}
auto pixel_size_color = to_color_map(pixel_size, 0, 0.5, 0);
imwrite(output_dir / ("FaceSizePX" + cd.frame_string + ".png"), pixel_size_color);
*/

Expand All @@ -573,7 +548,6 @@ int main(int argc, char *argv[]) {
occlusion_boundaries.setZero();
for (const loop_obj &o : image_iterator(buffer_width, buffer_height, "Copying Occlusion Boundaries")){
occlusion_boundaries(o.y, o.x) = pixels[o.j+1]*255;
o.progressbar();
}
imwrite(output_dir / ("OcclusionBoundaries_" + cd.frame_string + ".png"), occlusion_boundaries);
}
Expand Down
Loading

0 comments on commit 9732bae

Please sign in to comment.