批量添加摄像头bug

This commit is contained in:
曹前明 2022-07-06 18:21:04 +08:00
parent 026d860900
commit 8d9f458cd7
7 changed files with 1 additions and 216 deletions

View File

@ -1,38 +0,0 @@
//python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./BeiHangGrpc.proto
syntax = "proto3";
option java_generic_services = true;
option java_multiple_files = true;
option java_package = "com.lyzh.aiservice.grpc";
option java_outer_classname = "BeiHangProto";
service Helmet_Reg {
rpc sendHelmet_Info(JinYu_Request) returns (BHhelmet_Response){}
}
message JinYu_Request {
int64 zzid = 1; //ID
string imgsbase64 = 2 ; //Base64字符串
string imgUrl = 3 ; //oss链接Url
}
message BHhelmet_Response {
int64 zzid = 1; //ID
repeated HelmetInfo helmetinfoList = 2; //0: 1
}
message Point {
double x = 1; //x坐标
double y = 2; //y坐标
}
message Rectangle {
Point uleft = 1; //
Point lright = 2; //
}
message HelmetInfo {
int64 head_helmet = 1; //
double conf = 2; //
Rectangle coord = 3; //
}

View File

@ -1,75 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: BeiHangGrpc.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11\x42\x65iHangGrpc.proto\"A\n\rJinYu_Request\x12\x0c\n\x04zzid\x18\x01 \x01(\x03\x12\x12\n\nimgsbase64\x18\x02 \x01(\t\x12\x0e\n\x06imgUrl\x18\x03 \x01(\t\"F\n\x11\x42Hhelmet_Response\x12\x0c\n\x04zzid\x18\x01 \x01(\x03\x12#\n\x0ehelmetinfoList\x18\x02 \x03(\x0b\x32\x0b.HelmetInfo\"\x1d\n\x05Point\x12\t\n\x01x\x18\x01 \x01(\x01\x12\t\n\x01y\x18\x02 \x01(\x01\":\n\tRectangle\x12\x15\n\x05uleft\x18\x01 \x01(\x0b\x32\x06.Point\x12\x16\n\x06lright\x18\x02 \x01(\x0b\x32\x06.Point\"J\n\nHelmetInfo\x12\x13\n\x0bhead_helmet\x18\x01 \x01(\x03\x12\x0c\n\x04\x63onf\x18\x02 \x01(\x01\x12\x19\n\x05\x63oord\x18\x03 \x01(\x0b\x32\n.Rectangle2E\n\nHelmet_Reg\x12\x37\n\x0fsendHelmet_Info\x12\x0e.JinYu_Request\x1a\x12.BHhelmet_Response\"\x00\x42,\n\x17\x63om.lyzh.aiservice.grpcB\x0c\x42\x65iHangProtoP\x01\x88\x01\x01\x62\x06proto3')
_JINYU_REQUEST = DESCRIPTOR.message_types_by_name['JinYu_Request']
_BHHELMET_RESPONSE = DESCRIPTOR.message_types_by_name['BHhelmet_Response']
_POINT = DESCRIPTOR.message_types_by_name['Point']
_RECTANGLE = DESCRIPTOR.message_types_by_name['Rectangle']
_HELMETINFO = DESCRIPTOR.message_types_by_name['HelmetInfo']
JinYu_Request = _reflection.GeneratedProtocolMessageType('JinYu_Request', (_message.Message,), {
'DESCRIPTOR': _JINYU_REQUEST,
'__module__': 'BeiHangGrpc_pb2'
# @@protoc_insertion_point(class_scope:JinYu_Request)
})
_sym_db.RegisterMessage(JinYu_Request)
BHhelmet_Response = _reflection.GeneratedProtocolMessageType('BHhelmet_Response', (_message.Message,), {
'DESCRIPTOR': _BHHELMET_RESPONSE,
'__module__': 'BeiHangGrpc_pb2'
# @@protoc_insertion_point(class_scope:BHhelmet_Response)
})
_sym_db.RegisterMessage(BHhelmet_Response)
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), {
'DESCRIPTOR': _POINT,
'__module__': 'BeiHangGrpc_pb2'
# @@protoc_insertion_point(class_scope:Point)
})
_sym_db.RegisterMessage(Point)
Rectangle = _reflection.GeneratedProtocolMessageType('Rectangle', (_message.Message,), {
'DESCRIPTOR': _RECTANGLE,
'__module__': 'BeiHangGrpc_pb2'
# @@protoc_insertion_point(class_scope:Rectangle)
})
_sym_db.RegisterMessage(Rectangle)
HelmetInfo = _reflection.GeneratedProtocolMessageType('HelmetInfo', (_message.Message,), {
'DESCRIPTOR': _HELMETINFO,
'__module__': 'BeiHangGrpc_pb2'
# @@protoc_insertion_point(class_scope:HelmetInfo)
})
_sym_db.RegisterMessage(HelmetInfo)
_HELMET_REG = DESCRIPTOR.services_by_name['Helmet_Reg']
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
DESCRIPTOR._serialized_options = b'\n\027com.lyzh.aiservice.grpcB\014BeiHangProtoP\001\210\001\001'
_JINYU_REQUEST._serialized_start = 21
_JINYU_REQUEST._serialized_end = 86
_BHHELMET_RESPONSE._serialized_start = 88
_BHHELMET_RESPONSE._serialized_end = 158
_POINT._serialized_start = 160
_POINT._serialized_end = 189
_RECTANGLE._serialized_start = 191
_RECTANGLE._serialized_end = 249
_HELMETINFO._serialized_start = 251
_HELMETINFO._serialized_end = 325
_HELMET_REG._serialized_start = 327
_HELMET_REG._serialized_end = 396
# @@protoc_insertion_point(module_scope)

View File

@ -1,67 +0,0 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import BeiHangGrpc_pb2 as BeiHangGrpc__pb2
class Helmet_RegStub(object):
"""Missing associated documentation comment in .proto file."""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.sendHelmet_Info = channel.unary_unary(
'/Helmet_Reg/sendHelmet_Info',
request_serializer=BeiHangGrpc__pb2.JinYu_Request.SerializeToString,
response_deserializer=BeiHangGrpc__pb2.BHhelmet_Response.FromString,
)
class Helmet_RegServicer(object):
"""Missing associated documentation comment in .proto file."""
def sendHelmet_Info(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_Helmet_RegServicer_to_server(servicer, server):
rpc_method_handlers = {
'sendHelmet_Info': grpc.unary_unary_rpc_method_handler(
servicer.sendHelmet_Info,
request_deserializer=BeiHangGrpc__pb2.JinYu_Request.FromString,
response_serializer=BeiHangGrpc__pb2.BHhelmet_Response.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'Helmet_Reg', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
# This class is part of an EXPERIMENTAL API.
class Helmet_Reg(object):
"""Missing associated documentation comment in .proto file."""
@staticmethod
def sendHelmet_Info(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/Helmet_Reg/sendHelmet_Info',
BeiHangGrpc__pb2.JinYu_Request.SerializeToString,
BeiHangGrpc__pb2.BHhelmet_Response.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

View File

@ -1,31 +0,0 @@
import grpc
# import base64
from . import BeiHangGrpc_pb2_grpc
from . import BeiHangGrpc_pb2
if __name__ == "__main__":
IP = '127.0.0.1:9000'
channel = grpc.insecure_channel(IP) # 监听频道
stub = BeiHangGrpc_pb2_grpc.Helmet_RegStub(channel) # 客户端使用Stub类发送请求,参数为频道,为了绑定链接
image_id = 3
# 本地图像输入
# image_path = "./onnx/image/single3.jpg"
# with open(image_path, 'rb') as f:
# image_base64 = str(base64.b64encode(f.read()), encoding='utf-8')
# request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id,imgsbase64=image_base64)
# URL输入
imgUrl = "XXXXX.jpg"
request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id, imgUrl=imgUrl)
try:
response = stub.sendHelmet_Info(request)
print("network success! \n")
print(response)
except Exception:
print("network error! \n")

View File

@ -1,2 +0,0 @@
def helmet_test():
return True

View File

@ -1,6 +1,4 @@
from apps.ecm.algo import helmet_test
from apps.utils.sms import send_sms
import requests
from apps.am.models import Access, Area

View File

@ -47,7 +47,7 @@ class AlgoChannelViewSet(CreateModelMixin, DestroyModelMixin, ListModelMixin, Cu
acs = []
for i in vdata['vchannels']:
acs.append(AlgoChannel(id=idWorker.get_id(), algo=vdata['algo'], vchannel=i))
AlgoChannel.objects.bulk_create(objs=acs, ignore_conflicts=False)
AlgoChannel.objects.bulk_create(objs=acs, ignore_conflicts=True)
return Response()