Fixed semantic lidar + manual control (#8423)
This commit is contained in:
parent
7f26c281ff
commit
28df8db4be
|
@ -129,6 +129,37 @@ try:
|
|||
except ImportError:
|
||||
raise RuntimeError('cannot import numpy, make sure numpy package is installed')
|
||||
|
||||
OBJECT_TO_COLOR = [
|
||||
(255, 255, 255),
|
||||
(128, 64, 128),
|
||||
(244, 35, 232),
|
||||
(70, 70, 70),
|
||||
(102, 102, 156),
|
||||
(190, 153, 153),
|
||||
(153, 153, 153),
|
||||
(250, 170, 30),
|
||||
(220, 220, 0),
|
||||
(107, 142, 35),
|
||||
(152, 251, 152),
|
||||
(70, 130, 180),
|
||||
(220, 20, 60),
|
||||
(255, 0, 0),
|
||||
(0, 0, 142),
|
||||
(0, 0, 70),
|
||||
(0, 60, 100),
|
||||
(0, 80, 100),
|
||||
(0, 0, 230),
|
||||
(119, 11, 32),
|
||||
(110, 190, 160),
|
||||
(170, 120, 50),
|
||||
(55, 90, 80),
|
||||
(45, 60, 150),
|
||||
(157, 234, 50),
|
||||
(81, 0, 81),
|
||||
(150, 100, 100),
|
||||
(230, 150, 140),
|
||||
(180, 165, 180),
|
||||
]
|
||||
|
||||
# ==============================================================================
|
||||
# -- Global functions ----------------------------------------------------------
|
||||
|
@ -1105,6 +1136,7 @@ class CameraManager(object):
|
|||
['sensor.camera.instance_segmentation', cc.CityScapesPalette, 'Camera Instance Segmentation (CityScapes Palette)', {}],
|
||||
['sensor.camera.instance_segmentation', cc.Raw, 'Camera Instance Segmentation (Raw)', {}],
|
||||
['sensor.lidar.ray_cast', None, 'Lidar (Ray-Cast)', {'range': '50'}],
|
||||
['sensor.lidar.ray_cast_semantic', None, 'Semantic Lidar (Ray-Cast)', {'range': '50'}],
|
||||
['sensor.camera.dvs', cc.Raw, 'Dynamic Vision Sensor', {}],
|
||||
['sensor.camera.rgb', cc.Raw, 'Camera RGB Distorted',
|
||||
{'lens_circle_multiplier': '3.0',
|
||||
|
@ -1177,7 +1209,7 @@ class CameraManager(object):
|
|||
self = weak_self()
|
||||
if not self:
|
||||
return
|
||||
if self.sensors[self.index][0].startswith('sensor.lidar'):
|
||||
if self.sensors[self.index][0] == 'sensor.lidar.ray_cast':
|
||||
points = np.frombuffer(image.raw_data, dtype=np.dtype('f4'))
|
||||
points = np.reshape(points, (int(points.shape[0] / 4), 4))
|
||||
lidar_data = np.array(points[:, :2])
|
||||
|
@ -1190,6 +1222,21 @@ class CameraManager(object):
|
|||
lidar_img = np.zeros((lidar_img_size), dtype=np.uint8)
|
||||
lidar_img[tuple(lidar_data.T)] = (255, 255, 255)
|
||||
self.surface = pygame.surfarray.make_surface(lidar_img)
|
||||
elif self.sensors[self.index][0] == 'sensor.lidar.ray_cast_semantic':
|
||||
points = np.frombuffer(image.raw_data, dtype=np.dtype('f4'))
|
||||
points = np.reshape(points, (int(points.shape[0] / 6), 6))
|
||||
lidar_data = np.array(points[:, :2])
|
||||
lidar_data *= min(self.hud.dim) / (2.0 * self.lidar_range)
|
||||
lidar_data += (0.5 * self.hud.dim[0], 0.5 * self.hud.dim[1])
|
||||
lidar_data = lidar_data.astype(np.int32)
|
||||
lidar_data = np.reshape(lidar_data, (-1, 2))
|
||||
lidar_img_size = (self.hud.dim[0], self.hud.dim[1], 3)
|
||||
lidar_img = np.zeros((lidar_img_size), dtype=np.uint8)
|
||||
for i in range(len(image)):
|
||||
point = lidar_data[i]
|
||||
lidar_tag = image[i].object_tag
|
||||
lidar_img[tuple(point.T)] = OBJECT_TO_COLOR[int(lidar_tag)]
|
||||
self.surface = pygame.surfarray.make_surface(lidar_img)
|
||||
elif self.sensors[self.index][0].startswith('sensor.camera.dvs'):
|
||||
# Example of converting the raw_data from a carla.DVSEventArray
|
||||
# sensor into a NumPy array and using it as an image
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "Carla/Sensor/RayCastSemanticLidar.h"
|
||||
#include "Carla.h"
|
||||
#include "Carla/Actor/ActorBlueprintFunctionLibrary.h"
|
||||
#include "Carla/Game/Tagger.h"
|
||||
|
||||
#include <util/disable-ue4-macros.h>
|
||||
#include "carla/geom/Math.h"
|
||||
|
@ -216,7 +217,7 @@ void ARayCastSemanticLidar::ComputeRawDetection(const FHitResult& HitInfo, const
|
|||
|
||||
const AActor* actor = HitInfo.GetActor();
|
||||
Detection.object_idx = 0;
|
||||
Detection.object_tag = static_cast<uint32_t>(HitInfo.Component->CustomDepthStencilValue);
|
||||
Detection.object_tag = static_cast<uint32_t>(ATagger::GetTagFromString(HitInfo.Component->ComponentTags[0].ToString()));
|
||||
|
||||
if (actor != nullptr) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue