当前位置: 首页 > news >正文

关于GRPC的相关知识。

文件路径:D:\vcpkg\packages\protobuf_x64-windows\tools\protobuf

PS D:\vcpkg\packages\protobuf_x64-windows\tools\protobuf> .\protoc --grpc_out=. --plugin=protoc-gen-grpc=.\grpc_cpp_plugin.exe .\Interface.proto                                                                                        
PS D:\vcpkg\packages\protobuf_x64-windows\tools\protobuf> .\protoc --cpp_out=. .\Interface.proto                
PS D:\vcpkg\packages\protobuf_x64-windows\tools\protobuf>  

syntax = "proto3";
package DataTransmission;
service ImgTransmission {rpc Upload(stream ChunkOneLine) returns (Reply) {}
}
message Chunk 
{int32  imgData0 = 1;int32  imgData1 = 2;int32  imgData2 = 3;int32  imgData3 = 4;bytes	buff = 5;
}
message imgparm
{int32 type = 1;int32 rows = 2;int32 cols = 3;int32 channel = 4;
}
message ChunkOneLine
{repeated  Chunk oneLineData = 1;imgparm imgParmData = 2;Chunk	dataBuf = 3;
}
message Rectangle {int32 x = 1; // 矩形框的x坐标int32 y = 2; // 矩形框的y坐标int32 width = 3; // 矩形框的宽度int32 height = 4; // 矩形框的高度
}
message Reply {int32  defectType = 1; // 缺陷信息repeated Rectangle rectangles = 2; // 一个矩形框列表
}

class SAFServer final :public DataTransmission::ImgTransmission::Service
{
public:Status Upload(ServerContext* context, ServerReader<ChunkOneLine>* reader, Reply* reply);
};
Status SAFServer::Upload(ServerContext* context, ServerReader<ChunkOneLine>* reader, Reply* reply)
{std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now();ChunkOneLine oneLie;imgparm imgp;reader->Read(&oneLie);imgp = oneLie.imgparmdata();int Type = imgp.type();imgType = Type;cv::Mat mat;std::string str_decon;str_decon = oneLie.databuf().buff();std::vector<uchar>data(str_decon.begin(), str_decon.end());mat = cv::imdecode(data, 1);img = mat;iouThr = 0.25;Params ID;DetectResult DR;ID.inputImg.push_back(img);ID.imgType.push_back(imgType);Process(ID, DR, iouThr, OD, OS, SAA);std::chrono::system_clock::time_point end_time = std::chrono::system_clock::now();auto sec = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);std::cout << "Time cost :" << sec.count() << std::endl;std::cout << "resultNum:" << DR.defectType.size() << std::endl;if (SDR.defectType.size() > 0){reply->set_defecttype(DR.defectType[0]);for (int i = 0; i < DR.OCRect.size(); i++){DataTransmission::Rectangle rectangle;rectangle.set_x(DR.OCRect[i].x);rectangle.set_y(DR.OCRect[i].y);rectangle.set_width(DR.OCRect[i].width);rectangle.set_height(DR.OCRect[i].height);reply->add_rectangles()->CopyFrom(rectangle);}}{reply->set_defecttype(0);DataTransmission::Rectangle rectangle;rectangle.set_x(0);rectangle.set_y(0);rectangle.set_width(0);rectangle.set_height(0);reply->add_rectangles()->CopyFrom(rectangle);}//cv::resize(mat, mat, cv::Size(mat.cols / 4, mat.rows / 4));//cv::imshow("bb", mat);//cv::waitKey(100);delete oneLie.release_databuf();  // 释放 chunkreturn grpc::Status::OK;
}
http://www.lryc.cn/news/601643.html

相关文章:

  • 编程语言Java——核心技术篇(五)IO流:数据洪流中的航道设计
  • 点击劫持:潜藏在指尖的安全陷阱
  • 【Unity3D实例-功能-移动】角色移动-通过WSAD(Transform方式)
  • 《频率之光:共振之恋》
  • 益莱储:明智地投资测试仪器
  • 数据结构的基本知识
  • [STM32][HAL]stm32wbxx 超声波测距模块实现(HY-SRF05)
  • 深度学习在计算机视觉中的应用:对象检测
  • Java面试全栈通关:从微服务到AI的技术深度解析
  • 市电有电检测电路
  • elasticsearch 倒排索引原理详解
  • 湖南(源点咨询)市场调研 如何在行业研究中快速有效介入 起头篇
  • 一场关于电商零售增长破局的深圳探索
  • Python类(class)参数self的理解
  • ROS2总结(二)
  • VMware Workstation Pro虚拟机的下载和安装图文保姆级教程(附下载链接)
  • Mysql 二进制安装常见问题
  • QUARTUS速通流程
  • HCIP---MGRE实验
  • 数学建模——模糊综合评价
  • 2-4、Dify案例实践—基于工作流构建商城用户评价智能分析系统
  • 算法竞赛阶段二-数据结构(37)数据结构循环链表模拟实现
  • print(“\033[31m红\033[32m绿\033[34m蓝\033[0m默认色“)
  • 零基础学习性能测试第五章:JVM性能分析与调优-JVM运行时内存区域介绍
  • Maven之多模块项目管理
  • C语言——关于指针(逐渐清晰版)
  • 嵌入式——单片机的独立按键
  • 数据结构基础内容(第七篇:堆、哈夫曼树)
  • 电子电气架构 --- 软件bug的管理模式
  • 「iOS」————MRC