Skip to content

Commit

Permalink
update gRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
LdDl committed Aug 12, 2020
1 parent ecec6e2 commit 5d8d13c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 8 additions & 3 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"fmt"
"image"
"image/jpeg"
engine "license_plate_recognition"
"log"
"os"
"time"

engine "github.com/LdDl/odam"

"google.golang.org/grpc"
)

Expand Down Expand Up @@ -61,17 +62,21 @@ func main() {
defer conn.Close()

// Init gRPC client
client := engine.NewSTYoloClient(conn)
client := engine.NewServiceYOLOClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

// Send message to gRPC server
r, err := client.SendDetection(
ctx,
&engine.CamInfo{
&engine.ObjectInformation{
CamId: "my_new_uuid",
Timestamp: time.Now().Unix(),
Image: sendS3,
Class: &engine.ClassInfo{
ClassId: 100,
ClassName: "find_ocr",
},
Detection: &engine.Detection{
XLeft: int32(*xConfig),
YTop: int32(*yConfig),
Expand Down
10 changes: 5 additions & 5 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
grpcInstance := grpc.NewServer()

// Register servers
grpc_server.RegisterSTYoloServer(
grpc_server.RegisterServiceYOLOServer(
grpcInstance,
rs,
)
Expand All @@ -83,9 +83,9 @@ func main() {

}

// RecognitionServer Wrapper around engine.STYoloServer
// RecognitionServer Wrapper around engine.ServiceYOLOServer
type RecognitionServer struct {
grpc_server.STYoloServer
grpc_server.ServiceYOLOServer
netW *engine.YOLONetwork
framesQueue chan *vehicleInfo
maxLen int
Expand Down Expand Up @@ -165,12 +165,12 @@ func (rs *RecognitionServer) SendToQueue(n *vehicleInfo) {
}

type vehicleInfo struct {
imageInfo *grpc_server.CamInfo
imageInfo *grpc_server.ObjectInformation
img *image.NRGBA
}

// SendDetection Imeplented function or accepting image
func (rs *RecognitionServer) SendDetection(ctx context.Context, in *grpc_server.CamInfo) (*grpc_server.Response, error) {
func (rs *RecognitionServer) SendDetection(ctx context.Context, in *grpc_server.ObjectInformation) (*grpc_server.Response, error) {

imgBytes := in.GetImage()
imgReader := bytes.NewReader(imgBytes)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/LdDl/go-darknet v1.1.0
github.com/LdDl/gocv-blob v1.0.1 // indirect
github.com/LdDl/odam v0.3.1
github.com/LdDl/odam v0.4.1
github.com/disintegration/imaging v1.6.2
github.com/satori/go.uuid v1.2.0 // indirect
gocv.io/x/gocv v0.23.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ github.com/LdDl/odam v0.3.0 h1:+FChOURz8GILnpdbfAsuaLfpMMizurVw3QE3zvWJSls=
github.com/LdDl/odam v0.3.0/go.mod h1:Ah61oMuI+U8SkS1ihRGd9Ngb7boy1PHC418/UKS+coA=
github.com/LdDl/odam v0.3.1 h1:PfCjcoTYzQM3T3wyfwEhu+1BEyXUAs2wx9hScRgB7wM=
github.com/LdDl/odam v0.3.1/go.mod h1:Ah61oMuI+U8SkS1ihRGd9Ngb7boy1PHC418/UKS+coA=
github.com/LdDl/odam v0.4.0 h1:Ue7/2Cc01E5Yi7AoVsH936wgKOOmrMdSyBp7qh8E8U8=
github.com/LdDl/odam v0.4.0/go.mod h1:Ah61oMuI+U8SkS1ihRGd9Ngb7boy1PHC418/UKS+coA=
github.com/LdDl/odam v0.4.1 h1:MWxRZp58A6/Xf+w7/5lc5t4RTdBQqJkkWYusF7GrjCo=
github.com/LdDl/odam v0.4.1/go.mod h1:K1STBUV4Wg2fqfpfepSWE+ucdiW5FQH5Z3RMWp1G9Io=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
Expand Down

0 comments on commit 5d8d13c

Please sign in to comment.