Skip to content

Fix DVS camera in ue5-dev branch #8823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: ue5-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion PythonAPI/examples/manual_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ def __init__(self, parent_actor, hud, gamma_correction):
['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',
'lens_circle_falloff': '3.0',
Expand Down Expand Up @@ -1230,6 +1231,15 @@ def _parse_image(weak_self, image):
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
dvs_events = np.frombuffer(image.raw_data, dtype=np.dtype([
('x', np.uint16), ('y', np.uint16), ('t', np.int64), ('pol', bool)]))
dvs_img = np.zeros((image.height, image.width, 3), dtype=np.uint8)
# Blue is positive, red is negative
dvs_img[dvs_events[:]['y'], dvs_events[:]['x'], dvs_events[:]['pol'] * 2] = 255
self.surface = pygame.surfarray.make_surface(dvs_img.swapaxes(0, 1))
elif self.sensors[self.index][0].startswith('sensor.camera.optical_flow'):
image = image.get_color_coded_flow()
array = np.frombuffer(image.raw_data, dtype=np.dtype("uint8"))
Expand Down Expand Up @@ -1377,4 +1387,4 @@ def main():

if __name__ == '__main__':

main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void ADVSCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTim
TRACE_CPUPROFILER_EVENT_SCOPE(ADVSCamera::PostPhysTick);
Super::PostPhysTick(World, TickType, DeltaTime);
check(CaptureRenderTarget != nullptr);
if (!HasActorBegunPlay() || IsValid(this))
if (!HasActorBegunPlay() || !IsValid(this))
{
return;
}
Expand Down