diff --git a/LibCarla/source/carla/sensor/data/DVSEventArray.h b/LibCarla/source/carla/sensor/data/DVSEventArray.h index b44d0db35..2150e644f 100644 --- a/LibCarla/source/carla/sensor/data/DVSEventArray.h +++ b/LibCarla/source/carla/sensor/data/DVSEventArray.h @@ -9,6 +9,7 @@ #include "carla/Debug.h" #include "carla/sensor/data/Array.h" #include "carla/sensor/data/DVSEvent.h" +#include "carla/sensor/data/Color.h" #include "carla/sensor/s11n/DVSEventArraySerializer.h" namespace carla { @@ -16,7 +17,7 @@ namespace sensor { namespace data { /// An array of DVS Events in an image structure HxW - class DVSEventArray : public Array { + class DVSEventArray : public Array { using Super = Array; protected: @@ -51,6 +52,22 @@ namespace data { auto GetFOVAngle() const { return GetHeader().fov_angle; } + + std::vector ToImage() const { + std::vector img(GetHeight() * GetWidth()); + for (const auto &event : *this) { + size_t index = (GetWidth() * event.y) + event.x; + if (event.pol == true) { + // Blue is positive + img[index].b = 255u; + } else { + // Red is negative + img[index].r = 255u; + } + } + return img; + } + }; } // namespace data diff --git a/PythonAPI/carla/source/libcarla/SensorData.cpp b/PythonAPI/carla/source/libcarla/SensorData.cpp index a6784ace3..3f1845c51 100644 --- a/PythonAPI/carla/source/libcarla/SensorData.cpp +++ b/PythonAPI/carla/source/libcarla/SensorData.cpp @@ -319,12 +319,6 @@ void export_sensor_data() { .def(self_ns::str(self_ns::self)) ; - class_ >("ColorVector") - .add_property("raw_data", &GetRawDataAsBuffer< std::vector >) - .def("__len__", &std::vector::size) - .def(vector_indexing_suite< std::vector >()) - ; - class_>("IntVector") .add_property("raw_data", &GetRawDataAsBuffer< std::vector >) .def("__len__", &std::vector::size) @@ -364,25 +358,7 @@ void export_sensor_data() { .def("__setitem__", +[](csd::DVSEventArray &self, size_t pos, csd::DVSEvent event) { self.at(pos) = event; }) - .def("to_image", +[](const csd::DVSEventArray &self) -> std::vector { - std::vector img (self.GetHeight() * self.GetWidth()); - for (size_t i=0; i std::vector> { std::vector> array (self.size()); for (size_t i=0; i