MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / renderViewAndDepthOnViewerThread

Function renderViewAndDepthOnViewerThread

src/python/lfs/py_rendering.cpp:620–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618 }
619
620 [[nodiscard]] std::optional<std::pair<core::Tensor, core::Tensor>> renderViewAndDepthOnViewerThread(
621 const glm::mat3& rotation,
622 const glm::vec3& translation,
623 const int width,
624 const int height,
625 const float fov_degrees,
626 const bool expected_depth) {
627 if (width <= 0 || height <= 0 || !std::isfinite(fov_degrees) || fov_degrees <= 0.0f) {
628 return std::nullopt;
629 }
630 auto* const viewer = get_visualizer();
631 auto* const rendering_manager = viewer ? viewer->getRenderingManager() : nullptr;
632 auto* const scene_manager = viewer ? viewer->getSceneManager() : nullptr;
633 if (!rendering_manager || !scene_manager) {
634 return std::nullopt;
635 }
636 auto rgbd = rendering_manager->renderPreviewImageAndDepth(
637 scene_manager,
638 rotation,
639 translation,
640 lfs::rendering::vFovToFocalLength(fov_degrees),
641 width,
642 height,
643 expected_depth,
644 std::nullopt);
645 if (!rgbd.image || !rgbd.depth || !rgbd.image->is_valid() || !rgbd.depth->is_valid()) {
646 return std::nullopt;
647 }
648 auto image = *rgbd.image;
649 auto depth = *rgbd.depth;
650 if (image.device() != core::Device::CPU) {
651 image = image.cpu();
652 }
653 if (depth.device() != core::Device::CPU) {
654 depth = depth.cpu();
655 }
656 return std::make_pair(image.contiguous(), depth.contiguous());
657 }
658
659 [[nodiscard]] std::optional<std::pair<core::Tensor, core::Tensor>> renderViewAndDepthThreadSafe(
660 const glm::mat3& rotation,

Callers 1

Calls 9

get_visualizerFunction · 0.85
vFovToFocalLengthFunction · 0.85
getRenderingManagerMethod · 0.45
getSceneManagerMethod · 0.45
is_validMethod · 0.45
deviceMethod · 0.45
cpuMethod · 0.45
contiguousMethod · 0.45

Tested by

no test coverage detected