File was renamed from analysis/demo/simpleIPC.go |
| | |
| | | "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 |
| | |
| | | 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() |
| | |
| | | |
| | | import ( |
| | | "analysis/demo" |
| | | srv "analysis/work/service" |
| | | "flag" |
| | | "fmt" |
| | | ) |
| | |
| | | |
| | | 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() |
| | | } |
| | |
| | | imageChan := make(chan service.ImageInfo) |
| | | |
| | | d := service.NewReciever(ipcURL, imageChan) |
| | | go d.Run(false) |
| | | go d.RunAsClient() |
| | | |
| | | if proc == "" { |
| | | d.Stop() |
File was renamed from analysis/work/service/reciever.go |
| | |
| | | } |
| | | } |
| | | |
| | | // 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 { |