Skip to content

Commit e80a89a

Browse files
committed
add Net.Backend and Net.Target enums
1 parent 56b3c8a commit e80a89a

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

src/OpenCvSharp/Modules/dnn/Net.cs

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,21 +337,21 @@ public void SetHalideScheduler(string scheduler)
337337
/// Ask network to use specific computation backend where it supported.
338338
/// </summary>
339339
/// <param name="backendId">backend identifier.</param>
340-
public void SetPreferableBackend(int backendId)
340+
public void SetPreferableBackend(Backend backendId)
341341
{
342342
ThrowIfDisposed();
343-
NativeMethods.dnn_Net_setPreferableBackend(ptr, backendId);
343+
NativeMethods.dnn_Net_setPreferableBackend(ptr, (int)backendId);
344344
GC.KeepAlive(this);
345345
}
346346

347347
/// <summary>
348348
/// Ask network to make computations on specific target device.
349349
/// </summary>
350350
/// <param name="targetId">target identifier.</param>
351-
public void SetPreferableTarget(int targetId)
351+
public void SetPreferableTarget(Target targetId)
352352
{
353353
ThrowIfDisposed();
354-
NativeMethods.dnn_Net_setPreferableTarget(ptr, targetId);
354+
NativeMethods.dnn_Net_setPreferableTarget(ptr, (int)targetId);
355355
GC.KeepAlive(this);
356356
}
357357

@@ -451,5 +451,45 @@ public long GetPerfProfile(out double[] timings)
451451
}
452452

453453
#endregion
454+
455+
#region Enum
456+
457+
/// <summary>
458+
/// Enum of computation backends supported by layers.
459+
/// </summary>
460+
/// <remarks>
461+
/// DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if
462+
/// OpenCV is built with Intel's Inference Engine library or
463+
/// DNN_BACKEND_OPENCV otherwise.
464+
/// </remarks>
465+
public enum Backend
466+
{
467+
//! DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if
468+
//! OpenCV is built with Intel's Inference Engine library or
469+
//! DNN_BACKEND_OPENCV otherwise.
470+
#pragma warning disable CS1591
471+
DEFAULT,
472+
HALIDE,
473+
INFERENCE_ENGINE,
474+
OPENCV,
475+
VKCOM
476+
#pragma warning restore CS1591
477+
}
478+
479+
/// <summary>
480+
/// Enum of target devices for computations.
481+
/// </summary>
482+
public enum Target
483+
{
484+
#pragma warning disable CS1591
485+
CPU,
486+
OPENCL,
487+
OPENCL_FP16,
488+
MYRIAD,
489+
VULKAN
490+
#pragma warning restore CS1591
491+
}
492+
493+
#endregion
454494
}
455495
}

0 commit comments

Comments
 (0)