[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void NewDataCallback(IntPtr data, IntPtr info, IntPtr user_data);
+ /* typedef int (*ml_custom_easy_invoke_cb) (const ml_tensors_data_h in, ml_tensors_data_h out, void *user_data); */
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void CustomEasyInvokeCallback(IntPtr in_data, IntPtr out_data, IntPtr user_data);
+
/* int ml_pipeline_construct (const char *pipeline_description, ml_pipeline_state_cb cb, void *user_data, ml_pipeline_h *pipe); */
[DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_construct", CallingConvention = CallingConvention.Cdecl)]
internal static extern NNStreamerError Construct(string pipeline_description, StateChangedCallback callback, IntPtr user_data, out IntPtr pipeline_handle);
/* int ml_pipeline_switch_select (ml_pipeline_switch_h switch_handle, const char *pad_name); */
[DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_switch_select", CallingConvention = CallingConvention.Cdecl)]
internal static extern NNStreamerError SelectSwitchPad(IntPtr switch_handle, string pad_name);
+
+ /* int ml_pipeline_custom_easy_filter_register (const char *name, const ml_tensors_info_h in, const ml_tensors_info_h out, ml_custom_easy_invoke_cb cb, void *user_data, ml_custom_easy_filter_h *custom); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_custom_easy_filter_register", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError RegisterCustomFilter(string name, IntPtr input_info, IntPtr output_info, CustomEasyInvokeCallback callback, IntPtr user_data, out IntPtr custom_handle);
+
+ /* int ml_pipeline_custom_easy_filter_unregister (ml_custom_easy_filter_h custom); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_custom_easy_filter_unregister", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError UnregisterCustomFilter(IntPtr custom_handle);
+
+ /* int ml_pipeline_element_get_handle (ml_pipeline_h pipe, const char *element_name, ml_pipeline_element_h *elem_h); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_handle", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetElementHandle(IntPtr pipeline_handle, string element_name, out IntPtr element_handle);
+
+ /* int ml_pipeline_element_release_handle (ml_pipeline_element_h elem_h); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_release_handle", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError ReleaseElementHandle(IntPtr element_handle);
+
+ /* int ml_pipeline_element_set_property_bool (ml_pipeline_element_h elem_h, const char *property_name, const int32_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_bool", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyBool(IntPtr element_handle, string property_name, int value);
+
+ /* int ml_pipeline_element_set_property_string (ml_pipeline_element_h elem_h, const char *property_name, const char *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_string", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyString(IntPtr element_handle, string property_name, string value);
+
+ /* int ml_pipeline_element_set_property_int32 (ml_pipeline_element_h elem_h, const char *property_name, const int32_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_int32", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyInt32(IntPtr element_handle, string property_name, int value);
+
+ /* int ml_pipeline_element_set_property_int64 (ml_pipeline_element_h elem_h, const char *property_name, const int64_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_int64", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyInt64(IntPtr element_handle, string property_name, long value);
+
+ /* int ml_pipeline_element_set_property_uint32 (ml_pipeline_element_h elem_h, const char *property_name, const uint32_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_uint32", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyUInt32(IntPtr element_handle, string property_name, uint value);
+
+ /* int ml_pipeline_element_set_property_uint64 (ml_pipeline_element_h elem_h, const char *property_name, const uint64_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_uint64", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyUInt64(IntPtr element_handle, string property_name, ulong value);
+
+ /* int ml_pipeline_element_set_property_double (ml_pipeline_element_h elem_h, const char *property_name, const double value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_double", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyDouble(IntPtr element_handle, string property_name, double value);
+
+ /* int ml_pipeline_element_set_property_enum (ml_pipeline_element_h elem_h, const char *property_name, const uint32_t value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_set_property_enum", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError SetPropertyEnum(IntPtr element_handle, string property_name, uint value);
+
+ /* int ml_pipeline_element_get_property_bool (ml_pipeline_element_h elem_h, const char *property_name, int32_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_bool", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyBool(IntPtr element_handle, string property_name, out int value);
+
+ /* int ml_pipeline_element_get_property_string (ml_pipeline_element_h elem_h, const char *property_name, char **value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_string", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyString(IntPtr element_handle, string property_name, out string value);
+
+ /* int ml_pipeline_element_get_property_int32 (ml_pipeline_element_h elem_h, const char *property_name, int32_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_int32", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyInt32(IntPtr element_handle, string property_name, out int value);
+
+ /* int ml_pipeline_element_get_property_int64 (ml_pipeline_element_h elem_h, const char *property_name, int64_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_int64", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyInt64(IntPtr element_handle, string property_name, out long value);
+
+ /* int ml_pipeline_element_get_property_uint32 (ml_pipeline_element_h elem_h, const char *property_name, uint32_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_uint32", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyUInt32(IntPtr element_handle, string property_name, out uint value);
+
+ /* int ml_pipeline_element_get_property_uint64 (ml_pipeline_element_h elem_h, const char *property_name, uint64_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_uint64", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyUInt64(IntPtr element_handle, string property_name, out ulong value);
+
+ /* int ml_pipeline_element_get_property_double (ml_pipeline_element_h elem_h, const char *property_name, double *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_double", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyDouble(IntPtr element_handle, string property_name, out double value);
+
+ /* int ml_pipeline_element_get_property_enum (ml_pipeline_element_h elem_h, const char *property_name, uint32_t *value); */
+ [DllImport(Libraries.Nnstreamer, EntryPoint = "ml_pipeline_element_get_property_enum", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern NNStreamerError GetPropertyEnum(IntPtr element_handle, string property_name, out uint value);
}
internal static partial class SingleShot
--- /dev/null
+/*
+* Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.MachineLearning.Inference
+{
+ /// <summary>
+ /// The CustomFilter class provides interfaces to create a custom-filter in the pipeline.
+ /// </summary>
+ /// <remarks>
+ /// Because of data translation (i.e. marshaling and unmarshaling ) between Native and .Net Layer, CustomFilter class shows lower performance than native implementation.
+ /// </remarks>
+ /// <since_tizen> 8 </since_tizen>
+ public class CustomFilter : IDisposable
+ {
+ private Interop.Pipeline.CustomEasyInvokeCallback _nativeCallback;
+ private Func<TensorsData, TensorsData> _filter;
+
+ private TensorsInfo _InInfo;
+ private TensorsInfo _OutInfo;
+ private bool _disposed = false;
+
+ /// <summary>
+ /// Internally gets and sets the the native handle of custom filter.
+ /// </summary>
+ /// <since_tizen> 8 </since_tizen>
+ internal IntPtr Handle { get; set; }
+
+ /// <summary>
+ /// Gets or internally sets the name of the CustomFilter
+ /// </summary>
+ public string Name { get; internal set; }
+
+ /// <summary>
+ /// Creates new custom-filter with input and output tensors information.
+ /// </summary>
+ /// <param name="name">The name of custom-filter</param>
+ /// <param name="inInfo">The input tensors information</param>
+ /// <param name="outInfo">The output tensors information</param>
+ /// <param name="filter">Delegate to be called while processing the pipeline</param>
+ /// <returns>CustomFiter instance</returns>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public static CustomFilter Create(string name,
+ TensorsInfo inInfo, TensorsInfo outInfo, Func<TensorsData, TensorsData> filter)
+ {
+ NNStreamer.CheckNNStreamerSupport();
+
+ return new CustomFilter(name, inInfo, outInfo, filter);
+ }
+
+ /// <summary>
+ /// Releases any unmanaged resources used by this object.
+ /// </summary>
+ /// <since_tizen> 8 </since_tizen>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ /// <summary>
+ /// Releases any unmanaged resources used by this object including opened handle.
+ /// </summary>
+ /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+ /// <since_tizen> 8 </since_tizen>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+
+ if (disposing)
+ {
+ // release managed objects
+ }
+
+ // release unmanaged objects
+ if (Handle != IntPtr.Zero)
+ {
+ NNStreamerError ret = Interop.Pipeline.UnregisterCustomFilter(Handle);
+ if (ret != NNStreamerError.None)
+ Log.Error(NNStreamer.TAG, "failed to destroy CustomFilter object");
+
+ Handle = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+
+ private CustomFilter(string name, TensorsInfo inInfo, TensorsInfo outInfo, Func<TensorsData, TensorsData> filter)
+ {
+ /* Parameger check */
+ if (name == null)
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Given name is null");
+
+ if (inInfo == null || outInfo == null)
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Given TensorsInfo is null");
+
+ if (filter == null)
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Given Callback interface is null");
+
+ _nativeCallback = (in_data_handle, out_data_handle, _) =>
+ {
+ TensorsData inData = TensorsData.CreateFromNativeHandle(in_data_handle, IntPtr.Zero, true, false);
+ TensorsData outData = _filter(inData);
+ out_data_handle = outData.GetHandle();
+ };
+
+ IntPtr handle = IntPtr.Zero;
+
+ /* Create custom filter callback */
+ NNStreamerError ret = Interop.Pipeline.RegisterCustomFilter(name,
+ inInfo.GetTensorsInfoHandle(), outInfo.GetTensorsInfoHandle(), _nativeCallback, IntPtr.Zero, out handle);
+ NNStreamer.CheckException(ret, "Failed to create custom filter function: " + name);
+
+ /* Set internal member */
+ _InInfo = inInfo;
+ _OutInfo = outInfo;
+ _filter = filter;
+
+ Name = name;
+ Handle = handle;
+ }
+ }
+}
using System;
using System.Collections.Generic;
+using System.Text;
namespace Tizen.MachineLearning.Inference
{
}
/// <summary>
+ /// Gets the normal node instance with given node name.
+ /// </summary>
+ /// <param name="name">The name of normal node.</param>
+ /// <returns>The normal node instance</returns>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public Node GetNormal(string name)
+ {
+ NNStreamer.CheckNNStreamerSupport();
+
+ /* Check the parameter */
+ if (string.IsNullOrEmpty(name))
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Node name is invalid");
+
+ Node node;
+ if (_nodeList.ContainsKey(name))
+ {
+ if (_nodeList[name].Type != NodeType.Normal)
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, name + " is not a normal node");
+
+ node = (Node)_nodeList[name];
+ }
+ else
+ {
+ node = new Node(name, this);
+ _nodeList.Add(name, node);
+ }
+ return node;
+ }
+
+
+ /// <summary>
/// SwitchNode class to handle the switch node.
/// </summary>
/// <since_tizen> 8 </since_tizen>
}
/// <summary>
+ /// Node class to handle the properties of NNStreamer pipelines.
+ /// </summary>
+ /// <since_tizen> 8 </since_tizen>
+ public class Node : NodeInfo
+ {
+ internal Node(string name, Pipeline pipe) : base(NodeType.Normal, name, pipe)
+ {
+ IntPtr handle = IntPtr.Zero;
+
+ NNStreamerError ret = Interop.Pipeline.GetElementHandle(pipe.GetHandle(), name, out handle);
+ NNStreamer.CheckException(ret, "Failed to get the pipeline node handle: " + name);
+
+ Handle = handle;
+ }
+ }
+
+ /// <summary>
/// Node type of NNStreamer pipeline.
/// </summary>
/// <since_tizen> 8 </since_tizen>
/// The switch node.
/// </summary>
Switch = 3,
+ /// <summary>
+ /// The normal node of the pipeline.
+ /// </summary>
+ Normal = 4,
}
/// <summary>
/// </summary>
/// <since_tizen> 8 </since_tizen>
public bool Valid { get; internal set; }
+
+ private void CheckGetParam(string propertyName)
+ {
+ NNStreamer.CheckNNStreamerSupport();
+
+ if (string.IsNullOrEmpty(propertyName))
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Property name is invalid");
+ }
+
+ private void CheckSetParam(string propertyName, object value)
+ {
+ NNStreamer.CheckNNStreamerSupport();
+
+ if (string.IsNullOrEmpty(propertyName))
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Property name is invalid");
+
+ if (value is null)
+ throw NNStreamerExceptionFactory.CreateException(NNStreamerError.InvalidParameter, "Value is invalid");
+ }
+
+ /// <summary>
+ /// Gets the boolean of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a boolean value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out bool retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyBool(Handle, propertyName, out int value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value == 0 ? false : true;
+ }
+
+ /// <summary>
+ /// Gets the string of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a string value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out string retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyString(Handle, propertyName, out string value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Gets the integer (i.e. System.Int32) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a integer value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out int retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyInt32(Handle, propertyName, out int value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Gets the long integer (i.e. System.Int64) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a long integer value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out long retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyInt64(Handle, propertyName, out long value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Gets the unsigned integer (i.e. System.UInt32) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a unsigned integer value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out uint retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyUInt32(Handle, propertyName, out uint value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Gets the unsigned long integer (i.e. System.UInt64) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a unsigned long integer value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out ulong retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyUInt64(Handle, propertyName, out ulong value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Gets the floating-point value of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="retValue">On return, a floating-point value.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void GetValue(string propertyName, out double retValue)
+ {
+ CheckGetParam(propertyName);
+
+ NNStreamerError ret = Interop.Pipeline.GetPropertyDouble(Handle, propertyName, out double value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ retValue = value;
+ }
+
+ /// <summary>
+ /// Get the value of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <typeparam name="T">The value type of given property.</typeparam>
+ /// <param name="propertyName">The property name.</param>
+ /// <returns>The value of given property.</returns>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public T GetValue<T>(string propertyName)
+ {
+ NNStreamerError ret;
+ CheckGetParam(propertyName);
+
+ if (typeof(bool).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyBool(Handle, propertyName, out int value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value == 0 ? false : true, typeof(T));
+ }
+ else if (typeof(string).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyString(Handle, propertyName, out string value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value, typeof(T));
+ }
+ else if (typeof(int).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyInt32(Handle, propertyName, out int value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value, typeof(T));
+ }
+ else if (typeof(long).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyInt64(Handle, propertyName, out long value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value, typeof(T));
+ }
+ else if (typeof(uint).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyUInt32(Handle, propertyName, out uint value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value, typeof(T));
+ }
+ else if (typeof(ulong).IsAssignableFrom(typeof(T)))
+ {
+ ret = Interop.Pipeline.GetPropertyUInt64(Handle, propertyName, out ulong value);
+ NNStreamer.CheckException(ret, string.Format("Failed to get {0} property.", propertyName));
+
+ return (T)Convert.ChangeType(value, typeof(T));
+ }
+
+ throw new ArgumentException("The Input data type is not valid.");
+ }
+
+ /// <summary>
+ /// Sets the boolean of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The boolean value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, bool value)
+ {
+ CheckSetParam(propertyName, value);
+ int setValue = value ? 1 : 0;
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyBool(Handle, propertyName, setValue);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Sets the string of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The string of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, string value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyString(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Sets the integer (i.e. System.Int32) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The integer value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, int value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyInt32(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Sets the long integer (i.e. System.Int64) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The long integer value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, long value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyInt64(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Sets the unsigned integer (i.e. System.UInt32) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The unsigned integer value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, uint value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyUInt32(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Sets the unsigned long integer (i.e. System.UInt64) of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The unsigned long integer value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, ulong value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyUInt64(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
+
+ /// <summary>
+ /// Gets the floating-point value of node's property in NNStreamer pipelines.
+ /// </summary>
+ /// <param name="propertyName">The property name.</param>
+ /// <param name="value">The floating-point value of given property.</param>
+ /// <feature>http://tizen.org/feature/machine_learning.inference</feature>
+ /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
+ /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+ /// <since_tizen> 8 </since_tizen>
+ public void SetValue(string propertyName, double value)
+ {
+ CheckSetParam(propertyName, value);
+
+ NNStreamerError ret = Interop.Pipeline.SetPropertyDouble(Handle, propertyName, value);
+ NNStreamer.CheckException(ret, string.Format("Failed to set {0} property.", propertyName));
+ }
}
}
}