public void DbResultToSampleObjectAllowMissing() { const string mandatoryField = "Mandatory"; const int expectedMandatoryValue = 890; { DataTable dt = DatasetGenerator.CreateNewBasicDataTable( new string[] { mandatoryField }, new Type[] { typeof(int) }); using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedMandatoryValue)) { dr.Read(); SampleObject obj = new SampleObject(); DbAutoFillHelper.FillObjectFromDataReader(dr, obj); Assert.AreEqual(expectedMandatoryValue, obj.Mandatory); } } { DataTable dt = DatasetGenerator.CreateNewBasicDataTable(new string[] { }, new Type[] { }); using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, new object[] { })) { dr.Read(); SampleObject obj = new SampleObject(); Assert.ThrowsException <MissingFieldException>(() => { DbAutoFillHelper.FillObjectFromDataReader(dr, obj); }); } } }
private void button4_Click(object sender, EventArgs e) { //Add to dataset var textboxs = this.panel2.Controls; int samples = 0; foreach (TextBox tx in textboxs) { if (tx.Text != String.Empty) { //TO CHECK var zi = tx.Text; var i = Convert.ToInt32(tx.Name); var bit = projectionBitMapFilter.ResizedBitmaps[i]; var sequence = DatasetGenerator.ToZerosOnesSequence(Convert.ToChar(zi), bit); projectionBitMapFilter.ResizedBitmaps[i].Save(Variables.datasetimagespath + tx.Text + @".bmp"); FileWriter.AddLine(sequence, Variables.datasetpath); } } MessageBox.Show(samples + " new samples have been added"); }
public void DbResultsToBasicObject() { const string expectedStringValue = "String"; const int expectedIntValue = 76; const string stringPropName = "StringProperty"; const string intPropName = "IntField"; DataTable dt = DatasetGenerator.CreateNewBasicDataTable( new string[] { stringPropName, intPropName }, new Type[] { typeof(string), typeof(int) }); using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedStringValue, expectedIntValue)) { dr.Read(); BasicObject obj = new BasicObject(); DbAutoFillHelper.FillObjectFromDataReader(dr, obj); Assert.AreEqual(obj.StringProperty, expectedStringValue); Assert.AreEqual(obj.IntField, expectedIntValue); } }
public void DbResultToComplexObject() { const string nameINField = "NameIN"; const string toDbUuidField = "ToDbUuid"; const string fromDbIdField = "FromDbId"; const string expectedAliasedColumnName = "ALittleTest"; const string expectedNameINValue = "ComplexObject"; const int unexpectedToDbUuidValue = 23; const int expectedFromDbUuid = 3; const int expectedToDbUuidValue = -19; const bool expectedAliaseColumnValue = true; DataTable dt = DatasetGenerator.CreateNewBasicDataTable( new string[] { nameINField, toDbUuidField, fromDbIdField, expectedAliasedColumnName }, new Type[] { typeof(string), typeof(int), typeof(int), typeof(string) }); using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedNameINValue, unexpectedToDbUuidValue, expectedFromDbUuid, expectedAliaseColumnValue)) { dr.Read(); ComplexObject obj = new ComplexObject(); obj.ToDbUuid = expectedToDbUuidValue; DbAutoFillHelper.FillObjectFromDataReader(dr, obj); Assert.AreEqual(expectedNameINValue, obj.NameIN); Assert.AreNotEqual(unexpectedToDbUuidValue, obj.ToDbUuid); Assert.AreEqual(expectedToDbUuidValue, obj.ToDbUuid); Assert.AreEqual(expectedFromDbUuid, obj.FromDbId); Assert.AreEqual(expectedAliaseColumnValue, obj.Aliased); } }
static void Main(string[] args) { int level = 5; DatasetGenerator.GenerateDataSet(level); }
private void Process() { Bitmap bitmapFromScreen = BitmapService.BitmapFromScreen(CaptureArea.Width, CaptureArea.Height, CaptureArea.Left, CaptureArea.Top, this.comboBoxScreen.SelectedIndex); pictureBox1.Image = bitmapFromScreen; projectionBitMapFilter = ProjectionService.ProjectandFilter(SelectedColor, Convert.ToInt32(this.numericUpDownColorMargin.Value), bitmapFromScreen); ProjectionsToChartSeries(projectionBitMapFilter); ProjectionsToChartSeries(projectionBitMapFilter); this.pictureBox2.Image = projectionBitMapFilter.Bitmap; projectionBitMapFilter.HorizontalSegments = ProjectionService.ToSegments(projectionBitMapFilter.HorizontalProjection, projectionBitMapFilter.Bitmap.Height); projectionBitMapFilter.VerticalSegments = new List <Segment>(); if (SubtitlesDetected(projectionBitMapFilter.HorizontalSegments)) { long Range = projectionBitMapFilter.HorizontalSegments[0].End - projectionBitMapFilter.HorizontalSegments[0].Starts; Int64 AverageRange = MathHelper.Average(Ranges); projectionBitMapFilter.VerticalSegments = ProjectionService.ToSegments(projectionBitMapFilter.VerticalProjection, projectionBitMapFilter.Bitmap.Height); if (projectionBitMapFilter.VerticalSegments.Count != 0) { projectionBitMapFilter = ProjectionService.MaxMinEvaluation(bitmapFromScreen.Height, projectionBitMapFilter); List <Segment> GroupedSegments = SegmentationService.GroupSegments(projectionBitMapFilter.VerticalSegments); Bitmap bitmapInitialSegments = (Bitmap)projectionBitMapFilter.Bitmap.Clone(); Bitmap bitmapGroupedSegments = (Bitmap)projectionBitMapFilter.Bitmap.Clone(); this.pictureBox2.Image = BitmapService.DrawSegmentsinBitmap(projectionBitMapFilter.VerticalSegments, bitmapInitialSegments, Brushes.DarkRed); this.pictureBoxGrouped.Image = BitmapService.DrawSegmentsinBitmap(GroupedSegments, bitmapGroupedSegments, Brushes.Orange); projectionBitMapFilter.CroppedBitmaps = BitmapService.ExtractCropBitmaps(GroupedSegments, projectionBitMapFilter.Bitmap); foreach (Bitmap crop in projectionBitMapFilter.CroppedBitmaps) { var margin = BitmapService.CorrectMargin(crop); projectionBitMapFilter.CorrectedMarginBitmaps.Add(margin); } List <char> predictions = new List <char>(); foreach (Bitmap bitmap in projectionBitMapFilter.CorrectedMarginBitmaps) { Bitmap resized = BitmapService.ResizeImage(bitmap, 32, 32); projectionBitMapFilter.ResizedBitmaps.Add(resized); string zerosandones = DatasetGenerator.ToZerosOnesSequence(' ', resized); var c = PredictionService.Predict(zerosandones); predictions.Add(c); x++; } BitmapsToScreen(projectionBitMapFilter.ResizedBitmaps); AddTextBoxToScreen(projectionBitMapFilter.CroppedBitmaps.Count, predictions); } } }