Visual Servoing Platform  version 3.6.1 under development (2024-11-21)

#include <visp3/ar/vpPanda3DCommonFilters.h>

+ Inheritance diagram for vpPanda3DCanny:

Public Member Functions

 vpPanda3DCanny (const std::string &name, std::shared_ptr< vpPanda3DBaseRenderer > inputRenderer, bool isOutput, float edgeThreshold)
 
FrameBufferProperties getBufferProperties () const VP_OVERRIDE
 
void getRender (vpImage< vpRGBf > &I) const
 
void setEdgeThreshold (float edgeThreshold)
 
bool isRendering3DScene () const VP_OVERRIDE
 
GraphicsOutput * getMainOutputBuffer () VP_OVERRIDE
 
void afterFrameRendered () VP_OVERRIDE
 
virtual void initFramework ()
 
virtual void initFromParent (std::shared_ptr< PandaFramework > framework, PointerTo< WindowFramework > window)
 
virtual void initFromParent (const vpPanda3DBaseRenderer &renderer)
 
virtual void beforeFrameRendered ()
 
virtual void renderFrame ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 
NodePath & getRenderRoot ()
 
int getRenderOrder () const
 
void setRenderOrder (int order)
 
virtual void setCameraPose (const vpHomogeneousMatrix &wTc)
 
virtual vpHomogeneousMatrix getCameraPose ()
 
virtual void setNodePose (const std::string &name, const vpHomogeneousMatrix &wTo)
 
virtual void setNodePose (NodePath &object, const vpHomogeneousMatrix &wTo)
 
virtual vpHomogeneousMatrix getNodePose (const std::string &name)
 
virtual vpHomogeneousMatrix getNodePose (NodePath &object)
 
void computeNearAndFarPlanesFromNode (const std::string &name, float &near, float &far, bool fast)
 
NodePath loadObject (const std::string &nodeName, const std::string &modelPath)
 
virtual void addNodeToScene (const NodePath &object)
 
void setVerticalSyncEnabled (bool useVsync)
 
void setAbortOnPandaError (bool abort)
 
void enableDebugLog ()
 
void printStructure ()
 
virtual void enableSharedDepthBuffer (vpPanda3DBaseRenderer &sourceBuffer)
 

Static Public Member Functions

static vpColVector vispPointToPanda (const vpColVector &point)
 
static vpColVector vispVectorToPanda (const vpColVector &vec)
 

Protected Member Functions

void setupScene () VP_OVERRIDE
 
void setupCamera () VP_OVERRIDE
 
void setupRenderTarget () VP_OVERRIDE
 
void setRenderParameters (const vpPanda3DRenderParameters &params) VP_OVERRIDE
 
void getRenderBasic (vpImage< unsigned char > &I) const
 
void getRenderBasic (vpImage< vpRGBf > &I) const
 

Protected Attributes

std::shared_ptr< vpPanda3DBaseRendererm_inputRenderer
 
bool m_isOutput
 
std::string m_fragmentShader
 
PointerTo< Shader > m_shader
 
PointerTo< Texture > m_texture
 
PointerTo< GraphicsOutput > m_buffer
 
std::string m_name
 
int m_renderOrder
 
std::shared_ptr< PandaFramework > m_framework
 
PointerTo< WindowFramework > m_window
 
vpPanda3DRenderParameters m_renderParameters
 
NodePath m_renderRoot
 
PointerTo< Camera > m_camera
 
NodePath m_cameraPath
 
std::vector< GraphicsOutput * > m_buffers
 

Static Protected Attributes

static const char * FILTER_VERTEX_SHADER
 
static const vpHomogeneousMatrix VISP_T_PANDA
 
static const vpHomogeneousMatrix PANDA_T_VISP
 

Detailed Description

Implementation of canny filtering, using Sobel kernels.

The results of the canny are filtered based on a threshold value (defined between 0 and 255), checking whether there is enough gradient information. The output of this image is a floating RGB image containing:

  • In the red channel, the value of the convolution with the sobel horizontal kernel
  • In the green channel, the value of the convolution with the sobel vertical kernel
  • In the blue channel, the angle (in radians) of the edge normal.
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 87 of file vpPanda3DCommonFilters.h.

Constructor & Destructor Documentation

◆ vpPanda3DCanny()

