public BoundingBox[] Detect(byte[] imageData) { var container = new BboxContainer(); var size = Marshal.SizeOf(imageData[0]) * imageData.Length; var pnt = Marshal.AllocHGlobal(size); try { Marshal.Copy(imageData, 0, pnt, imageData.Length); var count = DetectImage(pnt, imageData.Length, ref container); if (count == -1) { throw new NotSupportedException($"{YoloLibraryName} has no OpenCV support"); } } catch (Exception exception) { return(null); } finally { Marshal.FreeHGlobal(pnt); } return(container.candidates); }
public BoundingBox[] Detect(string filename) { var container = new BboxContainer(); var count = DetectImage(filename, ref container); return(container.candidates); }
private static extern int DetectImage(IntPtr pArray, int nSize, ref BboxContainer container);
private static extern int DetectImage(string filename, ref BboxContainer container);