Add camera FOV to INI settings file
This commit is contained in:
parent
337483debf
commit
31805d3085
|
@ -34,6 +34,8 @@ PostProcessing=SceneFinal
|
|||
; Size of the captured image in pixels.
|
||||
ImageSizeX=720
|
||||
ImageSizeY=512
|
||||
; Camera field of view in degrees.
|
||||
CameraFOV=90
|
||||
; Position of the camera relative to the car in centimeters.
|
||||
CameraPositionX=170
|
||||
CameraPositionY=0
|
||||
|
|
|
@ -11,11 +11,11 @@ struct FCameraDescription
|
|||
GENERATED_BODY()
|
||||
|
||||
/** X size in pixels of the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly)
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(ClampMin = "1"))
|
||||
uint32 ImageSizeX = 720u;
|
||||
|
||||
/** Y size in pixels of the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly)
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(ClampMin = "1"))
|
||||
uint32 ImageSizeY = 512u;
|
||||
|
||||
/** Position relative to the player. */
|
||||
|
@ -29,4 +29,8 @@ struct FCameraDescription
|
|||
/** Post-process effect to be applied to the captured image. */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly)
|
||||
EPostProcessEffect PostProcessEffect = EPostProcessEffect::SceneFinal;
|
||||
|
||||
/** Camera field of view (in degrees). */
|
||||
UPROPERTY(Category = "Camera Description", EditDefaultsOnly, meta=(DisplayName = "Field of View", ClampMin = "0.001", ClampMax = "360.0"))
|
||||
float FOVAngle = 90.0f;
|
||||
};
|
||||
|
|
|
@ -95,6 +95,7 @@ static void GetCameraDescription(
|
|||
{
|
||||
ConfigFile.GetInt(Section, TEXT("ImageSizeX"), Camera.ImageSizeX);
|
||||
ConfigFile.GetInt(Section, TEXT("ImageSizeY"), Camera.ImageSizeY);
|
||||
ConfigFile.GetInt(Section, TEXT("CameraFOV"), Camera.FOVAngle);
|
||||
ConfigFile.GetInt(Section, TEXT("CameraPositionX"), Camera.Position.X);
|
||||
ConfigFile.GetInt(Section, TEXT("CameraPositionY"), Camera.Position.Y);
|
||||
ConfigFile.GetInt(Section, TEXT("CameraPositionZ"), Camera.Position.Z);
|
||||
|
@ -104,6 +105,13 @@ static void GetCameraDescription(
|
|||
ConfigFile.GetPostProcessEffect(Section, TEXT("PostProcessing"), Camera.PostProcessEffect);
|
||||
}
|
||||
|
||||
static void ValidateCameraDescription(FCameraDescription &Camera)
|
||||
{
|
||||
FMath::Clamp(Camera.FOVAngle, 0.001f, 360.0f);
|
||||
Camera.ImageSizeX = (Camera.ImageSizeX == 0u ? 720u : Camera.ImageSizeX);
|
||||
Camera.ImageSizeY = (Camera.ImageSizeY == 0u ? 512u : Camera.ImageSizeY);
|
||||
}
|
||||
|
||||
static void LoadSettingsFromFile(const FString &FileName, UCarlaSettings &Settings)
|
||||
{
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading settings from \"%s\""), *FileName);
|
||||
|
@ -131,6 +139,8 @@ static void LoadSettingsFromFile(const FString &FileName, UCarlaSettings &Settin
|
|||
Section += SubSection;
|
||||
GetCameraDescription(ConfigFile, *Section, Camera);
|
||||
}
|
||||
|
||||
ValidateCameraDescription(Camera);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,10 +116,17 @@ void ASceneCaptureCamera::SetPostProcessEffect(EPostProcessEffect otherPostProce
|
|||
PostProcessEffect = otherPostProcessEffect;
|
||||
}
|
||||
|
||||
void ASceneCaptureCamera::SetFOVAngle(float FOVAngle)
|
||||
{
|
||||
check(CaptureComponent2D != nullptr);
|
||||
CaptureComponent2D->FOVAngle = FOVAngle;
|
||||
}
|
||||
|
||||
void ASceneCaptureCamera::Set(const FCameraDescription &CameraDescription)
|
||||
{
|
||||
SetImageSize(CameraDescription.ImageSizeX, CameraDescription.ImageSizeY);
|
||||
SetPostProcessEffect(CameraDescription.PostProcessEffect);
|
||||
SetFOVAngle(CameraDescription.FOVAngle);
|
||||
}
|
||||
|
||||
bool ASceneCaptureCamera::ReadPixels(TArray<FColor> &BitMap) const
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
|
||||
void SetPostProcessEffect(EPostProcessEffect PostProcessEffect);
|
||||
|
||||
void SetFOVAngle(float FOVAngle);
|
||||
|
||||
void Set(const FCameraDescription &CameraDescription);
|
||||
|
||||
bool ReadPixels(TArray<FColor> &BitMap) const;
|
||||
|
|
Loading…
Reference in New Issue