Spaces:
Running
on
Zero
Running
on
Zero
File size: 5,752 Bytes
5f9d349 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
/*
* Copyright (C) 2020, Inria
* GRAPHDECO research group, https://team.inria.fr/graphdeco
* All rights reserved.
*
* This software is free for non-commercial, research and evaluation use
* under the terms of the LICENSE.md file.
*
* For inquiries contact [email protected] and/or [email protected]
*/
#pragma once
# include "Config.hpp"
# include <core/system/Config.hpp>
# include <core/graphics/Mesh.hpp>
# include <core/view/ViewBase.hpp>
# include "core/scene/BasicIBRScene.hpp"
# include <core/renderer/CopyRenderer.hpp>
# include <projects/ulr/renderer/ULRV2Renderer.hpp>
# include <core/renderer/PoissonRenderer.hpp>
namespace sibr {
/** View associated to ULRRenderer v2, providing interface and options. */
class SIBR_EXP_ULR_EXPORT ULRV2View : public sibr::ViewBase
{
SIBR_CLASS_PTR(ULRV2View);
/** Camera selection mode. */
enum class RenderMode { NORMAL = 0, ONLY_ONE_CAM = 1, LEAVE_ONE_OUT = 2 };
public:
/** Constructor.
*\param ibrScene the scene
*\param render_w rendering width
*\param render_h rendering height
**/
ULRV2View( const sibr::BasicIBRScene::Ptr& ibrScene, uint render_w, uint render_h );
/** Destructor. */
~ULRV2View();
/** Render using the ULR algorithm.
*\param dst destination target
*\param eye novel viewpoint
**/
virtual void onRenderIBR( sibr::IRenderTarget& dst, const sibr::Camera& eye );
/** Update state absed on user inputs.
*\param input the view input
**/
virtual void onUpdate(Input& input);
/** Display GUI. */
virtual void onGUI() override;
/** Select input cameras to use for rendering.
*\param eye the current viewpoint
*\return a list of camera indices.
**/
virtual std::vector<uint> chosen_cameras(const sibr::Camera& eye) ;
/** Select input cameras to use for rendering, based only on distance.
*\param eye the current viewpoint
*\return a list of camera indices.
**/
virtual std::vector<uint> chosen_camerasNew(const sibr::Camera& eye);
/** Select input cameras to use for rendering.
*\param eye the current viewpoint
*\return a list of camera indices.
**/
virtual std::vector<uint> chosen_cameras_angdist(const sibr::Camera& eye);
/** Set the altMesh and use instead of scene proxy.
*\param m mesh to use
**/
void altMesh(std::shared_ptr<sibr::Mesh> m) { _altMesh = m; }
/** Toggle occlusion testing.
*\param val should occlusion testing be performed
*/
void doOccl(bool val) { _ulr->doOccl(val); }
/** \return a pointer to the alt mesh if it exists */
std::shared_ptr<sibr::Mesh> altMesh() { return _altMesh; }
/** Set the number of cmaeras to select for blending.
*\param dist number of cameras for the distance criterion
*\param angle number of cameras for the angle criterion
**/
void setNumBlend(short int dist, short int angle);
/** Set the input RGBD textures.
*\param iRTs the new textures to use.
*/
void inputRTs(const std::vector<std::shared_ptr<RenderTargetRGBA32F> >& iRTs) { _inputRTs = iRTs;}
/** Set the masks for ignoring some regions of the input images.
*\param masks the new masks
**/
void setMasks( const std::vector<RenderTargetLum::Ptr>& masks );
/** Load masks from disk.
*\param ibrScene the scene
*\param w resolution width
*\param h resolution height
*\param maskDir masks directory path
*\param preFileName mask files prefix
*\param postFileName mask files suffix and extension
*/
void loadMasks(
const sibr::BasicIBRScene::Ptr& ibrScene, int w, int h,
const std::string& maskDir = "",
const std::string& preFileName = "",
const std::string& postFileName = ""
);
/** Set the camera selection mode.
*\param mode the new mode.
*/
void setRenderMode(RenderMode mode) { _renderMode = mode; }
/** \return the camera selection mode. */
RenderMode getRenderMode() const { return _renderMode; }
/** Set the view ID when in single view mode.
*\param id the camera id to use
*/
void setSingleViewId(int id) { _singleCamId = id; }
/** \return the current selected camera ID in single view mode. */
int getSingleViewId(void) const { return _singleCamId; }
/** Toggle poisson blending.
*\param val if true, Poisson blending is disabled.
*/
void noPoissonBlend(bool val) { _noPoissonBlend = val; }
/** \return true if pOisson blending is disabled. */
bool noPoissonBlend() const { return _noPoissonBlend; }
/** Compute soft visibility map.
*\param depthMap view depth map
*\param out will contain the soft visibility map
*/
void computeVisibilityMap(const sibr::ImageL32F & depthMap, sibr::ImageRGBA & out);
/** \return a pointer to the scene */
const std::shared_ptr<sibr::BasicIBRScene> & getScene() const { return _scene; }
public:
ULRV2Renderer::Ptr _ulr; ///< ULRV2 renderer.
PoissonRenderer::Ptr _poisson; ///< Poisson filling renderer.
protected:
std::shared_ptr<sibr::BasicIBRScene> _scene; ///< the current scene.
std::shared_ptr<sibr::Mesh> _altMesh; ///< For the cases when using a different mesh than the scene
int _numDistUlr, _numAnglUlr; ///< Number of cameras to select for each criterion.
std::vector<std::shared_ptr<RenderTargetRGBA32F> > _inputRTs; ///< input RTs -- usually RGB but can be alpha or other
bool _noPoissonBlend = false; ///< Runtime status of the poisson blend.
RenderTargetRGBA::Ptr _blendRT; ///< ULR destination RT.
RenderTargetRGBA::Ptr _poissonRT; ///< Poisson filling destination RT.
RenderMode _renderMode; ///< Current camera selection mode.
int _singleCamId; ///< Selected camera in single view mode.
bool testAltlULRShader; ///< TT: to switch with alternate shader with tab
};
} /*namespace sibr*/
|