|
@@ -3,11 +3,14 @@ using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
+using Newtonsoft.Json;
|
|
|
|
|
|
namespace WebManager
|
|
namespace WebManager
|
|
{
|
|
{
|
|
public class WebResult
|
|
public class WebResult
|
|
{
|
|
{
|
|
|
|
+ #region
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 数据定义
|
|
/// 数据定义
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -18,6 +21,8 @@ namespace WebManager
|
|
private const String Post = "Post";
|
|
private const String Post = "Post";
|
|
private const String Content_Type= "Content-Type:application/json";
|
|
private const String Content_Type= "Content-Type:application/json";
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -84,7 +89,12 @@ namespace WebManager
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public String RequestString(String postString)
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 向WebServer请求数据及返回结果
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="postString">请求数据的JSON</param>
|
|
|
|
+ /// <returns>返回结果的JSON</returns>
|
|
|
|
+ private String RequestString(String postString)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -96,5 +106,216 @@ namespace WebManager
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 计算原始图像偏移角度及方向
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_OffsetAngle_Direction(String imagePath, out double degree, out int direction, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_path", imagePath);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret= (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+
|
|
|
|
+ if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ JObject jname = JObject.Parse(jret["img_name"].ToString());
|
|
|
|
+ degree = Convert.ToDouble(jname["degree"].ToString());
|
|
|
|
+ direction = Convert.ToInt32(jname["direction"].ToString());
|
|
|
|
+ state = Convert.ToInt32(jname["state"].ToString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ direction = 0;
|
|
|
|
+ degree = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 计算切割点位置
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_Cut_Position(String imagePath, out double offsetx, out double offsety, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_path", imagePath);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ JObject jname = JObject.Parse(jret["img_name"].ToString());
|
|
|
|
+ JArray jlocation = JArray.Parse(jname["location"].ToString());
|
|
|
|
+ offsetx = Convert.ToDouble(jlocation[0].ToString());
|
|
|
|
+ offsety = Convert.ToDouble(jlocation[1].ToString());
|
|
|
|
+ state = Convert.ToInt32(jname["state"].ToString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ offsetx = 0;
|
|
|
|
+ offsety = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否切割成功验证
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imageBefore">切割前图像路径</param>
|
|
|
|
+ /// <param name="imageAfter">切割后图像路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_Cut_Success(String imageBefore, String imageAfter, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_before_path", imageBefore);
|
|
|
|
+ json.Add("img_after_path", imageAfter);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ state = Convert.ToInt32(jret["state"].ToString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 计算切割后图像梯形区域上边中心点坐标
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_Trapezoid_Top_Center_Position(String imagePath, out double offsetx, out double offsety, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_path", imagePath);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ JObject jname = JObject.Parse(jret["img_name"].ToString());
|
|
|
|
+ JArray jlocation = JArray.Parse(jname["top_center"].ToString());
|
|
|
|
+ offsetx = Convert.ToDouble(jlocation[0].ToString());
|
|
|
|
+ offsety = Convert.ToDouble(jlocation[1].ToString());
|
|
|
|
+ state = Convert.ToInt32(jname["state"].ToString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ offsetx = 0;
|
|
|
|
+ offsety = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 自动对焦
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">一组图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public String Img_Auto_Focus(List<String> imagePath)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ for(int i=0;i<imagePath.Count;i++)
|
|
|
|
+ {
|
|
|
|
+ json.Add("img_path" + i.ToString(), imagePath[i]);
|
|
|
|
+ }
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_path") != null && jret.Property("img_path").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ return jret["img_path"].ToString();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 自动消像散
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">一组图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public String Img_Auto_Stigmatic(List<String> imagePath)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ for (int i = 0; i < imagePath.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ json.Add("img_path" + i.ToString(), imagePath[i]);
|
|
|
|
+ }
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_path") != null && jret.Property("img_path").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ return jret["img_path"].ToString();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 计算切割面区域中心坐标,以及偏移角度及方向
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">图片路径</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_Center_Position_OffsetAngle_Direction(String imagePath, out double offsetx, out double offsety, out double degree, out int direction, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_path", imagePath);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ JObject jname = JObject.Parse(jret["img_name"].ToString());
|
|
|
|
+ JArray jlocation = JArray.Parse(jname["center"].ToString());
|
|
|
|
+ offsetx = Convert.ToDouble(jlocation[0].ToString());
|
|
|
|
+ offsety = Convert.ToDouble(jlocation[1].ToString());
|
|
|
|
+ state = Convert.ToInt32(jname["state"].ToString());
|
|
|
|
+ degree = Convert.ToDouble(jname["degree"].ToString());
|
|
|
|
+ direction = Convert.ToInt32(jname["direction"].ToString());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ direction = 0;
|
|
|
|
+ degree = 0;
|
|
|
|
+ offsetx = 0;
|
|
|
|
+ offsety = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测量尺寸
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="imagePath">图片路径</param>
|
|
|
|
+ /// <param name="ratio">放大倍数</param>
|
|
|
|
+ /// <param name="size">一像素代表**mm/um</param>
|
|
|
|
+ /// <returns>json字符串</returns>
|
|
|
|
+ public void Img_Measure_Size(String imagePath, String ratio, String size, out int state)
|
|
|
|
+ {
|
|
|
|
+ JObject json = new JObject();
|
|
|
|
+ json.Add("img_path", imagePath);
|
|
|
|
+ json.Add("ratio", ratio);
|
|
|
|
+ json.Add("size", size);
|
|
|
|
+ String res = RequestString(JsonConvert.SerializeObject(json));
|
|
|
|
+ JObject jret = (JObject)JsonConvert.DeserializeObject(res);
|
|
|
|
+ if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
|
|
|
|
+ {
|
|
|
|
+ JObject jstate = JObject.Parse(jret["img_name"].ToString());
|
|
|
|
+ state = Convert.ToInt32(jstate["state"].ToString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ state = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|