Video Analysis底层库拆分,sdk的go封装
Unknown
2019-07-12 768cdfe80e3cdd37448ca967b3c72d9837b626d7
增加多线程处理

1个文件已修改
17 ■■■■ 已修改文件
gosdk.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gosdk.go
@@ -18,7 +18,10 @@
// YoloHandle wrap C
type YoloHandle struct {
    handle C.YoloHandle
    LastYoloObjs []CObjTrackInfo //yolo跟踪的上一帧信息
    LastTrackID uint64       //yolo 被使用的ID
}
const RatioInterTrack = 50       //跟踪判断重叠阈值
// SDKImage sdk image
type SDKImage struct {
@@ -26,10 +29,6 @@
    Width  int
    Height int
}
var LastYoloObjs []CObjTrackInfo //yolo跟踪的上一帧信息
var LastTrackID uint64 = 0       //yolo 被使用的ID
const RatioInterTrack = 50       //跟踪判断重叠阈值
// InitYolo init yolo sdk
func InitYolo(fc, fw, fn string, gi int) *YoloHandle {
@@ -44,7 +43,7 @@
    g := C.int(gi)
    p := C.c_api_yolo_init(c, w, n, g)
    return &YoloHandle{p}
    return &YoloHandle{handle:p}
}
// InitFaceDetector init face detector
@@ -327,7 +326,7 @@
    //LastYoloObjs
    detectObjs := YoloDetect(handle, img, thrsh, umns)
    for _, vLast := range LastYoloObjs {
    for _, vLast := range handle.LastYoloObjs {
        for i := 0; i < len(detectObjs); i++ {
            //fmt.Println("vNew.Typ:", vNew.Typ)
            if vLast.ObjInfo.Typ == detectObjs[i].Typ { //同一类别,比如都是人体
@@ -350,8 +349,8 @@
    if len(detectObjs) > 0 {
        for _, vAdd := range detectObjs {
            tmp.ObjInfo = vAdd
            tmp.ID = LastTrackID
            LastTrackID++
            tmp.ID = handle.LastTrackID
            handle.LastTrackID++
            allObjs = append(allObjs, tmp)
            newObjs = append(newObjs, tmp)
@@ -359,7 +358,7 @@
    }
    //刷新上一帧的跟踪目标
    LastYoloObjs = allObjs
    handle.LastYoloObjs = allObjs
    return allObjs, newObjs
}