diff --git a/App_Code/CommonUse.cs b/App_Code/CommonUse.cs
index 12813ab..05e05e1 100644
--- a/App_Code/CommonUse.cs
+++ b/App_Code/CommonUse.cs
@@ -197,7 +197,7 @@ public class CommonUse
}
catch
{
- message = GetPostionString(i)+"未找到定位点";
+ message = GetPostionString(i) + "未找到定位点";
xielv = -100;
return null;
}
@@ -418,7 +418,7 @@ public class CommonUse
{
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();//所有的轮廓
VectorOfVectorOfPoint selected_contours = new VectorOfVectorOfPoint();//用于存储筛选过后的轮廓
- CvInvoke.FindContours(mat, contours, null, Emgu.CV.CvEnum.RetrType.External,
+ CvInvoke.FindContours(mat, contours, null, Emgu.CV.CvEnum.RetrType.List,
Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);//提取所有轮廓,操作过程中会对输入图像进行修改
//筛选轮廓。筛选条件:长宽比大于给定值
@@ -430,6 +430,8 @@ public class CommonUse
// continue;
//}
+ //ShowMatWaitKey("dingweidian", DrawContours(mat, new VectorOfVectorOfPoint(contours[i])), 0.6);
+
Rectangle rect = CvInvoke.BoundingRectangle(contours[i]);//外接矩形
Mat temp = new Mat(mat, rect);//提取ROI矩形区域
int pxNums = CvInvoke.CountNonZero(temp);//计算图像内非零像素个数
@@ -444,7 +446,11 @@ public class CommonUse
// bool bo = (rect.Width / rect.Height >= ratio && (rect.Width > 3 && rect.Height > 2) && (area > 200 && area <= 4500));
//bool bo = ((rect.Width > 3 && rect.Height > 2) && (area > 80 && area <= 15000));
//bool bo = pxNums > 130 && pxNums < 300;
- bool bo = (approx_curve.Size == 4 && CvInvoke.IsContourConvex(approx_curve) && (rect.Width > 15 && rect.Height > 15) && (area > 550 && area < 2000) && (rect.Width < 50 && rect.Height < 50) && pxNums > 550);
+ bool bo = (CvInvoke.IsContourConvex(approx_curve)
+ && (rect.Width > 10 && rect.Height > 10)
+ && (area > 200 && area < 2000)
+ && (rect.Width < 50 && rect.Height < 50)
+ && pxNums > 200);
if (bo)
{
selected_contours.Push(contours[i]);
@@ -1403,7 +1409,7 @@ public class CommonUse
Mat mat_color = new Mat();
CvInvoke.CvtColor(mat, mat_color, Emgu.CV.CvEnum.ColorConversion.Gray2Bgr);
- CvInvoke.DrawContours(mat_color, contours, -1, new MCvScalar(255, 0, 0), 2);
+ CvInvoke.DrawContours(mat_color, contours, -1, new MCvScalar(0, 0, 255), 2);
return mat_color;
}
@@ -1501,8 +1507,14 @@ public class CommonUse
///
public void ShowMatWaitKey(string title, Mat mat, double zoomRatio)
{
- CvInvoke.Resize(mat, mat, new Size(), zoomRatio, zoomRatio, Inter.Cubic);
- CvInvoke.Imshow(title, mat);
+ if (!System.Diagnostics.Debugger.IsAttached)
+ {
+ return;
+ }
+
+ var result = new Mat();
+ CvInvoke.Resize(mat, result, new Size(), zoomRatio, zoomRatio, Inter.Cubic);
+ CvInvoke.Imshow(title, result);
CvInvoke.WaitKey(0);
}
@@ -1564,10 +1576,12 @@ public class CommonUse
return bitmap;
}
Mat red = channels[2];
+
+ return red.Bitmap;
//commonUse.ShowMatWaitKey("red", red, 0.5);
- Mat redBinary = new Mat();
- CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary);
+ //Mat redBinary = new Mat();
+ //CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary);
//commonUse.ShowMatWaitKey("red+binary", redBinary, 0.5);
//Mat redDilate = new Mat();
@@ -1578,7 +1592,7 @@ public class CommonUse
//CvInvoke.MorphologyEx(redBinary, redDilate, MorphOp.Open, kernel, new Point(-1, -1), 1, BorderType.Default, new MCvScalar(0, 0, 0));
//commonUse.ShowMatWaitKey("redDilate", redDilate, 0.5);
- return redBinary.Bitmap;
+ //return redBinary.Bitmap;
}
}
diff --git a/Temp/Default.aspx b/Temp/Default.aspx
index d94f874..cfeee75 100644
--- a/Temp/Default.aspx
+++ b/Temp/Default.aspx
@@ -13,7 +13,60 @@
+
@@ -155,7 +208,7 @@
-
+
diff --git a/Temp/Default.aspx.cs b/Temp/Default.aspx.cs
index c49a03a..d83e7f7 100644
--- a/Temp/Default.aspx.cs
+++ b/Temp/Default.aspx.cs
@@ -335,6 +335,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
Image
currentFramext = new Image(PictureBoxBitMap);
Image myImage = new Image(commonUse.FilterRed(PictureBoxBitMap));
+
// 进行中值滤波
CvInvoke.MedianBlur(myImage, myImage, 5);
// 进行高斯滤波
@@ -346,14 +347,14 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
Bitmap bm_dest = myImage.Bitmap;
Image EmguImagex1 = new Image(bm_dest);
Mat mat_threshold1 = new Mat();
- CvInvoke.Threshold(EmguImagex1, mat_threshold1, 180, 255, Emgu.CV.CvEnum.ThresholdType.BinaryInv);
+ CvInvoke.Threshold(EmguImagex1, mat_threshold1, 210, 255, Emgu.CV.CvEnum.ThresholdType.BinaryInv);
Mat mat_dilate = commonUse.MyDilate(mat_threshold1);
VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1);
//var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1);
//commonUse.ShowMatWaitKey("44444", color_mat1, 0.8);
- //Response.Write(ImgToBase64String(color_mat1.Bitmap));
+ ////Response.Write(ImgToBase64String(color_mat1.Bitmap));
//return false;
diff --git a/Temp/SplitQuestion.aspx.cs b/Temp/SplitQuestion.aspx.cs
index 2931d44..5d43a2d 100644
--- a/Temp/SplitQuestion.aspx.cs
+++ b/Temp/SplitQuestion.aspx.cs
@@ -76,7 +76,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page
long subjective = Convert.ToInt64(Globals.Request("subjective"));
var checkResult = CheckStatusByApi(subjective);
- if (!checkResult.data)
+ if (!checkResult.data.Value)
{
Response.Write("验证失败!" + checkResult.message);
return;
@@ -187,8 +187,12 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page
//调用接口
//result r = (result)JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), lt.ToJsonString()), typeof(result));
- var r =JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt)));
- if (r.code == "200" && r.data)
+ var r = JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt)));
+ if (r == null || r.code != "200")
+ {
+ throw new Exception("调用接口失败了!");
+ }
+ if (r.code == "200" && r.data.Value)
{
Response.Write("1");
}
@@ -405,7 +409,14 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
string url = "http://192.168.2.9:6500/";
- if (Request.Url.Host.ToLower().Contains("23544.com"))
+
+ if (Request.Url.Host.ToLower().Contains("w.23544.com"))
+ {
+ // 测试地址
+ url = "https://mka.w.23544.com:8843/";
+ bearer = token;
+ }
+ else if (Request.Url.Host.ToLower().Contains("23544.com"))
{
// 正式地址
url = "https://mk-api.23544.com/ad/";
@@ -432,16 +443,27 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page
{
throw new Exception("验证接口调用失败!" + Response.StatusCode + " ||| " + reponse.Html);
}
-
+
//return (result)JsonConvert.DeserializeObject(reponse.Html, typeof(result));
- return JsonConvert.DeserializeObject(reponse.Html);
+ var ress = JsonConvert.DeserializeObject(reponse.Html);
+ if (ress == null || ress.code != "200")
+ {
+ throw new Exception("验证接口调用失败!" + Response.StatusCode + " ||| " + reponse.Html);
+ }
+ return ress;
}
private string RequestPost(string id, string body)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
// 测试地址
string url = "http://192.168.2.9:6500/";
- if (Request.Url.Host.ToLower().Contains("23544.com"))
+ if (Request.Url.Host.ToLower().Contains("w.23544.com"))
+ {
+ // 测试地址
+ url = "https://mka.w.23544.com:8843/";
+ bearer = token;
+ }
+ else if (Request.Url.Host.ToLower().Contains("23544.com"))
{
// 正式地址
url = "https://mk-api.23544.com/ad/";
@@ -497,7 +519,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page
public string message { get; set; }
public string code { get; set; }
- public bool data { get; set; }
+ public bool? data { get; set; }
}
diff --git a/Temp/UserNoPostionTemp.aspx b/Temp/UserNoPostionTemp.aspx
index 89bcd60..68f1372 100644
--- a/Temp/UserNoPostionTemp.aspx
+++ b/Temp/UserNoPostionTemp.aspx
@@ -8,6 +8,60 @@
导入外部答题卡制作模板
+
@@ -55,11 +109,12 @@
-
-
-
+
+
+
+
+
-
@@ -67,34 +122,55 @@
- <% if (PageIndex == "1") { %>
-
第一页
- <% }
- else
- { %>
-
第一页
- <% } %>
+ <% if (PageIndex == "1")
+ { %>
+
第一页
+ <% }
+ else
+ { %>
+
第一页
+ <% } %>
+
+
+ <% if (PageCount > 1)
+ { %>
+
+ <% if (PageIndex == "2")
+ { %>
+
第二页
+ <% }
+ else
+ { %>
+
第二页
+ <% } %>
+
+
+ <% } %>
+
+
+
+
+
+
+
+
-
- <% if (PageCount >1) { %>
-
- <% if (PageIndex == "2") { %>
-
第二页
- <% }
- else
- { %>
-
第二页
- <% } %>
-
-
- <% } %>
-
-
-
-
-
-
-
+
| 选定锚点 |
@@ -139,28 +215,31 @@
左下锚点
右下锚点
-
- <% if (PageIndex == "1") { %>
+ |
+ <% if (PageIndex == "1")
+ { %>
第一页
<% }
- else
- { %>
+ else
+ { %>
第一页
<% } %>
|
- <% if (PageCount >1) { %>
-
- <% if (PageIndex == "2") { %>
+ <% if (PageCount > 1)
+ { %>
+ |
+ <% if (PageIndex == "2")
+ { %>
第二页
<% }
- else
- { %>
+ else
+ { %>
第二页
<% } %>
|
- <% } %>
+ <% } %>
纸张类型:
|