vpPanda3DCanny::vpPanda3DCanny ( const std::string &  name,
std::shared_ptr< vpPanda3DBaseRenderer inputRenderer,
bool  isOutput,
float  edgeThreshold 
)

Definition at line 158 of file vpPanda3DCommonFilters.cpp.

Member Function Documentation

◆ addNodeToScene()

void vpPanda3DBaseRenderer::addNodeToScene ( const NodePath &  object)
virtualinherited

Add a node to the scene. Its pose is set as the identity matrix.

Parameters
object

Reimplemented in vpPanda3DRGBRenderer, and vpPanda3DRendererSet.

Definition at line 286 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::m_renderRoot, and vpPanda3DBaseRenderer::setNodePose().

◆ afterFrameRendered()

void vpPanda3DPostProcessFilter::afterFrameRendered ( )
inlinevirtualinherited

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 74 of file vpPanda3DPostProcessFilter.h.

References vpPanda3DBaseRenderer::afterFrameRendered().

◆ beforeFrameRendered()

virtual void vpPanda3DBaseRenderer::beforeFrameRendered ( )
inlinevirtualinherited

Reimplemented in vpPanda3DRendererSet.

Definition at line 77 of file vpPanda3DBaseRenderer.h.

Referenced by vpPanda3DBaseRenderer::renderFrame().

◆ computeNearAndFarPlanesFromNode()

void vpPanda3DBaseRenderer::computeNearAndFarPlanesFromNode ( const std::string &  name,
float &  near,
float &  far,
bool  fast 
)
inherited

Compute the near and far planes for the camera at the current pose, given a certain node/part of the graph.

The near clipping value will be set to the distance to the closest point of the object. The far clipping value will be set to the distance to farthest vertex of the object.

Warning
Depending on geometry complexity, this may be an expensive operation.
if the object lies partly behind the camera, the near plane value will be zero. If it fully behind, the far plane will also be zero. If these near/far values are used to update the rendering parameters of the camera, this may result in an invalid projection matrix.
Parameters
namename of the node that should be used to compute near and far values.
nearresulting near clipping plane distance
farresulting far clipping plane distance
fastWhether to use the axis align bounding box to compute the clipping planes. This is faster than reprojecting the full geometry in the camera frame

Definition at line 191 of file vpPanda3DBaseRenderer.cpp.

References vpException::badValue, vpException::fatalError, vpPanda3DBaseRenderer::getCameraPose(), vpPanda3DBaseRenderer::getNodePose(), vpHomogeneousMatrix::inverse(), vpPanda3DBaseRenderer::m_camera, vpPanda3DBaseRenderer::m_cameraPath, vpPanda3DBaseRenderer::m_renderRoot, vpException::notInitialized, and vpPanda3DBaseRenderer::PANDA_T_VISP.

◆ enableDebugLog()

void vpPanda3DBaseRenderer::enableDebugLog ( )
inherited

Definition at line 312 of file vpPanda3DBaseRenderer.cpp.

◆ enableSharedDepthBuffer()

void vpPanda3DBaseRenderer::enableSharedDepthBuffer ( vpPanda3DBaseRenderer sourceBuffer)
virtualinherited

◆ getBufferProperties()

FrameBufferProperties vpPanda3DCanny::getBufferProperties ( ) const
virtual

Implements vpPanda3DPostProcessFilter.

Definition at line 174 of file vpPanda3DCommonFilters.cpp.

◆ getCameraPose()

vpHomogeneousMatrix vpPanda3DBaseRenderer::getCameraPose ( )
virtualinherited

Retrieve the camera's pose, in the world frame. The pose is specified using the ViSP convention (Y-down right handed).

Reimplemented in vpPanda3DRendererSet.

Definition at line 150 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::getNodePose(), vpPanda3DBaseRenderer::m_camera, vpPanda3DBaseRenderer::m_cameraPath, and vpException::notInitialized.

Referenced by vpPanda3DBaseRenderer::computeNearAndFarPlanesFromNode().

◆ getMainOutputBuffer()

GraphicsOutput* vpPanda3DPostProcessFilter::getMainOutputBuffer ( )
inlinevirtualinherited

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 72 of file vpPanda3DPostProcessFilter.h.

◆ getName()

const std::string& vpPanda3DBaseRenderer::getName ( ) const
inlineinherited

Get the name of the renderer.

