SetNode

The SetNode class in Geomapi represents the data and metadata captured within a single epoch. The data itself can consist of various remote sensing inputs (point clouds, meshes, etc.) and mostly builds upon OPEN3D. The metadata of the SetNode consists of the overarching properties and builds upon the RDFlib framework:

http://www.open3d.org/docs/latest/tutorial/Basic/mesh.html#

https://rdflib.readthedocs.io/

The code below shows how to create a SetNode from various inputs.

First the geomapi and external packages are imported

#IMPORT PACKAGES
from rdflib import Graph
import os
import numpy as np

#IMPORT MODULES
from context import geomapi #context import for documentation only
from geomapi.nodes import SetNode
Jupyter environment detected. Enabling Open3D WebVisualizer.
[Open3D INFO] WebRTC GUI backend enabled.
[Open3D INFO] WebRTCWindowSystem: HTTP handshake server disabled.

SetNode Creation

A SetNode is constructed using the same parameters as the base Node. Please refer to Node Tutorial For more info about Node Creation

SetNode( subject = None,             # (URIRef, optional) : A subject to use as identifier for the Node.
         graph = None,               # (Graph, optional) : An RDF Graph to parse.
         graphPath = None,           # (Path, optional) : The path of an RDF Graph to parse.
         name = None,                # (str, optional) : A name of the Node.
         path = None,                # (Path, optional) : A filepath to a resource.
         timestamp = None,           # (str, optional) : Timestamp for the node.
         resource = None,            # (optional) : Resource associated with the node.
         cartesianTransform = None,  # (np.ndarray, optional) : The (4x4) transformation matrix.
         orientedBoundingBox = None, # (o3d.geometry.OrientedBoundingBox, optional) : The oriented bounding box of the node.
         convexHull = None,          # (o3d.geometry.TriangleSet, optional) : The convex hull of the node.
         loadResource = False,       # Load the resource at initialization?
         linkedNodes = None,         # (List[Node], optional) : A list of geomapi.Node linked to this set
         linkedSubjects = None       # (List[RDFLiteral], optional) : A list of subjects linked to this set
        )

Creation from RDF Graph

A SetNode can be created directly from a graph.

import geomapi.tools as tl

nodes = tl.graph_to_nodes(graphPath = r"../../..\tests\testfiles\graphs\resources_graph.ttl")
setNode = SetNode(linkedNodes=nodes)
print(setNode.linkedSubjects)
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
[rdflib.term.URIRef('http://resources#parking_mesh'), rdflib.term.URIRef('http://resources#DJI_0085'), rdflib.term.URIRef('http://resources#IMG_8834'), rdflib.term.URIRef('http://resources#parking_pcd'), rdflib.term.URIRef('http://resources#Basic_Wall_168_WA_f2_Soilmix_600mm_956569_06v1k9ENv8DhGMCvKUuLQV'), rdflib.term.URIRef('http://resources#Floor_232_FL_Concrete_CIP_450mm-naspanning_1035905_2qZtnImXH6Tgdb58DjNlmF')]

SetNode Transformation

Since every nod has a cartesian transform, it can be transformed using the node.transform() function.

The transformation also updates the convexHull and orientedBoundingBox.

Furthermore, if the SetNode has a resource, that resource is also transformed.

node = SetNode()
print(node.cartesianTransform)
transformation = np.array([[0,0,1,0],[0,1,0,0],[1,0,0,0],[0,0,0,1]])
node.transform(transformation=transformation)
print("applying transformation: (-1)")
print(node.cartesianTransform,"\n")

node = SetNode()
rotation = np.array([90,0,0]) #eulers in degrees
node.transform(rotation=rotation)
print("applying rotation: (90,0,0)")
print(node.cartesianTransform,"\n")

node = SetNode()
translation = np.array([1,2,3])
node.transform(translation=translation)
print("applying translation: (1,2,3)")
print(node.cartesianTransform)
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]
applying transformation: (-1)
[[0. 0. 1. 0.]
 [0. 1. 0. 0.]
 [1. 0. 0. 0.]
 [0. 0. 0. 1.]] 

applying rotation: (90,0,0)
[[ 1.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00]
 [ 0.000000e+00  6.123234e-17 -1.000000e+00  0.000000e+00]
 [ 0.000000e+00  1.000000e+00  6.123234e-17  0.000000e+00]
 [ 0.000000e+00  0.000000e+00  0.000000e+00  1.000000e+00]] 

applying translation: (1,2,3)
[[1. 0. 0. 1.]
 [0. 1. 0. 2.]
 [0. 0. 1. 3.]
 [0. 0. 0. 1.]]

SetNode Visualisation

When a SetNode has a linkedNodes, the show() function displays the all the 3D representations of the nodes using open3d

import geomapi.tools as tl
nodes = tl.graph_to_nodes(graphPath = r"../../..\tests\testfiles\graphs\resources_graph.ttl", loadResource = True, focalLength35mm = 50)
setNode = SetNode(linkedNodes=nodes)
for node in setNode.linkedNodes:
    print(node.name)
    print(node.path)
    #node.show()
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
No path is defined, unable to load resource
No path is defined, unable to load resource
parking
C:\Users\jelle\Documents\DoctoraatLocal\geomapi\tests\testfiles\mesh\parking.obj
DJI_0085
C:\Users\jelle\Documents\DoctoraatLocal\geomapi\tests\testfiles\img\DJI_0085.JPG
IMG_8834
C:\Users\jelle\Documents\DoctoraatLocal\geomapi\tests\testfiles\img\IMG_8834.JPG
parking
C:\Users\jelle\Documents\DoctoraatLocal\geomapi\tests\testfiles\pcd\parking.pcd
Basic Wall:168_WA_f2_Soilmix 600mm:956569
None
Floor:232_FL_Concrete CIP 450mm-naspanning:1035905
None
setNode.show()
[Open3D WARNING] [AddGeometry] Invalid pointer. Possibly a null pointer or None was passed in.
[Open3D WARNING] [AddGeometry] Invalid pointer. Possibly a null pointer or None was passed in.

Further reading

Please refer to the full API documentation of the SetNode class for more details about the functionality