2019-04-12 18:25:53 +03:00
|
|
|
// Copyright (C) 2018-2019 Intel Corporation
|
2018-10-16 13:45:03 +03:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include <ie_preprocess.hpp>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
class PreProcessTests : public ::testing::Test {
|
|
|
|
|
protected:
|
|
|
|
|
virtual void TearDown() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(PreProcessTests, throwsOnSettingNullMeanImage) {
|
|
|
|
|
InferenceEngine::PreProcessInfo info;
|
|
|
|
|
info.init(1);
|
|
|
|
|
ASSERT_THROW(info.setMeanImage(InferenceEngine::Blob::Ptr(nullptr)),
|
|
|
|
|
InferenceEngine::details::InferenceEngineException);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PreProcessTests, throwsOnSetting2DMeanImage) {
|
|
|
|
|
InferenceEngine::PreProcessInfo info;
|
|
|
|
|
info.init(1);
|
2019-08-09 19:02:42 +03:00
|
|
|
InferenceEngine::Blob::Ptr blob(new InferenceEngine::TBlob<float>({ InferenceEngine::Precision::FP32,
|
|
|
|
|
{1, 1}, InferenceEngine::Layout::HW}));
|
2018-10-16 13:45:03 +03:00
|
|
|
ASSERT_THROW(info.setMeanImage(blob), InferenceEngine::details::InferenceEngineException);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PreProcessTests, throwsOnSettingWrongSizeMeanImage) {
|
|
|
|
|
InferenceEngine::PreProcessInfo info;
|
|
|
|
|
info.init(1);
|
2019-08-09 19:02:42 +03:00
|
|
|
InferenceEngine::TBlob<float>::Ptr blob(new InferenceEngine::TBlob<float>({ InferenceEngine::Precision::FP32,
|
|
|
|
|
{ 2, 1, 1 }, InferenceEngine::Layout::CHW }));
|
|
|
|
|
IE_SUPPRESS_DEPRECATED_START
|
2018-10-16 13:45:03 +03:00
|
|
|
blob->set({ 1.f, 2.f });
|
2019-08-09 19:02:42 +03:00
|
|
|
IE_SUPPRESS_DEPRECATED_END
|
2018-10-16 13:45:03 +03:00
|
|
|
ASSERT_THROW(info.setMeanImage(blob), InferenceEngine::details::InferenceEngineException);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PreProcessTests, noThrowWithCorrectSizeMeanImage) {
|
|
|
|
|
InferenceEngine::PreProcessInfo info;
|
|
|
|
|
info.init(2);
|
2019-08-09 19:02:42 +03:00
|
|
|
InferenceEngine::TBlob<float>::Ptr blob(new InferenceEngine::TBlob<float>({ InferenceEngine::Precision::FP32,
|
|
|
|
|
{ 2, 1, 1 }, InferenceEngine::Layout::CHW }));
|
|
|
|
|
IE_SUPPRESS_DEPRECATED_START
|
2018-10-16 13:45:03 +03:00
|
|
|
blob->set({ 1.f, 2.f });
|
2019-08-09 19:02:42 +03:00
|
|
|
IE_SUPPRESS_DEPRECATED_END
|
2018-10-16 13:45:03 +03:00
|
|
|
ASSERT_NO_THROW(info.setMeanImage(blob));
|
|
|
|
|
}
|