From 732887c52ae60be37614c4bfc49461bd9c284bbf Mon Sep 17 00:00:00 2001 From: yanguojin Date: Thu, 19 Oct 2023 16:21:49 +0800 Subject: [PATCH] Simplify the code, remove OpenCvSharp dependencies from the code, and handle common models. --- modules/csharp_api/csharp/core/compiled_model.cs | 3 +-- modules/csharp_api/csharp/core/infer_request.cs | 3 +-- modules/csharp_api/csharp/core/model.cs | 1 - modules/csharp_api/csharp/core/partial_shape.cs | 3 +-- modules/csharp_api/csharp/core/tensor.cs | 6 +++--- modules/csharp_api/csharp/exception/exception.cs | 3 +-- modules/csharp_api/csharp/native_methods/ov_base.cs | 2 +- .../csharp_api/csharp/native_methods/ov_infer_request.cs | 4 +--- 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/modules/csharp_api/csharp/core/compiled_model.cs b/modules/csharp_api/csharp/core/compiled_model.cs index 21facf951..da28319da 100644 --- a/modules/csharp_api/csharp/core/compiled_model.cs +++ b/modules/csharp_api/csharp/core/compiled_model.cs @@ -1,5 +1,4 @@ -using OpenCvSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; diff --git a/modules/csharp_api/csharp/core/infer_request.cs b/modules/csharp_api/csharp/core/infer_request.cs index ff351f286..31ad5d05d 100644 --- a/modules/csharp_api/csharp/core/infer_request.cs +++ b/modules/csharp_api/csharp/core/infer_request.cs @@ -1,5 +1,4 @@ -using OpenCvSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; diff --git a/modules/csharp_api/csharp/core/model.cs b/modules/csharp_api/csharp/core/model.cs index 2bb355daa..f9266baf0 100644 --- a/modules/csharp_api/csharp/core/model.cs +++ b/modules/csharp_api/csharp/core/model.cs @@ -6,7 +6,6 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; -using static OpenCvSharp.FileStorage; namespace OpenVinoSharp { diff --git a/modules/csharp_api/csharp/core/partial_shape.cs b/modules/csharp_api/csharp/core/partial_shape.cs index 5740e7e6e..83769d310 100644 --- a/modules/csharp_api/csharp/core/partial_shape.cs +++ b/modules/csharp_api/csharp/core/partial_shape.cs @@ -1,5 +1,4 @@ -using OpenCvSharp; -using System; +using System; using System.Collections.Generic; using System.Drawing.Drawing2D; using System.Linq; diff --git a/modules/csharp_api/csharp/core/tensor.cs b/modules/csharp_api/csharp/core/tensor.cs index f344d9d37..9d45c54b0 100644 --- a/modules/csharp_api/csharp/core/tensor.cs +++ b/modules/csharp_api/csharp/core/tensor.cs @@ -46,11 +46,11 @@ public Tensor(IntPtr ptr) /// Tensor element type /// Tensor shape /// Image data - public Tensor(element.Type type, Shape shape, OvMat mat) + public Tensor(element.Type type, Shape shape, byte[] mat) { - int l =mat.mat_data.Length; + int l =mat.Length; IntPtr data = Marshal.AllocHGlobal(l); - Marshal.Copy(mat.mat_data, 0, data, (int)mat.mat_data_size); + Marshal.Copy(mat, 0, data, (int)mat.Length); HandleException.handler( NativeMethods.ov_tensor_create_from_host_ptr ((uint)type.get_type(), shape.shape, data, ref m_ptr)); diff --git a/modules/csharp_api/csharp/exception/exception.cs b/modules/csharp_api/csharp/exception/exception.cs index fcee37d34..83e081b1b 100644 --- a/modules/csharp_api/csharp/exception/exception.cs +++ b/modules/csharp_api/csharp/exception/exception.cs @@ -1,5 +1,4 @@ -using OpenCvSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; diff --git a/modules/csharp_api/csharp/native_methods/ov_base.cs b/modules/csharp_api/csharp/native_methods/ov_base.cs index 2ed76b8d6..b53dc3a86 100644 --- a/modules/csharp_api/csharp/native_methods/ov_base.cs +++ b/modules/csharp_api/csharp/native_methods/ov_base.cs @@ -11,6 +11,6 @@ namespace OpenVinoSharp /// public partial class NativeMethods { - private const string dll_extern = "./openvino2023.1/openvino_c.dll"; + private const string dll_extern = "openvino_c"; } } diff --git a/modules/csharp_api/csharp/native_methods/ov_infer_request.cs b/modules/csharp_api/csharp/native_methods/ov_infer_request.cs index 00a66f843..c8c0de851 100644 --- a/modules/csharp_api/csharp/native_methods/ov_infer_request.cs +++ b/modules/csharp_api/csharp/native_methods/ov_infer_request.cs @@ -1,12 +1,10 @@ -using OpenCvSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Threading.Tasks; -using static OpenCvSharp.Stitcher; namespace OpenVinoSharp {