Returns
const std::string&

Definition at line 92 of file vpPanda3DBaseRenderer.h.

◆ getNodePose() [1/2]

vpHomogeneousMatrix vpPanda3DBaseRenderer::getNodePose ( const std::string &  name)
virtualinherited

Get the pose of a Panda node, in world frame in the ViSP convention (Y-down right handed).

Parameters
nameNode path to search for.
See also
setNodePose(const std::string &, const vpHomogeneousMatrix &) for more info
Returns
wTo, the pose of the object in world frame
Exceptions
ifno node can be found from the given path.

Reimplemented in vpPanda3DRendererSet.

Definition at line 173 of file vpPanda3DBaseRenderer.cpp.

References vpException::badValue, and vpPanda3DBaseRenderer::m_renderRoot.

Referenced by vpPanda3DBaseRenderer::computeNearAndFarPlanesFromNode(), and vpPanda3DBaseRenderer::getCameraPose().

◆ getNodePose() [2/2]

vpHomogeneousMatrix vpPanda3DBaseRenderer::getNodePose ( NodePath &  object)
virtualinherited

Get the pose of a Panda node, in world frame in the ViSP convention (Y-down right handed). This version of the method directly uses the Panda Nodepath.

Reimplemented in vpPanda3DRendererSet.

Definition at line 182 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::PANDA_T_VISP.

◆ getRender()

void vpPanda3DCanny::getRender ( vpImage< vpRGBf > &  I) const

◆ getRenderBasic() [1/2]

◆ getRenderBasic() [2/2]

◆ getRenderOrder()

int vpPanda3DBaseRenderer::getRenderOrder ( ) const
inlineinherited

Get the rendering order of this renderer. If a renderer A has a lower order value than B, it will be rendered before B. This is useful, if for instance, B is a postprocessing filter that depends on the result of B.

Returns
int

Definition at line 123 of file vpPanda3DBaseRenderer.h.

Referenced by vpPanda3DPostProcessFilter::vpPanda3DPostProcessFilter().

◆ getRenderRoot()

NodePath& vpPanda3DBaseRenderer::getRenderRoot ( )
inlineinherited

Get the scene root.

Definition at line 100 of file vpPanda3DBaseRenderer.h.

◆ initFramework()

void vpPanda3DBaseRenderer::initFramework ( )
virtualinherited

◆ initFromParent() [1/2]

void vpPanda3DBaseRenderer::initFromParent ( const vpPanda3DBaseRenderer renderer)
virtualinherited

◆ initFromParent() [2/2]

void vpPanda3DBaseRenderer::initFromParent ( std::shared_ptr< PandaFramework >  framework,
PointerTo< WindowFramework >  window 
)
virtualinherited

◆ isRendering3DScene()

bool vpPanda3DPostProcessFilter::isRendering3DScene ( ) const
inlinevirtualinherited

Returns true if this renderer process 3D data and its scene root can be interacted with.

This value could be false, if for instance it is redefined in a subclass that performs postprocessing on a texture.

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 67 of file vpPanda3DPostProcessFilter.h.

◆ loadObject()

NodePath vpPanda3DBaseRenderer::loadObject ( const std::string &  nodeName,
const std::string &  modelPath 
)
inherited

Load a 3D object. To load an .obj file, Panda3D must be compiled with assimp support.

Once loaded, the object will not be visible, it should be added to the scene.

Parameters
nodeNamethe name that will be used when inserting the node in the scene graph
modelPathPath to the model file
Returns
NodePath The NodePath containing the 3D model, which can now be added to the scene graph.

Definition at line 274 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::m_framework, and vpPanda3DBaseRenderer::m_window.

◆ printStructure()

void vpPanda3DBaseRenderer::printStructure ( )
inherited

Definition at line 330 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::m_renderRoot.

◆ renderFrame()

void vpPanda3DBaseRenderer::renderFrame ( )
virtualinherited

◆ setAbortOnPandaError()

void vpPanda3DBaseRenderer::setAbortOnPandaError ( bool  abort)
inherited

Set the behaviour when a Panda3D assertion fails. If abort is true, the program will stop. Otherwise, an error will be displayed in the console.

Parameters
abortwhether to abort (true) or display a message when an assertion fails.

Definition at line 302 of file vpPanda3DBaseRenderer.cpp.

