Skip to content

Commit

Permalink
fixed multi-camera record issue microsoft#685
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Dec 16, 2017
1 parent 69ebee9 commit b256e41
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Unreal/Plugins/AirSim/Source/UnrealImageCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "NedTransform.h"


UnrealImageCapture::UnrealImageCapture(APIPCamera* cameras[])
UnrealImageCapture::UnrealImageCapture(const std::vector<APIPCamera*>& cameras)
: cameras_(cameras)
{
//TODO: explore screenshot option
Expand All @@ -18,7 +18,7 @@ UnrealImageCapture::~UnrealImageCapture()
void UnrealImageCapture::getImages(const std::vector<msr::airlib::ImageCaptureBase::ImageRequest>& requests,
std::vector<msr::airlib::ImageCaptureBase::ImageResponse>& 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";
Expand Down
6 changes: 2 additions & 4 deletions Unreal/Plugins/AirSim/Source/UnrealImageCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ class UnrealImageCapture : public msr::airlib::ImageCaptureBase
public:
typedef msr::airlib::ImageCaptureBase::ImageType ImageType;

UnrealImageCapture(APIPCamera* cameras[]);
UnrealImageCapture(const std::vector<APIPCamera*>& cameras);
virtual ~UnrealImageCapture();

virtual void getImages(const std::vector<ImageRequest>& requests, std::vector<ImageResponse>& responses) override;


private:
void getSceneCaptureImage(const std::vector<msr::airlib::ImageCaptureBase::ImageRequest>& requests,
std::vector<msr::airlib::ImageCaptureBase::ImageResponse>& responses, bool use_safe_method);
Expand All @@ -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<APIPCamera*> cameras_;
std::vector<uint8_t> last_compressed_png_;
};
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void VehiclePawnWrapper::initialize(APawn* pawn, const std::vector<APIPCamera*>&
cameras_ = cameras;
config_ = config;

image_capture_.reset(new UnrealImageCapture(cameras_.data()));
image_capture_.reset(new UnrealImageCapture(cameras_));

if (!NedTransform::isInitialized())
NedTransform::initialize(pawn_);
Expand Down

0 comments on commit b256e41

Please sign in to comment.