summaryrefslogtreecommitdiff
path: root/python/openvino/runtime/streaming/image_streaming_app/layout_transform
diff options
context:
space:
mode:
Diffstat (limited to 'python/openvino/runtime/streaming/image_streaming_app/layout_transform')
-rw-r--r--python/openvino/runtime/streaming/image_streaming_app/layout_transform/CMakeLists.txt35
-rw-r--r--python/openvino/runtime/streaming/image_streaming_app/layout_transform/include/ILayoutTransform.h38
-rw-r--r--python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.cpp51
-rw-r--r--python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.h38
4 files changed, 162 insertions, 0 deletions
diff --git a/python/openvino/runtime/streaming/image_streaming_app/layout_transform/CMakeLists.txt b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/CMakeLists.txt
new file mode 100644
index 0000000..ecbffca
--- /dev/null
+++ b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright 2023 Intel Corporation
+#
+# This software and the related documents are Intel copyrighted materials,
+# and your use of them is governed by the express license under which they
+# were provided to you ("License"). Unless the License provides otherwise,
+# you may not use, modify, copy, publish, distribute, disclose or transmit
+# this software or the related documents without Intel's prior written
+# permission.
+#
+# This software and the related documents are provided as is, with no express
+# or implied warranties, other than those that are expressly stated in the
+# License.
+
+project(layout_transform)
+
+set(header_files "")
+set(source_files "")
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# Header files
+set(header_files ${header_files} "include/ILayoutTransform.h")
+set(header_files ${header_files} "source/LayoutTransform.h")
+
+# Source files
+set(source_files ${source_files} "source/LayoutTransform.cpp")
+
+set(all_files ${header_files} ${source_files})
+
+add_library(${PROJECT_NAME} STATIC ${all_files})
+target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
+target_link_libraries(${PROJECT_NAME} uio)
+
diff --git a/python/openvino/runtime/streaming/image_streaming_app/layout_transform/include/ILayoutTransform.h b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/include/ILayoutTransform.h
new file mode 100644
index 0000000..f54f9d5
--- /dev/null
+++ b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/include/ILayoutTransform.h
@@ -0,0 +1,38 @@
+// Copyright 2023 Intel Corporation.
+//
+// This software and the related documents are Intel copyrighted materials,
+// and your use of them is governed by the express license under which they
+// were provided to you ("License"). Unless the License provides otherwise,
+// you may not use, modify, copy, publish, distribute, disclose or transmit
+// this software or the related documents without Intel's prior written
+// permission.
+//
+// This software and the related documents are provided as is, with no express
+// or implied warranties, other than those that are expressly stated in the
+// License.
+
+#pragma once
+
+#include <cstdint>
+#include <memory>
+
+class ILayoutTransform {
+ public:
+ class Configuration {
+ public:
+ uint32_t _width;
+ uint32_t _height;
+ uint32_t _cVector;
+ float _blueVariance;
+ float _greenVariance;
+ float _redVariance;
+ float _blueShift;
+ float _greenShift;
+ float _redShift;
+ };
+
+ virtual ~ILayoutTransform() {}
+ virtual void SetConfiguration(Configuration& configuration) = 0;
+
+ static std::shared_ptr<ILayoutTransform> Create();
+};
diff --git a/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.cpp b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.cpp
new file mode 100644
index 0000000..a045b6a
--- /dev/null
+++ b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.cpp
@@ -0,0 +1,51 @@
+// Copyright 2023 Intel Corporation.
+//
+// This software and the related documents are Intel copyrighted materials,
+// and your use of them is governed by the express license under which they
+// were provided to you ("License"). Unless the License provides otherwise,
+// you may not use, modify, copy, publish, distribute, disclose or transmit
+// this software or the related documents without Intel's prior written
+// permission.
+//
+// This software and the related documents are provided as is, with no express
+// or implied warranties, other than those that are expressly stated in the
+// License.
+
+#include "LayoutTransform.h"
+#include <thread>
+
+std::shared_ptr<ILayoutTransform> ILayoutTransform::Create() { return std::make_shared<LayoutTransform>(); }
+
+LayoutTransform::LayoutTransform() { _spUioDevice = UIO::IDevice::Load("layout_transform"); }
+
+static uint32_t FloatToUint32(float value) {
+ union FloatAndUint32 {
+ float _floatValue;
+ uint32_t _uint32Value;
+ };
+ FloatAndUint32 convertType;
+ convertType._floatValue = value;
+ return convertType._uint32Value;
+}
+
+void LayoutTransform::SetConfiguration(Configuration& configuration) {
+ _configuration = configuration;
+
+ if (_spUioDevice) {
+ _spUioDevice->Write((uint32_t)RegisterMap::RESET, 1u);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ _spUioDevice->Write((uint32_t)RegisterMap::RESET, 0u);
+
+ _spUioDevice->Write((uint32_t)RegisterMap::C_VECT, _configuration._cVector);
+ _spUioDevice->Write((uint32_t)RegisterMap::WIDTH, _configuration._width);
+ _spUioDevice->Write((uint32_t)RegisterMap::HEIGHT, _configuration._height);
+
+ _spUioDevice->Write((uint32_t)RegisterMap::VARIANCES + 0, FloatToUint32(_configuration._blueVariance));
+ _spUioDevice->Write((uint32_t)RegisterMap::VARIANCES + 1, FloatToUint32(_configuration._greenVariance));
+ _spUioDevice->Write((uint32_t)RegisterMap::VARIANCES + 2, FloatToUint32(_configuration._redVariance));
+
+ _spUioDevice->Write((uint32_t)RegisterMap::SHIFTS + 0, FloatToUint32(_configuration._blueShift));
+ _spUioDevice->Write((uint32_t)RegisterMap::SHIFTS + 1, FloatToUint32(_configuration._greenShift));
+ _spUioDevice->Write((uint32_t)RegisterMap::SHIFTS + 2, FloatToUint32(_configuration._redShift));
+ }
+}
diff --git a/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.h b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.h
new file mode 100644
index 0000000..3d67a5d
--- /dev/null
+++ b/python/openvino/runtime/streaming/image_streaming_app/layout_transform/source/LayoutTransform.h
@@ -0,0 +1,38 @@
+// Copyright 2023 Intel Corporation.
+//
+// This software and the related documents are Intel copyrighted materials,
+// and your use of them is governed by the express license under which they
+// were provided to you ("License"). Unless the License provides otherwise,
+// you may not use, modify, copy, publish, distribute, disclose or transmit
+// this software or the related documents without Intel's prior written
+// permission.
+//
+// This software and the related documents are provided as is, with no express
+// or implied warranties, other than those that are expressly stated in the
+// License.
+
+#pragma once
+#include <memory>
+#include "ILayoutTransform.h"
+#include "IUioDevice.h"
+
+enum class RegisterMap : uint32_t {
+ RESET = 0,
+ C_VECT,
+ WIDTH,
+ HEIGHT,
+ VARIANCES = 0x10, // to 0x1f
+ SHIFTS = 0x20, // to 0x2f
+};
+
+class LayoutTransform : public ILayoutTransform {
+ public:
+ LayoutTransform();
+
+ // ILayoutTransform interface
+ void SetConfiguration(Configuration& configuration) override;
+
+ private:
+ ILayoutTransform::Configuration _configuration = {};
+ std::shared_ptr<UIO::IDevice> _spUioDevice;
+};