//private Workspace _workspace; public DataInitialization(int Width, int Height) { var unityContainerInit = new UnityContainer(); _action = unityContainerInit.Resolve <Actions>(); _selectClass = unityContainerInit.Resolve <Selection>(); _pointSelection = unityContainerInit.Resolve <PointSelection>(); _rectangleSelection = unityContainerInit.Resolve <RectangleSelection>(); _drawClass = unityContainerInit.Resolve <DrawOnCanvas>(new OrderedParametersOverride(new object[] { Width, Height, _action })); _editDate = unityContainerInit.Resolve <EditData>(new OrderedParametersOverride(new object[] { _drawClass, _action })); _rectangl = unityContainerInit.Resolve <RectangleFigure>(); _ellipse = unityContainerInit.Resolve <EllipseFigure>(); _line = unityContainerInit.Resolve <Line>(); _poliLine = unityContainerInit.Resolve <PolylineFigure>(); _polygon = unityContainerInit.Resolve <PolygonFigure>(); _rectangleSelect = unityContainerInit.Resolve <RectangleSelect>(); _listFigures.Add(_rectangl); _listFigures.Add(_ellipse); _listFigures.Add(_line); _listFigures.Add(_poliLine); _listFigures.Add(_polygon); _drawListFigures.Add(_rectangl); _drawListFigures.Add(_ellipse); _drawListFigures.Add(_line); _drawListFigures.Add(_poliLine); _drawListFigures.Add(_polygon); _drawListFigures.Add(_rectangleSelect); _selectionList.Add(_pointSelection); _selectionList.Add(_rectangleSelection); _modesList.Add(unityContainerInit.Resolve <DrawMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass }))); _modesList.Add(unityContainerInit.Resolve <SelectRegionMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _modesList.Add(unityContainerInit.Resolve <SelectPointoMode>(new OrderedParametersOverride(new object[] { _listFigures, _selectClass, _drawClass, _editDate, _selectionList }))); _workspace = new Workspace(_selectClass, _drawClass, _editDate, _listFigures, _modesList, _drawListFigures); }
static public byte[] ToSerialized(Dictionary <string, List <float[]> > expressions, SVMModel model, string[] classLabels, int[] indices, PointSelection pointSelection) { OpenSeeExpressionRepresentation oser = new OpenSeeExpressionRepresentation(); oser.expressions = expressions; oser.modelBytes = model.SaveModel(); oser.classLabels = classLabels; oser.indices = indices; oser.pointSelection = pointSelection; oser.thunderSVM = true; //oser.newModel = true; IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress)) { formatter.Serialize(gzipStream, oser); gzipStream.Flush(); } return(memoryStream.ToArray()); }
//private bool newModel = false; static public void LoadSerialized(byte[] modelBytes, out Dictionary <string, List <float[]> > expressions, out SVMModel model, out string[] classLabels, out int[] indices, ref PointSelection pointSelection) { IFormatter formatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(modelBytes); memoryStream.Position = 0; OpenSeeExpressionRepresentation oser; using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) { oser = formatter.Deserialize(gzipStream) as OpenSeeExpressionRepresentation; } expressions = oser.expressions; if (oser.thunderSVM) { model = new ThunderSVMModel(oser.modelBytes); } else { model = new SVMModel(oser.modelBytes); } classLabels = oser.classLabels; indices = oser.indices; //pointSelection = oser.pointSelection; if (indices == null) { indices = new int[1 + 1 + 3 + 4 + 3 + 3 * 66]; for (int i = 0; i < 1 + 1 + 3 + 4 + 3 + 3 * 66; i++) { indices[i] = i; } } /*if (pointSelection == null) * pointSelection = new PointSelection(); * if (!oser.newModel) * pointSelection.features = true;*/ }