From b256e4120436682280aa6016887e272d4a7a17a9 Mon Sep 17 00:00:00 2001 From: Shital Shah Date: Fri, 15 Dec 2017 18:08:11 -0800 Subject: [PATCH] fixed multi-camera record issue https://github.com/Microsoft/AirSim/issues/685 --- Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp | 4 ++-- Unreal/Plugins/AirSim/Source/UnrealImageCapture.h | 6 ++---- Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp b/Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp index c3455de2b1..2294f03ebb 100644 --- a/Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp +++ b/Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp @@ -5,7 +5,7 @@ #include "NedTransform.h" -UnrealImageCapture::UnrealImageCapture(APIPCamera* cameras[]) +UnrealImageCapture::UnrealImageCapture(const std::vector& cameras) : cameras_(cameras) { //TODO: explore screenshot option @@ -18,7 +18,7 @@ UnrealImageCapture::~UnrealImageCapture() void UnrealImageCapture::getImages(const std::vector& requests, std::vector& responses) { - if (cameras_== nullptr) { + if (cameras_.size() == 0) { for (unsigned int i = 0; i < requests.size(); ++i) { responses.push_back(ImageResponse()); responses[responses.size() - 1].message = "camera is not set"; diff --git a/Unreal/Plugins/AirSim/Source/UnrealImageCapture.h b/Unreal/Plugins/AirSim/Source/UnrealImageCapture.h index ade5f054ec..c35030d010 100644 --- a/Unreal/Plugins/AirSim/Source/UnrealImageCapture.h +++ b/Unreal/Plugins/AirSim/Source/UnrealImageCapture.h @@ -10,12 +10,11 @@ class UnrealImageCapture : public msr::airlib::ImageCaptureBase public: typedef msr::airlib::ImageCaptureBase::ImageType ImageType; - UnrealImageCapture(APIPCamera* cameras[]); + UnrealImageCapture(const std::vector& cameras); virtual ~UnrealImageCapture(); virtual void getImages(const std::vector& requests, std::vector& responses) override; - private: void getSceneCaptureImage(const std::vector& requests, std::vector& responses, bool use_safe_method); @@ -25,8 +24,7 @@ class UnrealImageCapture : public msr::airlib::ImageCaptureBase void updateCameraVisibility(APIPCamera* camera, const msr::airlib::ImageCaptureBase::ImageRequest& request); - private: - APIPCamera** cameras_; + std::vector cameras_; std::vector last_compressed_png_; }; \ No newline at end of file diff --git a/Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp b/Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp index bb32106fdd..5888af6780 100644 --- a/Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp +++ b/Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp @@ -120,7 +120,7 @@ void VehiclePawnWrapper::initialize(APawn* pawn, const std::vector& cameras_ = cameras; config_ = config; - image_capture_.reset(new UnrealImageCapture(cameras_.data())); + image_capture_.reset(new UnrealImageCapture(cameras_)); if (!NedTransform::isInitialized()) NedTransform::initialize(pawn_);