public async void Quadraliteral(StorageFile file, IList <WF.Point> points) { var data = await FileIO.ReadBufferAsync(file); OpencvImageProcess opencv = new OpencvImageProcess(); // create a stream from the file var ms = new InMemoryRandomAccessStream(); var dw = new DataWriter(ms); dw.WriteBuffer(data); await dw.StoreAsync(); ms.Seek(0); // find out how big the image is, don't need this if you already know var bm = new BitmapImage(); await bm.SetSourceAsync(ms); // create a writable bitmap of the right size var wb = new WriteableBitmap(bm.PixelWidth, bm.PixelHeight); ms.Seek(0); // load the writable bitpamp from the stream await wb.SetSourceAsync(ms); Bitmap bmp = (Bitmap)wb; var wb1 = opencv.GetImageCorners(wb); wb1.Invalidate(); //wb.Invalidate(); // define quadrilateral's corners //List<IntPoint> corners = new List<IntPoint>(); //foreach (var point in points) //{ // corners.Add(new IntPoint((int)point.X, (int)point.Y)); //} //// create filter //var filter = // new SimpleQuadrilateralTransformation(corners); //// apply the filter //Bitmap newImage = filter.Apply(bmp); //wb = (WriteableBitmap)newImage; var f = await this.WriteableBitmapToStorageFile(wb1, FileFormat.Jpeg); }
public async void Quadraliteral(StorageFile file, IList<WF.Point> points) { var data = await FileIO.ReadBufferAsync(file); OpencvImageProcess opencv = new OpencvImageProcess(); // create a stream from the file var ms = new InMemoryRandomAccessStream(); var dw = new DataWriter(ms); dw.WriteBuffer(data); await dw.StoreAsync(); ms.Seek(0); // find out how big the image is, don't need this if you already know var bm = new BitmapImage(); await bm.SetSourceAsync(ms); // create a writable bitmap of the right size var wb = new WriteableBitmap(bm.PixelWidth, bm.PixelHeight); ms.Seek(0); // load the writable bitpamp from the stream await wb.SetSourceAsync(ms); Bitmap bmp = (Bitmap)wb; var wb1 = opencv.GetImageCorners(wb); wb1.Invalidate(); //wb.Invalidate(); // define quadrilateral's corners //List<IntPoint> corners = new List<IntPoint>(); //foreach (var point in points) //{ // corners.Add(new IntPoint((int)point.X, (int)point.Y)); //} //// create filter //var filter = // new SimpleQuadrilateralTransformation(corners); //// apply the filter //Bitmap newImage = filter.Apply(bmp); //wb = (WriteableBitmap)newImage; var f = await this.WriteableBitmapToStorageFile(wb1, FileFormat.Jpeg); }