◆ setCameraPose()

void vpPanda3DBaseRenderer::setCameraPose ( const vpHomogeneousMatrix wTc)
virtualinherited

Set the camera's pose. The pose is specified using the ViSP convention (Y-down right handed).

Parameters
wTcthe new pose of the camera, in world frame

Reimplemented in vpPanda3DRendererSet.

Definition at line 142 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::m_camera, vpPanda3DBaseRenderer::m_cameraPath, vpException::notInitialized, and vpPanda3DBaseRenderer::setNodePose().

◆ setEdgeThreshold()

void vpPanda3DCanny::setEdgeThreshold ( float  edgeThreshold)

Definition at line 168 of file vpPanda3DCommonFilters.cpp.

References vpPanda3DBaseRenderer::m_renderRoot.

◆ setName()

void vpPanda3DBaseRenderer::setName ( const std::string &  name)
inlineinherited

Definition at line 94 of file vpPanda3DBaseRenderer.h.

◆ setNodePose() [1/2]

void vpPanda3DBaseRenderer::setNodePose ( const std::string &  name,
const vpHomogeneousMatrix wTo 
)
virtualinherited

Set the pose of a node. This node can be any Panda object (light, mesh, camera). The pose is specified using the ViSP convention (Y-down right handed).

Parameters
nameNode path to search for, from the render root. This is the object that will be modified See https://docs.panda3d.org/1.10/python/programming/scene-graph/searching-scene-graph
wToPose of the object in the world frame
Exceptions
ifthe corresponding node cannot be found.

Reimplemented in vpPanda3DRendererSet.

Definition at line 158 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::m_renderRoot.

Referenced by vpPanda3DBaseRenderer::addNodeToScene(), vpPanda3DRGBRenderer::addNodeToScene(), and vpPanda3DBaseRenderer::setCameraPose().

◆ setNodePose() [2/2]

void vpPanda3DBaseRenderer::setNodePose ( NodePath &  object,
const vpHomogeneousMatrix wTo 
)
virtualinherited

Set the pose of a node. The pose is specified using the ViSP convention (Y-down right handed). This node can be any Panda object (light, mesh, camera).

Parameters
objectThe object for which to set the pose
wToPose of the object in the world frame

Reimplemented in vpPanda3DRendererSet.

Definition at line 164 of file vpPanda3DBaseRenderer.cpp.

References vpHomogeneousMatrix::getRotationMatrix(), vpHomogeneousMatrix::getTranslationVector(), vpPanda3DBaseRenderer::VISP_T_PANDA, vpQuaternionVector::w(), vpQuaternionVector::x(), vpQuaternionVector::y(), and vpQuaternionVector::z().

◆ setRenderOrder()

void vpPanda3DBaseRenderer::setRenderOrder ( int  order)
inlineinherited

Definition at line 125 of file vpPanda3DBaseRenderer.h.

◆ setRenderParameters()

void vpPanda3DPostProcessFilter::setRenderParameters ( const vpPanda3DRenderParameters params)
protectedvirtualinherited

Set new rendering parameters. If the scene has already been initialized, the renderer camera is updated.

Parameters
paramsthe new rendering parameters

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 123 of file vpPanda3DPostProcessFilter.cpp.

References vpException::fatalError, vpPanda3DRenderParameters::getImageHeight(), vpPanda3DRenderParameters::getImageWidth(), vpPanda3DBaseRenderer::m_buffers, vpPanda3DPostProcessFilter::m_inputRenderer, vpPanda3DBaseRenderer::m_renderParameters, vpPanda3DBaseRenderer::m_renderRoot, and vpPanda3DBaseRenderer::m_window.

◆ setupCamera()

void vpPanda3DPostProcessFilter::setupCamera ( )
protectedvirtualinherited

Initialize camera. Should be called when the scene root of this render has already been created.

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 73 of file vpPanda3DPostProcessFilter.cpp.

References vpPanda3DBaseRenderer::m_camera, vpPanda3DBaseRenderer::m_cameraPath, vpPanda3DBaseRenderer::m_renderRoot, and vpPanda3DBaseRenderer::m_window.

◆ setupRenderTarget()

◆ setupScene()

void vpPanda3DCanny::setupScene ( )
protectedvirtual

Initialize the scene for this specific renderer.

Creates a root scene for this node and applies shaders. that will be used for rendering

