public List <Shape> ProcessFrame(Bitmap cam) { unsafe { MyShapeListElement *shapes = processFrame(cam, this.background); List <Shape> ret = new List <Shape>(); MyShapeListElement *current = shapes; while (current->next != null) { ret.Add(new Shape(new Point(current->shape.pos.X, current->shape.pos.Y), current->shape.scale, current->shape.rot, current->shape.index)); MyContourPoint *curp = current->shape.contour; while (curp->next != null) { ret.Last().contour.Add(new Point(curp->pos.X, curp->pos.Y)); curp = curp->next; } current = current->next; } delete_shape_list_D(shapes); return(ret); } }
public Shape GetContour() { BitmapData data = im.LockBits(new Rectangle(0, 0, im.Width, im.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Shape shape = null; unsafe { MyImage img = new MyImage((uint *)data.Scan0.ToPointer(), im.Width, im.Height); MyImage img2; clone_image_N(img, &img2); binarize2(img2, true); closing(img2); MyShapeListElement *shapeList = null; real_contour_N(img2, &shapeList); if ((shapeList != null) && (shapeList->next != null)) { normalize_shape(&(shapeList->shape)); MyShape current = shapeList->shape; shape = new Shape(new Point(current.pos.X, current.pos.Y), current.scale, current.rot, current.index); MyContourPoint *curp = current.contour; while (curp->next != null) { shape.contour.Add(new Point(curp->pos.X, curp->pos.Y)); curp = curp->next; } } delete_shape_list_D(shapeList); delete_image_D(img2); } im.UnlockBits(data); if (shape != null) { return(shape); } else { return(null); } }
private static extern unsafe void delete_shape_list_D(MyShapeListElement *shapeList);