解决 IsPostionValue 取出来是 true 的问题

This commit is contained in:
强 杨 2023-11-23 15:46:31 +08:00
parent 6b8d25efe0
commit f08a432dc3
3 changed files with 12 additions and 9 deletions

View File

@ -418,7 +418,7 @@ public class CommonUse
{ {
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();//所有的轮廓 VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();//所有的轮廓
VectorOfVectorOfPoint selected_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);//提取所有轮廓,操作过程中会对输入图像进行修改 Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);//提取所有轮廓,操作过程中会对输入图像进行修改
//筛选轮廓。筛选条件:长宽比大于给定值 //筛选轮廓。筛选条件:长宽比大于给定值
@ -1576,10 +1576,12 @@ public class CommonUse
return bitmap; return bitmap;
} }
Mat red = channels[2]; Mat red = channels[2];
return red.Bitmap;
//commonUse.ShowMatWaitKey("red", red, 0.5); //commonUse.ShowMatWaitKey("red", red, 0.5);
Mat redBinary = new Mat(); //Mat redBinary = new Mat();
CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary); //CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary);
//commonUse.ShowMatWaitKey("red+binary", redBinary, 0.5); //commonUse.ShowMatWaitKey("red+binary", redBinary, 0.5);
//Mat redDilate = new Mat(); //Mat redDilate = new Mat();
@ -1590,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)); //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); //commonUse.ShowMatWaitKey("redDilate", redDilate, 0.5);
return redBinary.Bitmap; //return redBinary.Bitmap;
} }
} }

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> currentFramext = new Image<Gray, byte>(PictureBoxBitMap);
Image<Gray, byte> myImage = new Image<Gray, byte>(commonUse.FilterRed(PictureBoxBitMap)); Image<Gray, byte> myImage = new Image<Gray, byte>(commonUse.FilterRed(PictureBoxBitMap));
// 进行中值滤波 // 进行中值滤波
CvInvoke.MedianBlur(myImage, myImage, 5); CvInvoke.MedianBlur(myImage, myImage, 5);
// 进行高斯滤波 // 进行高斯滤波
@ -346,14 +347,14 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
Bitmap bm_dest = myImage.Bitmap; Bitmap bm_dest = myImage.Bitmap;
Image<Gray, byte> EmguImagex1 = new Image<Gray, byte>(bm_dest); Image<Gray, byte> EmguImagex1 = new Image<Gray, byte>(bm_dest);
Mat mat_threshold1 = new Mat(); 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); Mat mat_dilate = commonUse.MyDilate(mat_threshold1);
VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1); VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1);
//var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1); //var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1);
//commonUse.ShowMatWaitKey("44444", color_mat1, 0.8); //commonUse.ShowMatWaitKey("44444", color_mat1, 0.8);
//Response.Write(ImgToBase64String(color_mat1.Bitmap)); ////Response.Write(ImgToBase64String(color_mat1.Bitmap));
//return false; //return false;

View File

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