Laser-Based Obstacle Detection at Railway Level Crossings

Th is paper presents a system for obstacle detection in railway level crossings from 3 D point clouds acquired with tilting 2 D laser scanners. Although large obstacles in railway level crossings are detectable with current solutions, the detection of small obstacles remains an open problem. By relying on a tilting laser scanner, the proposed system is able to acquire highly dense and accurate point clouds, enabling the detection of small obstacles, like rocks laying near the rail. During an o ffl ine training phase, the system learns a background model of the level crossing from a set of point clouds. Th en, online, obstacles are detected as occupied space contrasting with the background model. To reduce the need for manual on-site calibration, the system automatically estimates the pose of the level crossing and railway with respect to the laser scanner. Experimental results show the ability of the system to successfully perform on a set of 41 point clouds acquired in an operational one-lane level crossing.


Introduction
Railway level crossings (e.g., see Figure 1) are a safety weak point in the railway infrastructure.To reduce the risk of collision between trains and people, vehicles, or any other goods, these are coordinated by half-barriers and traffic signalling.However, there is always the risk that people do not respect signalling or that an unexpected event results in the unwanted presence of people or goods in the train's passageway.CCTV systems are often used to allow remote operators to identify these situations and react promptly.Despite the advantages of relying on human-based decision making, the high number of trains and level crossings to control posit this strategy error-prone.Thus, it is preferable to have the human acting as a complement to sensor-based automated solutions.
Traditionally, obstacle detection at level crossings is done by means of inductive sensors laid on the pavement detecting metallic structures.Another approach is to check if any object interrupts the transmission of a radio or light signal between an emissor and a receptor, strategically and accurately installed on the level crossing.Despite detecting a large set of obstacles to a train's passage, these solutions will disregard nonmetallic and small obstacles, such as the ones depicted in Figure 2. A collision with such objects, although not necessarily damaging to the train, may project them off the railway endangering people or goods present nearby.The aforementioned obstacle detection techniques also require time-consuming installation and calibration of the equipment.More importantly, even if the sensor detects the obstacle, it will not be able to provide sufficiently discriminatory data for a proper assessment of the alarm's severity.More details on the use of traditional obstacle detection techniques in level crossings can be found in [1].
In recent years, techniques for higher acuity in obstacle detection have been proposed.However, these present several limitations in the detection of obstacles such as the ones depicted in Figure 2, which include a basket, a laid down jerrican, and a small rock.Of particular interest to this work are the challenges imposed by the rock, which due to its low volume (≈10 dm 3 ) is largely occluded by the rail, rendering it highly inconspicuous to most detection techniques.The small portion of the rock that stands out from the rail is insufficient for a RADAR system (e.g., [2]) to detect without incurring into unacceptable false alarm rates.A finer alternative to RADAR is the use of static 2D laser scanners (e.g., [3,4]).These provide a set of range radial measurements on a plane.However, to provide long range data without returning hits from the ground, these sensors must be accurately aligned with it.Moreover, the sensor must be very close to the ground in order to detect low obstacles, which are easily occluded by any ground's unevenness.Detailed analysis of the level crossing can be done, in principle, by processing high resolution imagery, provided by surveillance cameras (e.g., [5,6]).However, the robustness of image-based solutions is considerably challenged by the presence of shadows, sudden light variations, and unknown objects.A volumetric analysis of the level crossing should reduce the sensitivity to these environmental factors, provided that enough detail is available.Binocular vision is a low-cost solution to obtain such a rich volumetric information about the environment and, as a result, has been already studied in the context of obstacle detection in level crossings (e.g., [7][8][9]).However, in binocular vision, the accuracy and completeness of the volumetric data depend heavily on lighting conditions, materials' textures, and distance to scene elements.The latter limitation is particularly important when the goal is to detect partially occluded small obstacles.
This paper presents a system that uses volumetric sensory data to detect small obstacles in level crossings.For this purpose it relies on the use of dense 3D point clouds produced by a tilting 2D laser scanner.This way the system is not as dependent on lighting conditions and object's appearance as it would if relying on binocular vision, and it is also not as dependent on ground planarity as are solutions based on static 2D laser scanners.The system is composed of a software layer that processes the 3D point cloud preceded by an acquisition hardware layer.Obstacle detection is carried out exploiting the assumption that a quasiplanar dominant ground plane exists.A background model of the level crossing is learned from a set of training point clouds.Obstacles are the objects that show up in the point clouds captured online that are inexistent in the training dataset.To avoid cumbersome and time-consuming manual on-site calibration, the proposed system includes an automatic calibration process that estimates the pose of both level crossing and railway with respect to the laser scanner.
A commercial product from IHI Corporation uses tilting 2D laser scanners for obstacle detection in railway level crossings [10].The obstacle detection method operates on a scanwise basis; that is, it does not integrate information into a volumetric map, which limits its ability to engage on a detailed and robust volumetric analysis.Moreover, the method relies on the existence of a perfectly planar ground, whose pose with respect to the sensor must be known beforehand.This limits the ability of the method in detecting small obstacles in uneven ground.As a result, according to IHI, the product is designed to detect obstacles whose volume is greater than 1 m 3 .However, a rock as small as the one depicted in Figure 2 occupies considerably less than 1 m 3 .Moreover, the method presented in [10] does not report the ability to automatically estimate the pose of both level crossing and railway with respect to the sensor.Hence, our work is expected to contribute towards an increased detection resolution and faster installation of current laserbased obstacle detectors for railway level crossings.
This paper is organised as follows.Section 2 describes the proposed system.Then, a set of experimental results are presented in Section 3. Finally, in Section 4, some conclusions are drawn and future work avenues are suggested.

The Proposed System
2.1.System Overview.The system's software layer is composed of three main stages: (1) calibration; (2) training; and (3) online operation.The calibration phase is responsible for determining, from a single reference point cloud, the pose of the level crossing (see Section 2.3) and the pose of the railway (see Section 2.4).The system assumes that the sensor will not be moved until further calibration.
From the estimated pose of the level crossing, a set of three zones is defined longitudinal to the railway (see Figures 1 and 3).The goal is to allow separable system's parameterisation and, as a result, a better handling of the speed-accuracy trade-off.Every point cloud to be processed in both training and online operation stages is first segmented into these three zones (see Section 2.5).Then, to define a region of interest (ROI) for subsequent processing steps, the points in each segment of little value for obstacle detection are rejected (see Section 2.6).These points are those at the ground level and too far from the railway medial axis.
In the training phase, the system learns a volumetric map for each zone from the ROI of a set of acquired training point clouds (see Section 2.7).This map includes all static objects present in the level crossing and vicinities.During learning, the level crossing must be free of obstacles.The system must be retrained if the disposition of static obstacles changes.
Once training is concluded, the system can be used online.In this stage, a point cloud is acquired every time the traffic management system needs to ensure that the level crossing is free of unexpected obstacles.Then, the ROI of the acquired point cloud is compared with the volumetric map learned during the training phase to check for the presence of obstacles (see Section 2.8).Afterwards, a set of simple fast to compute metrics are obtained per obstacle (see Section 2.9).This information aims at providing the traffic management system with context information to assess the alarm severity.The level crossing model.The two horizontal lines represent the railway.The radial lines stemming from the LIDAR position are representative of the laser beams generated when the sensor is not tilted.These lines give an intuition regarding the loss of point density as a function of the distance to the sensor.The frame of reference represented is the one of the LIDAR.The four filled rectangles represent the four half-barriers present in the site.Note that, in most situations, the barriers disposed in a nonsquare quadrilateral shape.

Hardware Setup.
The equipment used to capture the point cloud is based on a LIDAR sensor from SICK, LMS 111.This laser scanner provides, at 25 Hz, 0.5 m-20 m range measurements with an angular resolution of 0.25 ∘ over a field of view of 270 ∘ .The LIDAR is coupled with an Inertial Measurement Unit (IMU) 1056-3/3/3, from PhidgetSpatial, and is tilted by means of a MX-64 servo, from Dynamixel (see Figure 4).Assuming that the tilt angle is zero when the laser beams are parallel to the ground plane, the tilting range during a full cycle is defined between −15 ∘ and 30 ∘ .The estimation of the laser's pose is performed through an optimal estimator [11] based on the IMU output.The laser's pose information, at every moment, is used to register the set of points captured at any given instant with the previously captured points.
To ensure a proper registration of the several 2D laser scans, the full 3D point cloud acquisition process is set to take on average 5 sec.This acquisition rate can be reduced with a better synchronisation between IMU and servo, ideally in hardware.Nevertheless, actual future deployments of the proposed system would rely on a multibeam laser scanner, such as a Velodyne LIDAR, which is able to provide full 3D point clouds at 15 Hz. Figure 5 depicts a typical 3D point cloud acquired with this setup at the level crossing.
The acquired point cloud encompasses ≈250 k 3D points.Note the decrease in point density as a function of the distance to the LIDAR.Note also that the point density in the half-barriers (HB) changes considerably.All these aspects impose serious challenges to the level crossing's pose estimation problem and obstacle detection thereafter.
The estimator, servo controller, and laser data registration to produce a complete point cloud run as separate nodes on the Robot Operating System (ROS) [12].The detection system was tested on a 2.66 GHz Intel Core 2 Duo-based MacBook Pro with 8 Gb of RAM, running the operating system OSX 10.9 Maverick.The system was fully implemented in C++ with extensive use of the Point Cloud Library (PCL) [13] for lowlevel point cloud processing tasks.

Level Crossing's Pose Estimation.
To detect obstacles and classify their relevance, it is crucial to estimate from the reference point cloud,   , the pose of the level crossing, that is, its position and orientation in the sensor's frame.The level crossing's pose is estimated from the configuration of the four half-barriers (HB), which are assumed to be upwards in the reference point cloud (see Figures 1 and 5).An HB in the upwards position is expected to exhibit a height with respect to the ground plane between 2 m and 6.5 m, depending on the road's width.Hence, the four HB are expected to standout considerably from the other elements in the scene.The first step to detect the four HB is to determine the set of points in the reference point cloud   , , that corresponds to the ground plane and, hence, is surely not belonging to any HB.This set of points are those whose signed orthogonal distance to the ground plane is higher than an empirically defined scalar, .This value is typically high (e.g., 1.5 m) so as to ensure that the dominant ground plane is found, despite potential ground's unevenness.Formally, a point p = (  ,   ,   ) in the reference point cloud, p ∈   , is added to the set of ground points ,  ←  ∪ {p}, if where the tuple  = (a, , , ) contains the set of coefficients of the plane equation  +  +  +  = 0 that defines the ground plane.
The installation of the sensor may not ensure its strict verticality and, thus, the ground plane's orientation and distance to the sensor are unknown without calibration.This means that the ground plane's coefficients need to be estimated directly from the reference point cloud   .The level crossing is not strictly planar, the input point cloud is noisy, and there are many objects standing on the ground plane.Therefore, the ground plane estimation process must be robust to the strong presence of outliers.This is attained by recurring to random sample consensus method (RANSAC) [14].In short, this method generates  plane hypotheses, that is, tuples   = (  ,   ,   ,   ),  = 1 ⋅ ⋅ ⋅ , and test which of them induces a higher number of inliers in the data.An inlier is a 3D point whose distance to the putative plane is below threshold  (see (11)).The best hypothesis, called simply  henceforth, is then refined with all data using a weighted least-squares approach.Refer to [15] for further details on the application of the RANSAC method for ground plane estimation.
The unorganised set of points belonging to objects present in the level crossing is composed of all nonground points,  =   \.As this set is unorganised, there is no distance function implicit in the order of the points in the set and, thus, there is no spatial connectivity as well.To segregate the various objects present in the scene, a segmentation procedure based on the Euclidean distance between the points is applied [16].The method clusters points in a way that each point within a cluster is close to at least another point in the cluster and it is far from any point from all other clusters.Closeness is empirically defined in an Euclidean sense by a scalar .At this point, all nonground points contained in  are separated into a set of clusters (segments), .This set of clusters excludes clusters that are unreasonably too small (<10 points) or too large (>2500 points).Too small clusters are often caused by the presence of noise whereas too large clusters are typically resulting from faulty laser scans registration.
The set of segments  contains all objects that are present in the level crossing, which includes walls, debris, traffic control equipment, and HB themselves.A first screening to separate the HB from all other objects is done by exploiting the knowledge that the four HB are oriented upwards and are surely taller than a given threshold .In this sense, and assuming that the sensor is roughly vertically aligned, a segment  is added to the set of putative HB segments,  ←  ∪ {}, if the height of the cluster is higher than , ℎ() > , with At this point, the set  is populated with an unordered set of segments corresponding to the four HB present in the scene and of segments potentially corresponding to non-HB objects and noise that could not be rejected as a function of its height.To reduce complexity in the next steps, these segments will be represented by their centroids projected onto the ground plane.The set of these two-dimensional vectors representing the position of a given object on the ground plane is denominated by   .Formally, for each segment  ∈  with unprojected centroid () = (1/|| ) ∑ p∈ p, a twodimensional vector is added to   ,   ←   ∪ {Ψ((), )}: where n  = (, , )/‖(, , )‖ is a unitary vector normal to the ground plane defined by  = (, , , ) and o  = (0, 0, −/) is an arbitrary point on plane .The next step is to check which objects represented by their two-dimensional positions in   actually do correspond to each of the four HB.That is, the previous step potentially detects many more objects than the ones corresponding to the actual HB (see Figure 6).This association problem is solved based on a model of the level crossing.This model assumes that the four HB are disposed as a quadrilateral laid on the ground plane, whose shape and dimensions are defined based on prior knowledge available at the system's commissioning phase.This quadrilateral model is used to check how closely the shape of a given quadrilateral, whose vertices are four of the elements in   , matches the shape of a quadrilateral model.
The quadrilateral model is defined in terms of four twodimensional vertices, q = (k 1 , k 2 , k 3 , k 4 ), each corresponding to the position of an HB.The similarity between the quadrilateral model q and a putative quadrilateral is taken as the cumulative Euclidean distance between the th vertexes in both quadrilaterals.The quadrilateral model is by definition centred in the origin, whereas the putative quadrilateral is not.As a consequence, the similarity metric Φ(q, q  ) must be computed after bringing the quadrilateral to the origin by means of translating its vertices by k  : The combination of four object locations stored in   that render the quadrilateral that best fits the quadrilateral model is the one, over the set all possible combinations , that builds the quadrilateral minimising the similarity metric: qA = arg min q  ∈ Φ (q, q  ) . (5) Figure 7 provides an illustration of the search procedure.The vertices of the quadrilateral qA correspond to the estimated locations of the four HB and, as a result, to the pose of the railway level crossing.The points defining this quadrilateral for a specific point cloud are depicted as k1 k2 k3 k4 in Figure 6.

Railway's Pose Estimation.
The quadrilateral defining the level crossing's pose, qA , is valuable information to determine where obstacles cannot be present for safety reasons.Further detail on which objects in the site can potentially be hit by the train can be obtained by determining the pose of the railway.A coarse approximation to the railway's pose can be geometrically obtained from the pose of the level crossing.Concretely, the railway is expected to cross the level crossing at its middle axis.To get an accurate estimate, the coarse railway's pose hypothesis must be refined according to local sensory data.
Specifically, the railway's middle axis is coarsely defined as the line L that splits the quadrilateral qA into two equal halves.Let us define the quadrilateral representing zone A, qA , by centroids k1 k2 k3 k4 .Then, L is the line that connects the points (1/2)(k 1 + k3 ) and (1/2)(k 2 + k4 ) (see Figure 8).
In actual level crossings, the quadrilateral defined by the half-barriers does not predict accurately enough the location of the railway.So as to compensate for this fact, L is used as a starting point for an accurate search for both rails' signature in the point cloud.Rails are assumed to be distinguishable from their close vicinities in terms of point density.Figure 5 shows that rails exhibit a higher point density than their surroundings (see the areas indicated by the circles in the figure).This is explained by the fact that a given surface is sampled more densely if its normal vector is parallel with respect to the laser beams than if it is perpendicular.The figure also shows that the rail casts a laser-shadow onto the vicinity ground, which lowers considerably the point density.
To estimate the lines that best represent both rails, L + and L − , two points on each must be found based on the rail's point density signature.The search for these points starts from two points sufficiently distant from each other and from the central area of the level crossing (the pavement in the central area renders the railway volumetrically inconspicuous) along lines L, a L , and b L (see Figure 8).Then, four search procedures start from these two points to look for the rails' signature (see Figure 9).
The search procedure proceeds as follows.From the two points a L and b L , two emanating search direction unitary vectors are created perpendicular to L, d, and −d, such that d ⋅ (a L − b L ) = 0 (see Figure 10).Each of these direction vectors is used to define a parametric semiline of the form i , with the corresponding expected position k i (unfilled circles).After averaging these distances, it is possible to state that the hypothesis picked in (a) is most likely to be correct one when compared to the one picked in (c).
where s ∈ {a L , b L } represents the search's starting point, k ∈ {d, −d} represents the unitary search direction vector perpendicular to the rail middle axis, and  ∈ R + is a control parameter that can be used to sample the semiline.
The parametric semilines are sampled by applying  increments to the control parameter  in (6),  ← +.At each sample point p(), the set of neighbour points within a radius of 2 is computed, (p()).If the cardinality of this set shows to be  times higher than the cardinality of the set obtained in the previous sampling point, |(p())| ≥ |(p( − ))|, then the search procedure stops and returns the centroid of the neighbour points as the result of the search.
For instance, let us consider the search procedure that starts in a L towards direction d.Let us assume that the search stops (the trail is found) when  in (6) takes the value  +  .In this case, the point on the rail resulting from this search procedure is taken as ((a L +  +  d)) (see (6) and Figure 10).
A - tree is built from the input point cloud and used in the computation of (⋅), that is, in the search for the neighbours of a given point.Formally, a point p  is added to the set of neighbours of p, (p) ← (p)∪{p  }, if ‖p−p  ‖ ≤ .The use of a - tree speeds up the nearest-neighbour search process considerably.

Zones Segmentation.
Point clouds acquired by a tilting laser scanner exhibit a considerable decrease in point density as a function of depth, which means that obstacles nearby the sensor are represented much more densely than obstacles distant from the sensor.To account for this factor, obstacle detection is parameterised differently depending on the distance to the sensor.Concretely, three zones are defined.One of the zones,  A , corresponds to the level crossing core, that is, the area covered by the quadrilateral qA .The two other zones,  B and  C , are both side-by-side with  A along both railway's directions.The quadrilaterals defining these zones are denominated as qB and qC , respectively.These two zones represent the periphery of the level crossing. B is assumed to be the closest to the sensor and, thus, the zone with higher density of points.Conversely,  C is the zone with the least point density.
For a given input point cloud obtained during either training or online operation phases,  A ,  B , and  C are the sets of 3D points encompassed by the cuboids whose base are the quadrilaterals defining the respective zones.A point p ∈ R 3 is said to belong to a given zone  ∈ {A, B, C}, p ∈   , if its 2D projection onto the ground plane, p * ∈ R 2 , is encompassed by the quadrilateral qi .By assuming that the sensor is roughly vertically aligned, p * is p without its third coordinate.
Let us assume that one of the quadrilateral sides is defined by the two-dimensional vertices ( 1 ,  1 ) and ( 2 ,  2 ) and, consequently, by the implicit function (, ) = ( p * is said to be below this line if (p * ) < 0. Let us now assume the existence of four implicit functions,  ∈{1,2,3,4} , one representing each side of the quadrilateral.Then, a point p is said to be encompassed by the quadrilateral if   (p * ) < 0, ∀ ∈ {1, 2, 3, 4}.

Region of Interest.
Obstacles are those objects that can potentially interfere with train's motion.A set of metrics can then set the alarm relevance depending on, for instance, the obstacle's distance to the railway.This means that the region of interest for the detector is not limited to the train's workspace; it must also encompass its vicinities.In this sense, a point in a given zone  ∈ {A, B, C}, p ∈   , is labelled as relevant if its orthogonal distance to the railway middle line L is below half the train's width plus a safety margin; the aggregate is represented by the scalar   : where a L and b L are two points along the line L (see Section 2.4).The index  in   states that the width of the region of interest changes according to the level crossing's zone.Small obstacle detection is a challenging task due to potential unevenness of the ground, sparsity of the point cloud, and its noisy nature.To reduce sensitivity to noise, the outliers present in all processed point clouds are filtered out.A point is discarded from further processing if the distribution of the distances between itself and its  nearest neighbours is too dissimilar from the distribution computed over all points in the point cloud [17].That is, if the point exhibits a local distribution that detaches from all other local distributions then it must be an outlier.Concretely, let  p represent the average Euclidean distance between a given point p and its  nearest neighbours.Let  and  be the mean and standard deviation, respectively, of these average distances computed over the whole point cloud   ,  = (1/|  |) ∑ p∈   p .With this principle in mind, a point p ∈   already labelled as relevant keeps its label if [17]  −  ≤  p ≤  + , where  is an empirically defined scalar.Due to efficiency purposes, the nearest neighbours search is performed on the top of a - tree.
Points already labelled relevant are passed through a final filtering process before being analysed for the presence of obstacles.Ground points are by definition nonobstacles and, thus, should be discarded using a RANSAC-like procedure.The ground plane  has been determined for the whole point cloud with a high distance threshold  (see Section 2.3), meaning that it is just a rough approximation of the local ground planarity.Therefore, the ground plane  is not well suited for segmenting ground points from potentially small obstacles.Instead, a ground plane is estimated for each zone based only on the points present therein.Formally, for a given zone  ∈ {A, B, C}, a RANSAC procedure is run on the top of the subpoint cloud   with distance threshold   to determine the zone's local ground plane   .Then, a given point p ∈   previously labelled as relevant only keeps its label if its orthogonal distance to the ground plane   is above a given threshold   , (p,   ) >   (see (11)).The subscript  in   denotes the fact that the threshold can be set separately for each zone.This is useful for instant to reduce the number of false positives in the farthest zone with respect to the sensor.In this zone, the low point density and signal-to-noise ratio induces large false positives if the threshold is low.Conversely, a low threshold operates well in the closest zones.As a result, distant obstacles must be large to be detected.This is a limitation imposed by the sensor that can be easily removed by registering point clouds acquired by complementary laser scanners.
Let us call    the relevant point cloud, that is, the subset of   that only contains points labelled relevant.In short, these are points of zone  that are nonoutliers, are included in the zone's region of interest, and are above the ground.Therefore,    potentially contains a few undetected ground points and objects standing on the ground.Not all these objects should be reported as obstacles.For example, a traffic control equipment is a static object present in the level crossing that is not an obstacle to the train, not even potential.Obstacles are defined as unexpected objects present in the level crossing and, thus, above-plane is not a sufficient condition to report the presence of an obstacle.The next section presents an additional step to identify unexpected objects in the region of interest of each zone.

Training.
To detect obstacles, a background model is first learned during a training phase for each zone  ∈ {A, B, C},    =  ,0 ∪ ⋅ ⋅ ⋅ ∪  , , where  is the number of clouds acquired for training.Hence, the background model is simply defined as the union of all point clouds in the training dataset (see Section 2.6).This assumes that only static elements (e.g., ground, traffic control equipment, and walls) are present in the level crossing during training and, therefore, represented in the background model.
The training phase occurs during the installation of the obstacle detector in the level crossing.It may be repeated whenever new static obstacles are added to or removed from the level crossing or when the sensor is moved.

Obstacle Detection.
After training, the system enters in the online operation stage, meaning that, prior to each train passage, it obtains a new point cloud, builds a relevant point cloud    per zone  ∈ {A, B, C} (see Section 2.6), and detects the presence of obstacles in it (see below).
Obstacles are defined as objects present in the current point cloud that were not present in the training dataset.Therefore, a potential obstacle is present whenever a difference between point cloud,   ∈{A,B,C} , and the corresponding background model,    , is found.Comparing the point clouds directly is impractical as these are unorganised; that is, there is no obvious implicit spatial order in their vector structures, and their point densities differ considerably.
To reduce computation, a fine regular grid with cell size ] is superposed onto each point cloud and all the points encompassed by each grid cell are substituted by their centroids.This results in two new downsampled point clouds per zone  ∈ {A, B, C}, V(   ) and V(   ).Then, the two downsampled point clouds in each zone are compared according to the method proposed by Kammerl et al. [18].In short, the first point cloud, V(   ), is used to build the initial structure of a double-buffered octree.Then, the doublebuffered octree's structure is altered in order to accommodate the contents of the second point cloud, V(   ).During this process, new octree's leaf nodes are added to the octree's structure so as to represent elements of the environment that were not represented by the initial octree's structure.The centroids of these octree's new leaf nodes are used to create a point cloud representing the set of potential obstacle points.This process is repeated so as to create a point cloud  *  per zone  ∈ {A, B, C}.
Finally, all points in  *  are segmented into a set of spatially separate objects according to their Euclidean distance (see Section 2.3), that is, potential obstacles,  = { 0 , . . .,   }, as in Section 2.3, where  is the number of separated objects found in the process.This set of objects does not include too small segments as these are likely to be caused by the presence of noise.The size of the smallest acceptable segment depends on the point density and range accuracy and, hence, it must be defined per zone,   ,  ∈ {A, B, C}.As the segments are built upon a downsampled point cloud, the point density of the clusters is roughly homogeneous, which means that the number of points in the segment is a rough approximation of the segment's surface area.As a result, small segments can be safely, that is, in a density-invariant way, rejected if it is supported by less than  points.

Obstacle Characterisation.
To be able to generate meaningful alarms it is essential to characterise the obstacles found in the train's workspace and vicinity.This section presents two simple metrics that can be computed rapidly.General purpose object recognition techniques adequate for point clouds (e.g., [19]) could also be applied to endow the alarming system with additional semantics, at the expense of additional computation.
The first metric is defined as the height and diameter of a bounding cylinder of the obstacle.This provides easy-to-interpret volume information that can be used by the alarming system to determine the relevance of the obstacle from its approximate volume and outline.The bounding cylinder is assumed to lay on the ground surface assuming that the lower part of the obstacle may be occluded.Moreover, the cylinder is perpendicular to the ground plane and its position is defined as the ground plane projected centroid of the obstacle points:   (, ) = (Ψ ( () , )) . ( The height and diameter of the cylinder with respect to ground plane  for obstacle , ℎ  (, ), and its radius,   (, ), are The third metric is the distance the cylinder is from the railway's middle axis, L. This information is crucial to determine the likelihood that the obstacle may actually be hit by the train.Formally, the third metric for object characterisation is computed as follows:

Experimental Results
To validate the proposed system a set of point clouds were acquired in the level crossing of Sabugo, Portugal (see Figure 1), with the setup presented in Section 2.2.To estimate the level crossing (see Section 2.  The figure shows that the system managed to detect the half-barriers properly (represented by the upwards directed arrows), as well as the railway (represented by the parallel red lines).The distance between these two lines was measured to be 1755 mm, which deviates only 5% from the expected distance, which is 1668 mm in Portugal and Spain.A little offset between the estimated railway orientation and the actual one is visible in the figure.This owes to the radius used to check point density variations along sampled points.A smaller radius would reduce the deviation but at the cost of potentially failing to detect the density change.12 presents the detection results in four of the 32 tested point clouds.The results show the ability of the system to detect a large variety of obstacles, from large car parts to small rocks laid down near one of the rails.Small-sized obstacles were disposed only on zones A and B as they are by definition inconspicuous in zone C due to its very low point density.A parameterisation that would enable the system to detect small obstacles in zone C would also result in unacceptable false alarm rates.The deployment of a complementary laser scanner would suffice to remove this constraint, meaning that the system would be able to detect both large and small obstacles in the whole area of the level crossing.The system detected all obstacles in the full set of tested point clouds without generating false alarms.
3.3.Timings.Table 1 presents the average partial time (over 10 repetitions) spent by the system in each of the processing steps that occur offline (calibration and training), online (detection), or in both offline and online phases.Point cloud acquisition time, which includes the mechanical tilting of the sensor, is rather high.However, as already explained in Section 2.2, it could be easily reduced to a small fraction of the current one with state-of-the-art multibeam laser scanners.Although this is not an issue in the calibration and training phases, it can be problematic while operating online.The time spent in pose estimation is clearly acceptable given the low time constraints of an offline calibration procedure.Finally, although further code optimisations could be considered, current detection time is acceptable for current safety standards.In sum, the system's responsiveness is in line with the requirements of level crossing safety standards.

Conclusions
A system for obstacle detection in level crossings from 3D point clouds acquired with tilting 2D laser scanners was presented.By allowing the detection of large and small obstacles (≥10 dm 3 ) despite lighting conditions, the system contributes to reducing the number of casualties in level crossings without reducing traffic flow.In addition to solving the detection problem, the proposed system includes an automatic mechanism to estimate the poses of both level crossing and railway, which reduces installation time.A set of experimental results on several point clouds acquired on an operational level crossing shows the viability of the system.
As future work we intend to reduce point cloud acquisition time, use more than one laser scanner, and include object classification capabilities to trigger semantic alarms.

Figure 1 :
Figure 1: The level crossing considered for the field trials.

Figure 2 :Figure 3 :
Figure 2: Some of the obstacles used to validate the proposed system.The volumes occupied by the basket, jerrican, and rock are approximately 20 dm 3 , 50 dm 3 , and 10 dm 3 , respectively.

Figure 4 :Figure 5 :
Figure 4: The laser scanner being actively tilted by the servo so as to acquire a complete 3D point cloud (time flows from (a) to (d)).The laser scanner tilting angle is estimated at each time step via the IMU mounted on the top of the sensor.

Figure 6 :
Figure 6: The several objects detected when searching for the HB in the same point cloud as the one depicted in Figure 5 (view aligned with the railway).The coloured spheres on top of arrows represent the centroid of each detected object and the unfilled circles at the starting points of the associated arrows correspond to the projection of the centroids on the ground plane.Note that only the objects detected in left hand side of the figure correspond to the actual HB.

Figure 7 :󸀠 1 k 󸀠 2 k 󸀠 3 k 󸀠 4 ,
Figure7: An illustration of the process employed to determine which detected objects represent the half-barriers (HB) in the point cloud.The coordinate system represents the 2D projection of the LIDAR frame of reference.The filled circles correspond to detected objects described in terms of the LIDAR frame of reference, that is, putative HB.(a) and (c) Four putative HB were randomly selected to form quadrilateralk  1 k  2 k  3 k  4 , whose centroid is k  .(b) and (d)The quadrilaterals picked in (a) and (c) are centred in the origin by translating each vertex by the corresponding quadrilateral's centroid vector.After this transformation it is possible to compare each putative HB position, a given vertex k  i , with the corresponding expected position k i (unfilled circles).After averaging these distances, it is possible to state that the hypothesis picked in (a) is most likely to be correct one when compared to the one picked in (c).

Figure 8 :Figure 9 :
Figure 8: Diagram representing the process used to obtain a first rough approximation of the railway middle axis line, L, given the quadrilateral k1 k2 k3 k4 formed by the half-barriers.

Figure 10 :
Figure 10: A diagram representative of the rail search procedure.

3 )
and railway (see Section 2.4) poses, the calibration point cloud depicted in Figure5was used.A set of similar 9 other point clouds were used for learning the background model (see Section 2.7).Another set of 32 point clouds was used to determine the ability of the detection system to report the presence of the obstacles depicted in Figure2.In this set, 28 clouds contain obstacles and 4 other clouds are free of obstacles.The system's parameters were empirically set as follows (see Section 2):  = 1000,  = 1.5 m,  A = 20 cm,  B = 15 cm,  C = 70 cm,  A = 32,  B = 35,  C = 55,  A = 4.25 m,  B =  C = 1.75 m,  = 10 cm,  = 2.5 m,  = 3.5 cm,  = 2.5, and  = 30.Finally, the volume of the minimum octrees' leaf size was set to 5 cm × 5 cm × 5 cm.

3. 1 .
Pose Estimation Results. Figure 11 depicts the pose estimation result obtained with the calibration point cloud.

Figure 11 :
Figure 11: Pose estimation results.Level crossing's pose estimation is represented by the arrows overlaid on the estimated half barrier positions.Railway's pose estimation is represented by the lines overlaid on the rails' regions.The red and green lines represent the estimated pose of the rails and their medial axis, respectively.

(a) 4 Figure 12 :
Figure 12: Detection results in typical point clouds from the testing data set.The three quadrilaterals correspond to the quadrilaterals that were estimated as defining zones A, B, and C. The grey points correspond to the ground points present in the region of interest.Coloured points are obstacle points (refer to subcaptions for color coding).