reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-15 400044583627cc72a1a3071f1a389e18953cbba0
update
5个文件已删除
1个文件已修改
729 ■■■■■ 已修改文件
common/flow.go 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/helper.go 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/lockList.go 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/recv.go 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/send.go 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/torule.go 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/flow.go
File was deleted
common/helper.go
@@ -1,28 +1,11 @@
package common
import (
    "context"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "strconv"
    "time"
    "basic.com/libgowrapper/sdkstruct.git"
    "basic.com/pubsub/protomsg.git"
    "basic.com/valib/deliver.git"
    "github.com/gogo/protobuf/proto"
)
const mode = deliver.PushPull
// GetIpcAddress get ipc
func GetIpcAddress(shm bool, id string) string {
    if shm {
        return id
    }
    return `ipc:///tmp/` + id + `.ipc`
}
// SubConfig sub
type SubConfig struct {
@@ -56,119 +39,5 @@
// Atoi atoi
func Atoi(s string) int {
    i, _ := strconv.Atoi(s)
    return i
}
// UnserilizeProto un
func UnserilizeProto(ctx context.Context, data <-chan []byte, out chan<- protomsg.SdkMessage, fn func(...interface{})) {
    for {
        select {
        case <-ctx.Done():
            return
        case d := <-data:
            if len(d) < 100 {
                continue
            }
            msg := protomsg.SdkMessage{}
            if err := proto.Unmarshal(d, &msg); err != nil {
                fn(err, " msg 处理异常")
                continue
            }
            out <- msg
        default:
            time.Sleep(10 * time.Millisecond)
        }
    }
}
// Msg2MsgSDK msg->msgsdk
func Msg2MsgSDK(msg protomsg.SdkMessage) *sdkstruct.MsgSDK {
    d, err := proto.Marshal(&msg)
    if err != nil {
        return nil
    }
    index, count := int(msg.Tasklab.Index), len(msg.Tasklab.Sdkinfos)
    if index >= count {
        return &sdkstruct.MsgSDK{
            MsgData:    d,
            SdkCount:   count,
            SdkIndex:   index,
            SdkDataLen: 0,
        }
    }
    return &sdkstruct.MsgSDK{
        MsgData:    d,
        SdkCount:   count,
        SdkIndex:   index,
        SdkDataLen: len(d),
    }
}
// EjectResult eject
func EjectResult(res []byte, msg protomsg.SdkMessage, out chan<- sdkstruct.MsgSDK) {
    if res == nil {
        s := Msg2MsgSDK(msg)
        if s == nil {
            return
        }
        out <- *s
        return
    }
    msg.Tasklab.Sdkinfos[int(msg.Tasklab.Index)].Sdkdata = res
    s := Msg2MsgSDK(msg)
    if s == nil {
        return
    }
    out <- *s
}
/////////////////////////////////////////////////////////////
// ValidRemoteMessage valid or not
func ValidRemoteMessage(msg protomsg.SdkMessage, fnName string, fn func(...interface{})) bool {
    if msg.Tasklab == nil {
        fn(fnName, " recieve msg nil")
        return false
    }
    sdkLen := len(msg.Tasklab.Sdkinfos)
    if sdkLen == 0 {
        fn(fnName, " has no sdk info")
        return false
    }
    curIndex := int(msg.Tasklab.Index)
    if curIndex < 0 || curIndex >= sdkLen {
        fn(fnName, " tasklab index ", curIndex, " error")
        return false
    }
    if msg.Tasklab.Sdkinfos[curIndex].Sdktype != fnName {
        fn(fnName, " is different from ", msg.Tasklab.Sdkinfos[curIndex].Sdktype)
        return false
    }
    return true
}
// UnpackImage unpack
func UnpackImage(msg protomsg.SdkMessage, fnName string, fn func(...interface{})) *protomsg.Image {
    // 反序列化数据得到sdk入参
    i := &protomsg.Image{}
    err := proto.Unmarshal(msg.Data, i)
    if err != nil {
        fn(fnName, " protobuf decode CameraImage error: ", err.Error())
        return nil
    }
    if i.Data == nil {
        fn(fnName, " protomsg.Image data null")
        return nil
    }
    return i
}
common/lockList.go
File was deleted
common/recv.go
File was deleted
common/send.go
File was deleted
common/torule.go
File was deleted