/openpose

human pose detection/estimation golang implementation using tensoflow openpose model

Primary LanguageGoApache License 2.0Apache-2.0

Golang lib for pose detection using tensorflow openpose

Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

Prerequest

  1. libtensorfow 1.x Follow the instruction Install TensorFlow for C
  2. download tenorflow model graph

Demo

demo screen capture

Install

go get -u github.com/bububa/openpose

Camera & Server

Requirements

  • libjpeg-turbo (use -tags jpeg to build without CGo)
  • On Linux/RPi native Go V4L implementation is used to capture images.

Use Opencv4

make cvcamera

On linux/Pi

# use native Go V4L implementation is used to capture images
make linux_camera

Use image/jpeg instead of libjpeg-turbo

use jpeg build tag to build with native Go image/jpeg instead of libjpeg-turbo

go build -o=./bin/cvcamera -tags=cv4,jpeg ./cmd/camera

Usage as Server

Usage of camera:
  -bind string
	Bind address (default ":56000")
  -delay int
	Delay between frames, in milliseconds (default 10)
  -width float
	Frame width (default 640)
  -height float
	Frame height (default 480)
  -index int
	Camera index
  -model string
    mode path

User as lib

import (
    "github.com/bububa/openpose"
)

func main() {
	t := openpose.NewPoseEstimator(modelPath, openpose.MobileNet)
	wd, _ := os.Getwd()
	img, err := loadImage("./golf.jpg")
	if err != nil {
		log.Fatalln(err)
	}
	modelSize := openpose.ModelSizeFaster
	sharpenSigma := 0.0
	t.SetSharpenSigma(sharpenSigma)
	humans, err := t.Estimate(img, modelSize)
	if err != nil {
		log.Fatalln(err)
	}
	outImg := openpose.DrawHumans(img, humans, 2)
    saveImage(outImg, "./out/jpg")
}