Skip to content

Commit

Permalink
Add camera response duration and remove uuid and timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
webermarci committed Jun 15, 2023
1 parent 502e040 commit 5240ac4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module github.com/webermarci/hikrec

go 1.19

require github.com/google/uuid v1.3.0
go 1.20
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
17 changes: 7 additions & 10 deletions hikrec.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package hikrec

import (
"time"
)
import "time"

type Direction string

Expand All @@ -13,11 +11,10 @@ const (
)

type Recognition struct {
UUID string `json:"uuid"`
Timestamp time.Time `json:"timestamp"`
Plate string `json:"plate"`
Confidence int `json:"confidence"`
Direction Direction `json:"direction"`
Country string `json:"country"`
Nation string `json:"nation"`
Plate string `json:"plate"`
Confidence int `json:"confidence"`
Direction Direction `json:"direction"`
Country string `json:"country"`
Nation string `json:"nation"`
CameraResponseDuration time.Duration `json:"camera_response_duration"`
}
13 changes: 4 additions & 9 deletions onvif.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package hikrec
import (
"strconv"
"time"

"github.com/google/uuid"
)

type envelope struct {
Expand Down Expand Up @@ -129,10 +127,10 @@ func (device *Device) PullRecognitions() (chan Recognition, error) {

go func() {
for {
start := time.Now()

messages, err := device.pullMessage(device.Url, pullAddress)
if err != nil {
time.Sleep(time.Second)

res, err := device.createPullPointSubscription()
for err != nil {
time.Sleep(time.Second)
Expand All @@ -147,10 +145,7 @@ func (device *Device) PullRecognitions() (chan Recognition, error) {
}

for _, message := range messages {
recognition := Recognition{
UUID: uuid.NewString(),
Timestamp: time.Now(),
}
recognition := Recognition{}

for _, item := range message.Data.Items {
switch item.Name {
Expand Down Expand Up @@ -185,9 +180,9 @@ func (device *Device) PullRecognitions() (chan Recognition, error) {
continue
}

recognition.CameraResponseDuration = time.Since(start)
outgoing <- recognition
}

}
}()

Expand Down

0 comments on commit 5240ac4

Please sign in to comment.