视频分析2.0 多进程拆分仓库
zhangmeng
2019-05-06 ffd71d97fc9eb5236e6a92db408745ddf080217b
整理代码
3个文件已删除
2 文件已重命名
2个文件已修改
351 ■■■■■ 已修改文件
analysis/demo/simpleCV.go 151 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/demo/simpleFace.go 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/demo/simpleYolo.go 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/demo/winYolo.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/main.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/proc.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/work/service/ipcreciever.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysis/demo/simpleCV.go
File was deleted
analysis/demo/simpleFace.go
File was deleted
analysis/demo/simpleYolo.go
File was deleted
analysis/demo/winYolo.go
File was renamed from analysis/demo/simpleIPC.go
@@ -11,23 +11,6 @@
    "gocv.io/x/gocv"
)
// RunYoloFromIPC recv data from ipc
func RunYoloFromIPC(ipcURL string, asServer bool) {
    imageChan := make(chan srv.ImageInfo)
    d := srv.NewReciever(ipcURL, imageChan)
    go d.Run(asServer)
    cfg := "./data/yolo/cfg/yolov3.cfg"
    weights := "./data/yolo/yolov3.weights"
    name := "./data/yolo/data/coco.names"
    yolo := gosdk.InitYolo(cfg, weights, name, 0)
    handleImage(yolo, imageChan)
}
func min(x, y int) int {
    if x > y {
        return y
@@ -74,7 +57,15 @@
var startYolo bool
var m sync.Mutex
func handleImage(yolo *gosdk.YoloHandle, ch <-chan srv.ImageInfo) {
// ShowYolo show yolo result
func ShowYolo(ch <-chan srv.ImageInfo) {
    cfg := "./data/yolo/cfg/yolov3.cfg"
    weights := "./data/yolo/yolov3.weights"
    name := "./data/yolo/data/coco.names"
    yolo := gosdk.InitYolo(cfg, weights, name, 0)
    window := gocv.NewWindow("Yolo")
    pic := gocv.NewMat()
analysis/main.go
@@ -2,6 +2,7 @@
import (
    "analysis/demo"
    srv "analysis/work/service"
    "flag"
    "fmt"
)
@@ -29,11 +30,12 @@
    fmt.Println("start test, pic folder: ", picFolder)
    // demo.Face(picFolder)
    // demo.Yolo(streamURL)
    // demo.CVDraw()
    imageChan := make(chan srv.ImageInfo)
    demo.RunYoloFromIPC(ipcURL, true)
    d := srv.NewReciever(ipcURL, imageChan)
    go d.RunAsServer()
    demo.ShowYolo(imageChan)
    fakeStartProc()
}
analysis/proc.go
@@ -15,7 +15,7 @@
    imageChan := make(chan service.ImageInfo)
    d := service.NewReciever(ipcURL, imageChan)
    go d.Run(false)
    go d.RunAsClient()
    if proc == "" {
        d.Stop()
analysis/work/service/ipcreciever.go
File was renamed from analysis/work/service/reciever.go
@@ -53,21 +53,24 @@
    }
}
// Run run task from ipc data
func (r *Reciever) Run(asServer bool) {
    var i *ipc.IPC
    if asServer {
        i = ipc.NewServer(r.ctxIPC.ctx, r.ipcURL)
    } else {
        i = ipc.NewClient(r.ctxIPC.ctx, r.ipcURL)
    }
func (r *Reciever) run(i *ipc.IPC) {
    dataChan := make(chan []byte)
    go unserilizeImageInfo(dataChan, r.chImage)
    i.RecvToChannel(dataChan)
}
// RunAsServer run a IPC server
func (r *Reciever) RunAsServer() {
    r.run(ipc.NewServer(r.ctxIPC.ctx, r.ipcURL))
}
// RunAsClient run as a IPC client
func (r *Reciever) RunAsClient() {
    r.run(ipc.NewClient(r.ctxIPC.ctx, r.ipcURL))
}
// Stop stop reciever, run in goroutine
func (r *Reciever) Stop() {
    if r.ctxIPC.cancel != nil {