定位点切割增加右上角定位点的宽度
This commit is contained in:
parent
d34e26d6fc
commit
17bf9bc281
|
|
@ -191,9 +191,11 @@ public class CommonUse
|
|||
//ShowMatWaitKey("123", aaa, 0.8);
|
||||
|
||||
string mx = "";
|
||||
Rectangle rt = new Rectangle();
|
||||
try
|
||||
{
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY, out message);
|
||||
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY, out message, out rt);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -224,7 +226,7 @@ public class CommonUse
|
|||
}
|
||||
if (i == 1)//右上角
|
||||
{
|
||||
PostionWW = GrXY.X;
|
||||
PostionWW = GrXY.X + rt.Width;
|
||||
}
|
||||
if (i == 2)//左下角
|
||||
{
|
||||
|
|
@ -560,7 +562,7 @@ public class CommonUse
|
|||
/// <param name="y_num"></param>
|
||||
/// <returns></returns>
|
||||
public int[] GetTargetGravityFind(VectorOfVectorOfPoint contours, int x_begin, int x_interval, int x_num,
|
||||
int y_begin, int y_interval, int y_num, out Point gravityXY, out string messag)
|
||||
int y_begin, int y_interval, int y_num, out Point gravityXY, out string messag, out Rectangle rectDT)
|
||||
{
|
||||
messag = string.Empty;
|
||||
int[] result = new int[x_num];//结果数组
|
||||
|
|
@ -575,6 +577,7 @@ public class CommonUse
|
|||
Point[] gravity = GetGravityOfContours(contours);//轮廓中心点坐标
|
||||
|
||||
gravityXY = new Point(0, 0);
|
||||
rectDT = new Rectangle(0, 0, 0, 0);
|
||||
for (int i = 0; i < contours.Size; i++)
|
||||
{
|
||||
VectorOfPoint contour = contours[i];
|
||||
|
|
@ -601,6 +604,7 @@ public class CommonUse
|
|||
gravityXY = gravity[i];
|
||||
gravityXY.X = rect.X;
|
||||
gravityXY.Y = rect.Y;
|
||||
rectDT = rect;
|
||||
}
|
||||
|
||||
//if (result[x_id] != -1)
|
||||
|
|
@ -1054,11 +1058,11 @@ public class CommonUse
|
|||
/// <param name="strText">输出文字</param>
|
||||
/// <returns></returns>
|
||||
public string GetValueAndDrawGrid_Find(Bitmap img, VectorOfVectorOfPoint contours,
|
||||
int x_begin, int x_interval, int x_num, int y_begin, int y_interval, int y_num, string strText, out Point pFindX, out string message)
|
||||
int x_begin, int x_interval, int x_num, int y_begin, int y_interval, int y_num, string strText, out Point pFindX, out string message, out Rectangle rt)
|
||||
{
|
||||
//画网格
|
||||
Point pFind;
|
||||
int[] intArray = GetTargetGravityFind(contours, x_begin, x_interval, x_num, y_begin, y_interval, y_num, out pFind, out message);
|
||||
int[] intArray = GetTargetGravityFind(contours, x_begin, x_interval, x_num, y_begin, y_interval, y_num, out pFind, out message, out rt);
|
||||
int maxValue = GetMaxValueOfArray(intArray);//数组最大值
|
||||
pFindX = pFind;
|
||||
string str = "";
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ using Emgu.CV.Flann;
|
|||
using System.Data.SqlTypes;
|
||||
using System.Security.AccessControl;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public partial class 外部答题卡_Default : System.Web.UI.Page
|
||||
{
|
||||
|
|
@ -514,7 +515,11 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
|
|||
int wL = Convert.ToInt32(W / xuanXiang);
|
||||
int hL = Convert.ToInt32(H / tiliang);
|
||||
|
||||
|
||||
Image<Gray, byte> bytimg = GetMatCutImg(color_mat.Bitmap, X, Y, W, H);
|
||||
//Bitmap bmp = ScaleToSize(tempImage.Bitmap, tempImage.Bitmap.Width * 4, tempImage.Bitmap.Height * 4, groupNo);
|
||||
|
||||
|
||||
|
||||
X = 0; Y = 0;
|
||||
Mat src = bytimg.Mat;
|
||||
|
|
|
|||
|
|
@ -677,10 +677,11 @@ public class MK_Operater
|
|||
int H = Convert.ToInt32(Convert.ToDouble(postCutList[3]));
|
||||
//commonUse.DrawGridByXY(测试查找坐标.myFrom.PB_guodu, X, W, 1, Y, H, 1);Response.Write(ImgToBase64String(bmp));
|
||||
string mx = "";
|
||||
Rectangle rt = new Rectangle();
|
||||
try
|
||||
{
|
||||
string message = string.Empty;
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message);
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message ,out rt);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -746,10 +747,11 @@ public class MK_Operater
|
|||
int W = Convert.ToInt32(Convert.ToDouble(postCutList[2]));
|
||||
int H = Convert.ToInt32(Convert.ToDouble(postCutList[3]));
|
||||
string mx = "";
|
||||
Rectangle rt = new Rectangle();
|
||||
try
|
||||
{
|
||||
string message = string.Empty;
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message);
|
||||
mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message ,out rt);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -771,7 +773,7 @@ public class MK_Operater
|
|||
}
|
||||
if (i == 1)//右上角
|
||||
{
|
||||
PostionWW = GrXY.X;
|
||||
PostionWW = GrXY.X+ rt.Width;
|
||||
}
|
||||
if (i == 2)//左下角
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue