Documentation for Axxon One 2.0. Documentation for other versions of Axxon One is available too.

Previous page Manage detectors using gRPC API methods  Manage interactive map using gRPC API methods Next page

To get tracks using GO, do the following:

  1. Install GO (see Go programming language).
  2. Run the code example:

    client := metadata.NewMetadataServiceClient(conn)
    
    stream, err := client.PullMetadata(context.Background())
    ch := make(chan int, 8)
    
    go func() {
      for {
        in, err := stream.Recv()
        if err == io.EOF {
          close(ch)
          return
        }
    
        if err != nil {
          log.Fatal(err)
        }
    
        switch data := in.Data.(type) {
          case *metadata.PullMetadataResponse_Heartbeat:
          //
          case *metadata.PullMetadataResponse_ConfigUpdate:
          //
          case *metadata.PullMetadataResponse_Sample:
          switch sampleData := data.Sample.Data.(type) {
            case *metadata.MetadataSample_Tracklets:
            log.Printf("Time: %v\nTracklets: %v", data.Sample.Timestamp, sampleData.Tracklets)
          }
        }
    
        ch <- 1 // notify the main thread about receiving the sample
      }
    }()
    
    endpoint := media.EndpointRef{AccessPoint: "hosts/SERVER/AVDetector.1/SourceEndpoint.vmda"}
    req := metadata.PullMetadataRequest{
      Count:                 8, // ask for several samples, so that they are not lost while server waits for another response from client
      Endpoint:              &endpoint,
      ProposedChannelIdleMs: 15000,
    }
    
    if err := stream.Send(&req); err != nil {
      log.Fatal(err)
    }
    
    for {
      // whenever a sample is received ask for another sample keeping the total samples requested to a fixed value > 1
      <-ch 
      req := metadata.PullMetadataRequest{
        Count: 1,
      }
    
      if err := stream.Send(&req); err != nil {
        log.Fatal(err)
      }
    }

As a result, you will get the possible response options.

Response examples:

Message about the received tracks:
{
  "sample": {
    "timestamp": "20230914T133656.981000",
    "tracklets": {
      "tracklets": [
        {
          "id": 70,
          "state": "OBJECT_STATE_NORMAL",
          "rectangle": {
            "x": 0.10248079895973206,
            "y": 0.3568287789821625,
            "w": 0.17517775297164917,
            "h": 0.257714182138443
          },
          "logicalCenter": {
            "x": 0.19006967544555664,
            "y": 0.6145429611206055
          },
          "color": {
            "hue": 222.47191011235952,
            "saturation": 0.3093524946210368,
            "value": 0.49719319611902735
          }
        }
      ]
    }
  }
}

where

  • timestamptime corresponding to the video frame for which tracks are formed;
  • trackletslist of tracks.
Message about the Server activity when the Server has no other messages:
{

  "heartbeat": {}

}
Message about the time during which the Server is active and you can receive data from it:
{
  "configUpdate": {
    "maxChannelIdleMs": 15000
  }
}
  • No labels