add-提交运行版

development
liuwf 1 month ago
parent d60a4e6e5a
commit cdcf85aa61

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SlnMesnac.Config;
using System;
using System.Collections.Generic;
@ -66,7 +67,26 @@ namespace SlnMesnac.TouchSocket
if(type== "ocr")
{
}else if(type == "pci")
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);
// 发送请求的长度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}\"}}";

@ -91,7 +91,7 @@ namespace SlnMesnac.WPF.ViewModel
{
Task.Run(async () =>
{
await ocrClient.StartAsync("127.0.0.1", "10001");
await ocrClient.StartAsync("127.0.0.1", "7024");
await pciClient.StartAsync("127.0.0.1", "9999");
});
@ -136,7 +136,7 @@ namespace SlnMesnac.WPF.ViewModel
RefreshPicture(File.ReadAllBytes(selectedFilePath));
if(type== "ocr")
{
ocrClient.sendMessage("ocr","hello world");
ocrClient.sendMessage("ocr", fileName);
}
else if(type== "pci")
{

Loading…
Cancel
Save