`// Process image private void ProcessImage(Bitmap bitmap){// lock image BitmapData bitmapData = bitmap.LockBits(new Rectangle(0,0,bitmap.Width,bitmap.Height),ImageLockMode.ReadWrite,bitmap.PixelFormat);
// step 2 - locating objects
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 5;
blobCounter.MinWidth = 5;
blobCounter.ObjectsOrder = ObjectsOrder.Size;
blobCounter.ProcessImage(bitmapData);
Blob[] blobs = blobCounter.GetObjectsInformation();
bitmap.UnlockBits(bitmapData);
// step 3 - check objects' type and highlight
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
Graphics g = Graphics.FromImage(bitmap);
Pen redPen = new Pen(Color.Red, 2); // quadrilateral
for (int i = 0, n = blobs.Length; i < n; i++)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
List<IntPoint> corners;
// use the shape checker to extract the corner points
if (shapeChecker.IsQuadrilateral(edgePoints,out corners ))
{
// only do things if the corners form a rectangle
if (shapeChecker.CheckPolygonSubType(corners) == PolygonSubType.Rectangle)
{
g.DrawPolygon(redPen, ToPointsArray(corners));
}
}
}
redPen.Dispose();
g.Dispose();
// put new image to clipboard
Clipboard.SetDataObject(bitmap);
// and to picture box
pictureBox1.Image = bitmap;
}
}`In [this link][0] array of rectangles was detected. Now, my question is how do I extract the rectangle from the image. My scenario is I detect the rectangular License plate of a car (colored image converted to binary ) in the image and draw with red the location of the plate.
现在我想从图像中提取红色绘制的板 . 我怎么做 .
由于我的图像是二值图像,我已应用扩张来获得正确的LP候选,所有候选在图像中被成功识别,但我无法使用 ExtractBiggestBlob
方法提取它们 .
请帮忙 . 提前致谢 .
1 回答
对于非托管数组,使用BitBlt GDI方法 .