Hi
i am using Airsim to simulate drones
everything works good but the problem is when i want to render images from the camera. airsim has a client that i can request images with it easily but its really slow! i have a simple environment and an strong computer but arisim capturing about 5 images per second while i at least need 30!
not many resources in use while running the project and capturing data:
i wanted to figure out why this is happening so i have tried to just save screen shots or use a custom camera and save it’s view. both worked real time for me.
i dont know how can i make this airsim work’s faster, would you help me please?
see this code and this one for more details about how airsim working.
i have tested capturing screen shots in the getSceneCaptureImage instead of its self function to see if its working fast enough but i see this error:
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in UnrealEditor-Win64-DebugGame.exe.
and its the code i am trying to save screenshots with it:
UGameViewportClient* GameViewport = GEngine->GameViewport;
static int counter = 0; // Use static to maintain the counter across function calls
if (GameViewport)
{
FViewport* Viewport = GameViewport->Viewport;
TArray<FColor> Bitmap;
if (Viewport->ReadPixels(Bitmap))
{
int32 Width = Viewport->GetSizeXY().X;
int32 Height = Viewport->GetSizeXY().Y;
// Declare CompressedBitmap
TArray<uint8> CompressedBitmap;
counter++;
// Create the file path
std::string filePath = "C:/Users/AI-Control Lab/Pictures/Saved Pictures/OpenCVTestImage" + std::to_string(counter) + ".png";
// Compress the image
FImageUtils::CompressImageArray(Width, Height, Bitmap, CompressedBitmap);
// Convert std::string to FString
FString FilePathFString(filePath.c_str());
// Save the compressed image to the file
bool bSuccess = FFileHelper::SaveArrayToFile(CompressedBitmap, *FilePathFString);
if (bSuccess)
{
UE_LOG(LogTemp, Warning, TEXT("Screenshot saved as %s"), *FilePathFString);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to save screenshot as %s"), *FilePathFString);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Viewport->ReadPixels failed"));
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("GEngine->GameViewport is null"));
}
thanks for you time.
Reza