完成单张、批次模板调整需求

This commit is contained in:
强 杨 2023-12-08 14:10:09 +08:00
commit d5ac2f04e3
8 changed files with 256 additions and 78 deletions

View File

@ -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
/// <param name="zoomRatio"></param>
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;
}
}

View File

@ -13,7 +13,60 @@
<meta http-equiv="Cache" content="no-cache">
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<script>
var SelectOBJ = null;
$(document).ready(function (e) {
$($(".main")[0]).find(".main_tabletop ").each(function () {
$(this).click(function () {
SelectOBJ = this;
})
})
})
setInterval(function () {
$($(".main")[0]).find(".main_tabletop ").each(function () {
$(this).click(function () {
SelectOBJ = this;
})
})
},500)
$(document).keydown(function (event) {
if (event.keyCode == 38) {//上
$(SelectOBJ).css("top", (parseInt($(SelectOBJ).css("top")) - 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 40) {//下
$(SelectOBJ).css("top", (parseInt($(SelectOBJ).css("top")) + 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 37) {//左
$(SelectOBJ).css("left", (parseInt($(SelectOBJ).css("left")) - 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 39) {//左
$(SelectOBJ).css("left", (parseInt($(SelectOBJ).css("left")) + 1) + "px");
event.stopPropagation();
event.preventDefault();
}
});
document.body.onkeydown = function (e) {
if (e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 37 || e.keyCode == 38) {
return false;
}
}
</script>
</head>
<body>
<div class="divBG backgroundGo" style="display: none;"></div>
@ -155,7 +208,7 @@
</table>
</div>
<div style="width: 1570px; overflow: hidden;">
<div class="main_papermain">
<div class="main_papermain" id="mainbox_l_T">
<img id="SelectImg" src="<%=imgage %>" style="width: 100%; float: left; z-index: 0;" />
</div>

View File

@ -335,6 +335,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
Image<Gray, byte> currentFramext = new Image<Gray, byte>(PictureBoxBitMap);
Image<Gray, byte> myImage = new Image<Gray, byte>(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<Gray, byte> EmguImagex1 = new Image<Gray, byte>(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;

View File

@ -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<result>(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt)));
if (r.code == "200" && r.data)
var r = JsonConvert.DeserializeObject<result>(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<result>(reponse.Html);
var ress = JsonConvert.DeserializeObject<result>(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; }
}

View File

@ -8,6 +8,60 @@
<title>导入外部答题卡制作模板</title>
<script src="../js/jquery-1.10.2.min.js"></script>
<link href="../css/default.css" rel="stylesheet" />
<script>
var SelectOBJ = null;
$(document).ready(function (e) {
$($(".main")[0]).find(".main_tabletop").each(function () {
$(this).click(function () {
SelectOBJ = this;
})
})
})
setInterval(function () {
$($(".main")[0]).find(".main_tabletop ").each(function () {
$(this).click(function () {
SelectOBJ = this;
})
})
}, 500)
$(document).keydown(function (event) {
if (event.keyCode == 38) {//上
$(SelectOBJ).css("top", (parseInt($(SelectOBJ).css("top")) - 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 40) {//下
$(SelectOBJ).css("top", (parseInt($(SelectOBJ).css("top")) + 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 37) {//左
$(SelectOBJ).css("left", (parseInt($(SelectOBJ).css("left")) - 1) + "px");
event.stopPropagation();
event.preventDefault();
}
if (event.keyCode == 39) {//左
$(SelectOBJ).css("left", (parseInt($(SelectOBJ).css("left")) + 1) + "px");
event.stopPropagation();
event.preventDefault();
}
});
document.body.onkeydown = function (e) {
if (e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 37 || e.keyCode == 38) {
return false;
}
}
</script>
</head>
<body>
<div class="divBG backgroundGo" style="display: none;"></div>
@ -55,11 +109,12 @@
<input type="text" style="display: none;" value="<%=MainTempId %>" id="MainTempId" />
<input type="text" style="display: none;" value="<%=PageCount %>" id="PageCount" />
<input type="text" style="display: none;" value="<%=UserID %>" id="UserID" />
<input type="text" style="display:none;" value="<%=Rotate %>" id="Rotate" />
<input type="text" style="display:none;" value="<%=BatchID %>" id="BatchID" />
<input type="text" style="display:none;" value="<%=GroupNo %>" id="GroupNo" />
<input type="text" style="display: none;" value="<%=Rotate %>" id="Rotate" />
<input type="text" style="display: none;" value="<%=BatchID %>" id="BatchID" />
<input type="text" style="display: none;" value="<%=GroupNo %>" id="GroupNo" />
<textarea id="HideAreaText" style="display: none;"><%=HideAreaText %></textarea>
@ -67,34 +122,55 @@
<input type="hidden" id="pager_A" value="<%=pager %>" />
<div class="main">
<div class="main_tool">
<% if (PageIndex == "1") { %>
<div class="tiaomasz_hover" style="float:left;">第一页</div>
<% }
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)" style="float:left;">第一页</div>
<% } %>
<% if (PageIndex == "1")
{ %>
<div class="tiaomasz_hover" style="float: left;">第一页</div>
<% }
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)" style="float: left;">第一页</div>
<% } %>
<% if (PageCount > 1)
{ %>
<% if (PageIndex == "2")
{ %>
<div class="tiaomasz_hover" style="float: left;">第二页</div>
<% }
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)" style="float: left;">第二页</div>
<% } %>
<% } %>
<input type="button" class="btn_XY" value="左倾斜" onclick="PicRotate(0)" style="float: left; padding: 10px; padding-left: 30px; padding-right: 30px; font-size: 14px; margin-left: 150px; margin-right: 10px;" />
<input type="button" class="btn_XY" value="右倾斜" onclick="PicRotate(1)" style="float: left; padding: 10px; padding-left: 30px; padding-right: 30px; margin-right: 10px; font-size: 14px; margin-left: 10px;" />
<label style="float: left; padding: 10px; margin-right: 10px; font-size: 14px; margin-left: 10px;">卷子是否存在定位点:</label>
<select id="select_ishaspostion" style="float: left; padding: 10px; padding-left: 10px; padding-right: 10px; margin-right: 10px; font-size: 14px; margin-left: 10px;">
<option value="1">有定位点</option>
<option value="0">无定位点</option>
</select>
<script>
$("#select_ishaspostion").val("<%=ishaspostion%>");
$("#select_ishaspostion").change(function () {
if ($(this).val() == 0) {
document.location.href = document.location.href.replace("ishaspostion=1", "ishaspostion=0");
}
else {
document.location.href = document.location.href.replace("ishaspostion=0", "ishaspostion=1");
}
})
</script>
<input type="button" id="noButtonK" style="float: left; padding: 10px; padding-left: 30px; padding-right: 30px; font-size: 14px; margin-left: 100px; margin-right: 10px;" onclick="GetDataTotal(-1,'<%=tenant %>')" value="保存数据" />
<% if (PageCount >1) { %>
<% if (PageIndex == "2") { %>
<div class="tiaomasz_hover" style="float:left;">第二页</div>
<% }
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)" style="float:left;">第二页</div>
<% } %>
<% } %>
<input type="button" class="btn_XY" value="左倾斜" onclick="PicRotate(0)" style="float:left; padding:10px; padding-left:30px; padding-right:30px; font-size:14px; margin-left:150px;margin-right:10px;"/>
<input type="button" class="btn_XY" value="右倾斜" onclick="PicRotate(1)" style="float:left;padding:10px; padding-left:30px; padding-right:30px;margin-right:10px; font-size:14px;margin-left:10px;" />
<input type="button" id="noButtonK" style="float:left; padding:10px; padding-left:30px; padding-right:30px; font-size:14px; margin-left:100px;margin-right:10px;" onclick="GetDataTotal(-1,'<%=tenant %>')" value="保存数据" />
<script>
var rote = 0;
function PicRotate(flag) {
@ -123,13 +199,13 @@
var roteBind = parseFloat("<%=Rotate%>");
rote = roteBind;
document.getElementById("SelectImg").style.transform = 'rotate(' + roteBind + 'deg)';
</script>
</div>
<div class="main_tool" style="display:none;">
<div class="main_tool" style="display: none;">
<table>
<tr>
<th style="display: none" class="lockHide">选定锚点</th>
@ -139,28 +215,31 @@
<div class="maodian" id="point_2">左下锚点</div>
<div class="maodian" id="point_3">右下锚点</div>
</td>
<td style="padding: 0;" valign="top" >
<% if (PageIndex == "1") { %>
<td style="padding: 0;" valign="top">
<% if (PageIndex == "1")
{ %>
<div class="tiaomasz_hover">第一页</div>
<% }
else
{ %>
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)">第一页</div>
<% } %>
</td>
<% if (PageCount >1) { %>
<td style="padding: 0;" valign="top" >
<% if (PageIndex == "2") { %>
<% if (PageCount > 1)
{ %>
<td style="padding: 0;" valign="top">
<% if (PageIndex == "2")
{ %>
<div class="tiaomasz_hover">第二页</div>
<% }
else
{ %>
else
{ %>
<div class="tiaomasz" onclick="ChangePageNum(<%=AnotherTempID %>)">第二页</div>
<% } %>
</td>
<% } %>
<% } %>
<td class="lockHide">
<span>纸张类型:</span>
<select id="selectPageSize" disabled onchange="ChangePageSize(this)" style="font-size: 14px; padding-left: 10px; padding-right: 20px; width: 100px;">
@ -223,7 +302,7 @@
</div>
</div>
<div onclick="HideRight(this)" style="position: fixed; display:none; right: 0; top: 0; z-index: 333; height: 40px; width: 40px; background: #000000; color: #fff; text-align: center; line-height: 40px; font-size: 12px;">折叠</div>
<div onclick="HideRight(this)" style="position: fixed; display: none; right: 0; top: 0; z-index: 333; height: 40px; width: 40px; background: #000000; color: #fff; text-align: center; line-height: 40px; font-size: 12px;">折叠</div>
<script>
function HideRight(obj) {
if ($(obj).html() == "折叠") {
@ -239,7 +318,7 @@
}
}
</script>
<div class="right_list" style="display:none;">
<div class="right_list" style="display: none;">
<ul class="ul lockHide">
<li class="hover">客观题设置</li>
<li>

View File

@ -45,6 +45,8 @@ public partial class Temp_UserNoPostionTemp : System.Web.UI.Page
public string BatchID = "";
public string GroupNo = "";
public string ishaspostion = "";
protected void Page_Load(object sender, EventArgs e)
{
@ -54,7 +56,8 @@ public partial class Temp_UserNoPostionTemp : System.Web.UI.Page
BatchID = Globals.Request("BatchID");
pager = Globals.Request("pager").ToLower();
GroupNo = Globals.Request("GroupNo");
ishaspostion = Globals.Request("ishaspostion");
if (action != 0)
{
Response.Clear();
@ -95,10 +98,10 @@ public partial class Temp_UserNoPostionTemp : System.Web.UI.Page
sql = "select * from MK_TempleteDataUserOnePaper where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID + " AND GroupNo_varchar='" + GroupNo + "'";
}
//if (!string.IsNullOrEmpty(BatchID))
//{
// sql = "select * from MK_TempleteDataUserBatch where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID + " AND BatchID_nvarchar='" + BatchID + "'";
//}
if (!string.IsNullOrEmpty(BatchID))
{
sql = "select * from MK_TempleteDataUserBatch where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID + " AND BatchID_nvarchar='" + BatchID + "'";
}

View File

@ -24,7 +24,7 @@ function CloseHideArea(obj) {
///设置锚点
function SetMao(obj, index) {
if (IsPostionValue == "False") {
if (IsPostionValue.toLowerCase() == "false" || IsPostionValue.toLowerCase() == "0") {
alert("无法设置定位点,请修改主模板数据.");
return;
}
@ -815,7 +815,7 @@ function SetMaoPostion(postiondata) {
//alert(IsPostionValue);
if (postiondata == "") {
if (IsPostionValue == "1") {
if (IsPostionValue == "1" || IsPostionValue.toLowerCase() == "true") {
SetMao(document.getElementById("point_0"), 0);
SetMao(document.getElementById("point_1"), 1);
SetMao(document.getElementById("point_2"), 2);
@ -823,7 +823,7 @@ function SetMaoPostion(postiondata) {
}
return;
}
if (IsPostionValue == "0") {
if (IsPostionValue == "0" || IsPostionValue.toLowerCase() == "false") {
$("#draggable_0").remove();
$("#draggable_1").remove();
$("#draggable_2").remove();

View File

@ -404,7 +404,9 @@ function GetMaoPostion() {
//alert("锚点未设置完成");
return "";
}
if ($("#select_ishaspostion").val() == "0") {
return "^";
}
return xy.trim('^');;
}
@ -610,9 +612,6 @@ function GetDataTotal(objvalue, tenant) {
//初始化绑定数据
function BaseDataBind() {
var Bindlist = $("#Bindlist").val()
var list = Bindlist.split('$');
var maodian = "";//左边距,右边距,长,高
@ -672,6 +671,7 @@ function BaseDataBind() {
$("#selectPageSize").val("1200");
}
$("#selectPageSize").val(pageWidth);
$("#selectPageSize").change();
@ -758,8 +758,11 @@ function SetMaoPostion(postiondata) {
//alert(postiondata);
//alert(IsPostionValue);
if ($("#select_ishaspostion").val() == "0") {
IsPostionValue = "False";
}
if (postiondata == "") {
if (IsPostionValue == "1") {
if (IsPostionValue == "1" || IsPostionValue == "True") {
SetMao(document.getElementById("point_0"), 0);
SetMao(document.getElementById("point_1"), 1);
SetMao(document.getElementById("point_2"), 2);
@ -767,7 +770,10 @@ function SetMaoPostion(postiondata) {
}
return;
}
if (IsPostionValue == "0") {
if (IsPostionValue == "0" || IsPostionValue == "False") {
$("#draggable_0").remove();
$("#draggable_1").remove();
$("#draggable_2").remove();