|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SlnMesnac.Config;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -65,8 +66,27 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
|
if(type== "ocr")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var request = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "image_path", msg },
|
|
|
|
|
{ "service_type", "parse_labels" } // "check_texts", "check_duplicates", "parse_labels"
|
|
|
|
|
};
|
|
|
|
|
// 转换为 JSON 并编码为字节
|
|
|
|
|
string message = JsonConvert.SerializeObject(request);
|
|
|
|
|
byte[] requestBytes = Encoding.UTF8.GetBytes(message);
|
|
|
|
|
|
|
|
|
|
}else if(type == "pci")
|
|
|
|
|
// 发送请求的长度(4字节)
|
|
|
|
|
byte[] lengthBytes = BitConverter.GetBytes(requestBytes.Length);
|
|
|
|
|
if (BitConverter.IsLittleEndian)
|
|
|
|
|
{
|
|
|
|
|
Array.Reverse(lengthBytes); // 如果系统是小端序,需要反转字节顺序
|
|
|
|
|
}
|
|
|
|
|
tcpClient.Send(lengthBytes,0, lengthBytes.Length);
|
|
|
|
|
|
|
|
|
|
tcpClient.Send(requestBytes,0,requestBytes.Length);
|
|
|
|
|
}
|
|
|
|
|
else if(type == "pci")
|
|
|
|
|
{
|
|
|
|
|
// 使用转义字符正确构造字符串
|
|
|
|
|
string message = $"\x00\x00\x00+{{\"image_path\": \"{msg}\"}}";
|
|
|
|
|