26 return 0.2989 * Color.R + 0.587 * Color.G + 0.114 * Color.B;
30 : Super(ObjectInitializer)
34 TEXT(
"Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
36 RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT(
"RandomEngine"));
43 constexpr bool bEnableModifyingPostProcessEffects =
true;
47 Cp.
Id = TEXT(
"positive_threshold");
53 Cm.
Id = TEXT(
"negative_threshold");
59 Sigma_Cp.
Id = TEXT(
"sigma_positive_threshold");
65 Sigma_Cm.
Id = TEXT(
"sigma_negative_threshold");
71 Refractory_Period.
Id = TEXT(
"refractory_period_ns");
77 Use_Log.
Id = TEXT(
"use_log");
83 Log_EPS.
Id = TEXT(
"log_eps");
88 Definition.Variations.Append({ Cp, Cm, Sigma_Cp, Sigma_Cm, Refractory_Period, Use_Log, Log_EPS });
95 Super::Set(Description);
103 "negative_threshold",
108 "sigma_positive_threshold",
113 "sigma_negative_threshold",
118 "refractory_period_ns",
138 if (!HasActorBegunPlay() || IsPendingKill())
149 TArray<FColor> RawImage;
166 auto Buff =
Stream.PopBufferFromPool();
173 #if defined(WITH_ROS2)
175 if (ROS2->IsEnabled())
177 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"ROS2 Send");
184 if (WidthOpt.has_value())
185 W = FCString::Atoi(*WidthOpt->Value);
187 if (HeightOpt.has_value())
188 H = FCString::Atoi(*HeightOpt->Value);
190 if (FovOpt.has_value())
191 Fov = FCString::Atof(*FovOpt->Value);
192 AActor* ParentActor = GetAttachParentActor();
195 FTransform LocalTransformRelativeToParent = GetActorTransform().GetRelativeTransform(ParentActor->GetActorTransform());
196 ROS2->ProcessDataFromDVS(
Stream.
GetSensorType(), StreamId, LocalTransformRelativeToParent, BufView, W, H, Fov,
this);
205 if (events.size() > 0)
207 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"ADVSCamera Stream Send");
209 Stream.Send(*
this, BufView);
217 if (image.Num() != (this->GetImageHeight() * this->GetImageWidth()))
224 for (
size_t i = 0; i < image.Num(); ++i)
234 if (image.Num() != (this->GetImageHeight() * this->GetImageWidth()))
241 for (
size_t i = 0; i < image.Num(); ++i)
256 if (this->
last_image.Num() != (this->GetImageHeight() * this->GetImageWidth()))
275 static constexpr float tolerance = 1e-6;
291 if (std::fabs (it - itdt) > tolerance)
295 const float pol = (itdt >= it) ? +1.0 : -1.0;
302 constexpr float minimum_contrast_threshold = 0.01;
303 C = std::max(minimum_contrast_threshold, C);
305 float curr_cross = prev_cross;
306 bool all_crossings =
false;
310 curr_cross += pol * C;
312 if ((pol > 0 && curr_cross > it && curr_cross <= itdt)
313 || (pol < 0 && curr_cross < it && curr_cross >= itdt))
315 const std::uint64_t edt = (curr_cross - it) * delta_t_ns / (itdt - it);
321 if (t >= last_stamp_at_xy)
323 const std::uint64_t dt = t - last_stamp_at_xy;
338 all_crossings =
true;
340 }
while (!all_crossings);
351 std::sort(events.begin(), events.end(), [](const ::carla::sensor::data::DVSEvent& it1, const ::carla::sensor::data::DVSEvent& it2){return it1.t < it2.t;});
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
static float FColorToGrayScaleFloat(FColor Color)
std::vector<::carla::sensor::data::DVSEvent > DVSEventArray
ADVSCamera(const FObjectInitializer &ObjectInitializer)
TArray< float > prev_image
dvs::Config config
动态时间传感器的仿真配置
void Set(const FActorDescription &ActorDescription) override
TArray< double > last_event_timestamp
包含以秒为单位的最新事件时间的图像
ADVSCamera::DVSEventArray Simulation(float DeltaTime)
static FActorDefinition GetSensorDefinition()
void ImageToLogGray(const TArray< FColor > &image)
TArray< float > last_image
包含最新(当前)图像和先前图像的图像
void ImageToGray(const TArray< FColor > &image)
TArray< float > ref_values
包含触发事件最新参考值的图像
virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime) override
std::int64_t current_time
以纳秒为单位的当前时间
bool ReadPixels(TArray< FColor > &BitMap) const
Use for debugging purposes only.
void EnablePostProcessingEffects(bool Enable=true)
UTextureRenderTarget2D * CaptureRenderTarget
Render target necessary for scene capture.
void EnqueueRenderSceneImmediate()
Immediate enqueues render commands of the scene at the current time.
uint32 GetImageHeight() const
uint32 GetImageWidth() const
void WaitForRenderThreadToFinish()
Blocks until the render thread has finished all it's tasks.
boost::optional< FActorAttribute > GetAttribute(const FString Name)
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
FAsyncDataStream GetDataStream(const SensorT &Self)
Return the FDataStream associated with this sensor.
URandomEngine * RandomEngine
Random Engine used to provide noise for sensor output.
const UCarlaEpisode & GetEpisode() const
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight.
static int32 RetrieveActorAttributeToInt(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, int32 Default)
从参与者属性映射中检索整数,如果不存在则返回默认值。
static bool RetrieveActorAttributeToBool(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, bool Default)
从参与者属性映射中检索布尔值,如果不存在则返回默认值。
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
创建一个相机参与者定义。
static float RetrieveActorAttributeToFloat(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, float Default)
float GetNormalDistribution(float Mean, float StandardDeviation)
static std::shared_ptr< BufferView > CreateFrom(Buffer &&buffer)
一块原始数据。 请注意,如果需要更多容量,则会分配一个新的内存块,并 删除旧的内存块。这意味着默认情况下,缓冲区只能增长。要释放内存,使用 clear 或 pop。
static std::shared_ptr< ROS2 > GetInstance()
static Buffer Serialize(Sensor &sensor, Args &&... args)
Serialize the arguments provided into a Buffer by calling to the serializer registered for the given ...
静态断言,用于确保token_data结构体的大小与Token::data的大小相同。
const auto & get_stream_id() const
获取流ID的引用。
std::shared_ptr< BufferView > SharedBufferView
constexpr std::int64_t secToNanosec(double seconds)
constexpr double nanosecToSecTrunc(std::int64_t nanoseconds)
TMap< FString, FActorAttribute > Variations
用户选择了参与者的变化版本。请注意,此时是 由不可修改的属性表示
Definition of an actor variation.
TArray< FString > RecommendedValues
bool bRestrictToRecommended
std::uint64_t refractory_period_ns