public static Mat ImDecode(byte[] buffer, CvLoadImage flags = CvLoadImage.Color) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } var error = NativeMethods.opencv_imdecode(buffer, buffer.Length, (int)flags, out var ret); if (error != NativeMethods.ErrorType.OK) { throw new NcnnException("Unknown Exception"); } return(new Mat(ret)); }
public static Mat ImRead(string fileName, CvLoadImage flags = CvLoadImage.Color) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException(nameof(fileName)); } if (!File.Exists(fileName)) { throw new FileNotFoundException("The specified file does not exist.", fileName); } var str = Ncnn.Encoding.GetBytes(fileName); var error = NativeMethods.opencv_imread(str, str.Length, (int)flags, out var ret); if (error != NativeMethods.ErrorType.OK) { throw new NcnnException("Unknown Exception"); } return(new Mat(ret)); }