public TrackPointContext(CvSize imageSize, int maxPointsCount) { gray = new IplImage(imageSize, 8, 1); pyramid = new IplImage(imageSize, 8, 1); points = new StructureSafeMemoryBox<CvPoint2D32f>(maxPointsCount); isFading = new bool[maxPointsCount]; }
void DrawSquares(List<CvPoint> squares, PieceInfo[] pieces, HighGuiWindow window) { using (IplImage cpy = lastFrame.CloneImage()) { StructureSafeMemoryBox<CvPoint> pt = new StructureSafeMemoryBox<CvPoint>(4); IntPtrSafeMemoryBox rect = new IntPtrSafeMemoryBox(); rect.Value = pt.Pointer; Int32SafeMemoryBox count = new Int32SafeMemoryBox(); count.Value = 4; for (int i = 0; i < squares.Count; i += 4) { pt[0] = squares[i + 0]; pt[1] = squares[i + 1]; pt[2] = squares[i + 2]; pt[3] = squares[i + 3]; CvPoint center = new CvPoint((squares[i + 0].x + squares[i + 2].x) / 2, (squares[i + 0].y + squares[i + 2].y) / 2); // CvScalar color = new CvScalar(0, 255, 255); CxCore.cvPolyLine(cpy, rect.Pointer, count.Pointer, 1, 1, CvScalar.FromRGB(255, 255, 0), 3, CxCore.CV_AA, 0); } PieceInfo[,] layout = lastLayout; if (layout != null) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { pt[0] = new CvPoint(j * 20 + 3, i * 20 + 3); pt[1] = new CvPoint(j * 20 + 3, i * 20 + 18); pt[2] = new CvPoint(j * 20 + 18, i * 20 + 18); pt[3] = new CvPoint(j * 20 + 18, i * 20 + 3); CvScalar color = CvScalar.FromRGB(layout[i, j].color[0], layout[i, j].color[1], layout[i, j].color[2]); CxCore.cvFillPoly(cpy, rect.Pointer, count.Pointer, 1, color, CxCore.CV_AA, 0); } } } count.Dispose(); rect.Dispose(); pt.Dispose(); window.ShowImage(cpy); } }