Small fixes
This commit is contained in:
parent
ff5c722703
commit
ead2e84ecd
@ -123,7 +123,7 @@ namespace WebApplication5.Templates
|
||||
else
|
||||
image.ROI = new Rectangle(0, idetiferHeight, image.Size.Width / 2, image.Size.Height- idetiferHeight);
|
||||
|
||||
image.Save(@"C:\Users\Janek\Desktop\Tests\scans\half_" + rightcolumn + ".jpg");
|
||||
//image.Save(@"C:\Users\Janek\Desktop\Tests\scans\half_" + rightcolumn + ".jpg");
|
||||
var lines = GetHorizontal(image);
|
||||
var left = GetLeftLine(lines);
|
||||
var right = GetRightLine(lines);
|
||||
@ -134,7 +134,7 @@ namespace WebApplication5.Templates
|
||||
image.ROI = new Rectangle();
|
||||
var rec = new Rectangle(rightcolumn ? image.Size.Width / 2 + left : left, idetiferHeight + top, right - left, height * questionsIds.Count);
|
||||
image.Draw(rec, new Gray(255), 10);
|
||||
image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + rightcolumn + "lines.jpg");
|
||||
//image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + rightcolumn + "lines.jpg");
|
||||
|
||||
for (int i = 0; i < questionsIds.Count; i++)
|
||||
{
|
||||
@ -162,11 +162,13 @@ namespace WebApplication5.Templates
|
||||
image.ROI = recc;
|
||||
var pixels = (float)image.ROI.Size.Height * image.ROI.Width;
|
||||
var nonZero = (float)image.CountNonzero()[0];
|
||||
|
||||
//image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + i + j + rightcolumn + "boxes.jpg");
|
||||
var ratio = (pixels - nonZero) / pixels;
|
||||
if (ratio > 0.1)
|
||||
{
|
||||
a.Checked = true;
|
||||
image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + rightcolumn + ratio + "lines.jpg");
|
||||
//image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + rightcolumn + ratio + "lines.jpg");
|
||||
}
|
||||
|
||||
qA.Answers.Add(a);
|
||||
@ -185,7 +187,7 @@ namespace WebApplication5.Templates
|
||||
var topLine = GetTopLine(lines);
|
||||
var avgDist = avg - topLine;
|
||||
|
||||
lines = lines.Where(l => Math.Max(l.P1.Y, l.P2.Y) < (2 * avgDist) + topLine)
|
||||
lines = lines.Where(l => Math.Max(l.P1.Y, l.P2.Y) < (2 * avgDist) + topLine + 100)
|
||||
.ToArray();
|
||||
|
||||
return lines;
|
||||
@ -195,10 +197,11 @@ namespace WebApplication5.Templates
|
||||
{
|
||||
Image<Bgr, byte> answersCard = new Image<Bgr, byte>(fileName);
|
||||
Image<Gray, byte> grayImage = answersCard.Convert<Gray, byte>();
|
||||
var grayMin = grayImage.ThresholdToZero(new Gray(150));
|
||||
return grayMin;
|
||||
|
||||
return grayImage;
|
||||
}
|
||||
private Image<Gray,byte> RotateImage(Image<Gray, byte> image, Mat x) {
|
||||
private Image<Gray, byte> RotateImage(Image<Gray, byte> image, Mat x)
|
||||
{
|
||||
var z = x.GetData();
|
||||
var pointOfQr = new Point()
|
||||
{
|
||||
@ -231,9 +234,9 @@ namespace WebApplication5.Templates
|
||||
if (i == 3)
|
||||
{
|
||||
image = image.Rotate(180, new Gray(255), false);
|
||||
image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + "rotated.jpg");
|
||||
//image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + "rotated.jpg");
|
||||
}
|
||||
return image;
|
||||
return image.ThresholdToZero(new Gray(150));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user