Skip to main content
Solved

Frontview image of point cloud


sami26beniaouf
Contributor
Forum|alt.badge.img+7

Hello everyone,

 

I have a point cloud of a section of a road, and I'm wondering if i can get a front view picture of the point cloud like in the screenshot using FME. I also have the axe of the road if it can help with the direction.

 

Thank you in advance.

 

Best answer by daveatsafe

Hi @sami26beniaouf​,

You can use the CoordinateSwapper with an X <-> Z swap to switch the top view for a front view. To generate an image, use a PointCloudSorter to sort the points by the z component, ascending, then an ImageRasterizer. The sorting ensures that the closer points will overwrite the farther points.

Screen Shot 2023-10-24 at 3.20.09 PM

View original
Did this help you find an answer to your question?

7 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • Best Answer
  • October 24, 2023

Hi @sami26beniaouf​,

You can use the CoordinateSwapper with an X <-> Z swap to switch the top view for a front view. To generate an image, use a PointCloudSorter to sort the points by the z component, ascending, then an ImageRasterizer. The sorting ensures that the closer points will overwrite the farther points.

Screen Shot 2023-10-24 at 3.20.09 PM


sami26beniaouf
Contributor
Forum|alt.badge.img+7

Hello @daveatsafe​,

Thank you for your reply, that's the solution i thought about but the road is not always in the same direction as x. Do you think it's possible to use a given direction like using the axe of the road?


takashi
Contributor
  • October 28, 2023

Hi @sami26beniaouf​ ,

I'm not sure what the "axe" means, but if the angle of the road direction against the X axis is known, I think you can rotate the point cloud with Rotator to make the road parallel to the X axis, and then apply the method provided by @daveatsafe​ . 


sami26beniaouf
Contributor
Forum|alt.badge.img+7

Hi @Takashi Iijima​,

Thank you very much for your response,

i'm sorry i mean axis, I have the polyline of the road axis which is not a straight line. It's a good idea, but do you think we can find the angle between the road axis and the X axis localy in the point cloud location?


takashi
Contributor
  • October 30, 2023

Just an idea.

  1. Split the polyline into individual segments,
  2. Calculate rotation angle against the X axis for each segment,
  3. Make buffers of those segments,
  4. Clip the point cloud by the buffers,
  5. Rotate each clipped point cloud so that its axis is along the X axis,
  6. Apply @daveatsafe​ 's solution to each point cloud.

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • October 30, 2023

To find the angle and axis needed to rotate a road segment to vertical, you can use the following code in a PythonCaller:

import fmeobjects
import math
# Template Function interface:
def calcQuaternion(feature):
   start = feature.getCoordinate(0)
   end = feature.getCoordinate(1)
   vector = [(end[0]-start[0]),(end[1]-start[1]),(end[2]-start[2])]
   length = math.sqrt((end[0]-start[0])**2 + (end[1]-start[1])**2 + (end[2]-start[2])**2)
   vertical = [0,0,length]
   cross =  [vertical[1]*vector[2] - vertical[2]*vector[1],vertical[2]*vector[0] - vertical[0]*vector[2],vertical[0]*vector[1] - vertical[1]*vector[0]]
   dot = vertical[0]*vector[0] + vertical[1]*vector[1] + vertical[2]*vector[2]
   cos = dot/(length**2)
   # in some edge cases, a slightly out of bounds cos may be created
   if cos > 1.0:
       cos = 1.0
   if cos < -1.0:
       cos = -1.0
   rotation = math.acos(cos)*180/math.pi
   feature.setAttribute('_vector_x',cross[0])
   feature.setAttribute('_vector_y',cross[1])
   feature.setAttribute('_vector_z',cross[2])
   feature.setAttribute('_rotation',rotation)
   if rotation == 180 and cross == [0,0,0]:
       feature.setAttribute('_length',-length)
   else:
       feature.setAttribute('_length',length)
 

Use the resulting _vector_x, _y, _z and _rotation value in a 3D Rotator to rotate the segment to vertical.


sami26beniaouf
Contributor
Forum|alt.badge.img+7

Thank you @daveatsafe​ and @Takashi Iijima​. I'll try both methods !


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings