@@ -373,6 +373,36 @@ def __call__(self, lidar, labels):
373373 return lidar , labels
374374
375375
376+ class Random_Translate (object ):
377+ def __init__ (
378+ self ,
379+ translate_range_x = (- 0.1 , 0.1 ),
380+ translate_range_y = (- 0.1 , 0.1 ),
381+ p = 0.5
382+ ):
383+ #Translate ranges from [-1, 1]
384+ #With 1 being the full length of BEV in x/y direction
385+ self .x_range = translate_range_x
386+ self .y_range = translate_range_y
387+ self .p = p
388+
389+ def __call__ (self , lidar , labels ):
390+ if np .random .random () <= self .p :
391+ factor_x = np .random .uniform (self .x_range [0 ], self .x_range [1 ])
392+ factor_y = np .random .uniform (self .y_range [0 ], self .y_range [1 ])
393+
394+ factor_x *= (cnf .boundary ["maxX" ] - cnf .boundary ["minX" ])
395+ factor_y *= (cnf .boundary ["maxY" ] - cnf .boundary ["minY" ])
396+
397+ lidar [:, 0 ] += factor_x
398+ lidar [:, 1 ] += factor_y
399+
400+ labels [:, 0 ] += factor_x
401+ labels [:, 1 ] += factor_y
402+
403+ return lidar , labels
404+
405+
376406class Horizontal_Flip (object ):
377407 def __init__ (self , p = 0.5 ):
378408 self .p = p
0 commit comments