Reimplemented from vpPanda3DPostProcessFilter.

Definition at line 162 of file vpPanda3DCommonFilters.cpp.

References vpPanda3DBaseRenderer::m_renderRoot, and vpPanda3DPostProcessFilter::setupScene().

◆ setVerticalSyncEnabled()

void vpPanda3DBaseRenderer::setVerticalSyncEnabled ( bool  useVsync)
inherited

set whether vertical sync is enabled. When vertical sync is enabled, render speed will be limited by the display's refresh rate

Parameters
useVsyncWhether to use vsync or not

Definition at line 293 of file vpPanda3DBaseRenderer.cpp.

◆ vispPointToPanda()

vpColVector vpPanda3DBaseRenderer::vispPointToPanda ( const vpColVector point)
staticinherited

Definition at line 318 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DBaseRenderer::PANDA_T_VISP.

◆ vispVectorToPanda()

vpColVector vpPanda3DBaseRenderer::vispVectorToPanda ( const vpColVector vec)
staticinherited

Member Data Documentation

◆ FILTER_VERTEX_SHADER

BEGIN_VISP_NAMESPACE const char * vpPanda3DPostProcessFilter::FILTER_VERTEX_SHADER
staticprotectedinherited
Initial value:
= R"shader(
#version 330
in vec4 p3d_Vertex;
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec2 p3d_MultiTexCoord0;
out vec2 texcoords;
void main()
{
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
texcoords = p3d_MultiTexCoord0;
}
)shader"

Definition at line 102 of file vpPanda3DPostProcessFilter.h.

Referenced by vpPanda3DPostProcessFilter::setupScene().

◆ m_buffer

PointerTo<GraphicsOutput> vpPanda3DPostProcessFilter::m_buffer
protectedinherited

◆ m_buffers

◆ m_camera

PointerTo<Camera> vpPanda3DBaseRenderer::m_camera
protectedinherited

◆ m_cameraPath

◆ m_fragmentShader

std::string vpPanda3DPostProcessFilter::m_fragmentShader
protectedinherited

Whether this filter is an output to be used and should be copied to ram.

Definition at line 97 of file vpPanda3DPostProcessFilter.h.

Referenced by vpPanda3DPostProcessFilter::setupScene().

◆ m_framework

std::shared_ptr<PandaFramework> vpPanda3DBaseRenderer::m_framework
protectedinherited

◆ m_inputRenderer

std::shared_ptr<vpPanda3DBaseRenderer> vpPanda3DPostProcessFilter::m_inputRenderer
protectedinherited

◆ m_isOutput

bool vpPanda3DPostProcessFilter::m_isOutput
protectedinherited

◆ m_name

std::string vpPanda3DBaseRenderer::m_name
protectedinherited

◆ m_renderOrder

int vpPanda3DBaseRenderer::m_renderOrder
protectedinherited

◆ m_renderParameters

◆ m_renderRoot

◆ m_shader

PointerTo<Shader> vpPanda3DPostProcessFilter::m_shader
protectedinherited

Definition at line 98 of file vpPanda3DPostProcessFilter.h.

Referenced by vpPanda3DPostProcessFilter::setupScene().

◆ m_texture

PointerTo<Texture> vpPanda3DPostProcessFilter::m_texture
protectedinherited

◆ m_window

◆ PANDA_T_VISP

const vpHomogeneousMatrix vpPanda3DBaseRenderer::PANDA_T_VISP
staticprotectedinherited

Homogeneous transformation matrix to convert from the Panda coordinate system (right-handed Z-up) to the ViSP coordinate system (right-handed Y-Down)

Definition at line 268 of file vpPanda3DBaseRenderer.h.

Referenced by vpPanda3DBaseRenderer::computeNearAndFarPlanesFromNode(), vpPanda3DBaseRenderer::getNodePose(), vpPanda3DBaseRenderer::vispPointToPanda(), and vpPanda3DBaseRenderer::vispVectorToPanda().

◆ VISP_T_PANDA

BEGIN_VISP_NAMESPACE const vpHomogeneousMatrix vpPanda3DBaseRenderer::VISP_T_PANDA
staticprotectedinherited

Definition at line 267 of file vpPanda3DBaseRenderer.h.

Referenced by vpPanda3DBaseRenderer::setNodePose().