darknet

package
v0.0.0-...-7055065 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 13 Imported by: 0

README

copy from github.com/LdDl/go-darknet

modifications:

  • changed the way to get the number and names of classes from obj.names instead of read from darknet config file.
  • added the feature to draw bounding boxes and labels including to automatically generate colors of boxes and label text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundingBox

type BoundingBox struct {
	StartPoint image.Point
	EndPoint   image.Point
}

BoundingBox represents a bounding box.

type DarknetImage

type DarknetImage struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

DarknetImage represents the image buffer.

func Float32ToDarknetImage

func Float32ToDarknetImage(flatten []float32, width, height int) (*DarknetImage, error)

Float32ToDarknetImage Converts []float32 to darknet image

func Image2Float32

func Image2Float32(src image.Image) (*DarknetImage, error)

func ImageRGBA2Float32

func ImageRGBA2Float32(img *image.RGBA) (*DarknetImage, error)

Image2Float32 Returns []float32 representation of image.Image

func (*DarknetImage) Close

func (img *DarknetImage) Close() error

Close and release resources.

type Detection

type Detection struct {
	BoundingBox

	ClassIDs      []int
	ClassNames    []string
	Probabilities []float32
}

Detection represents a detection.

type DetectionResult

type DetectionResult struct {
	Detections           []*Detection
	NetworkOnlyTimeTaken time.Duration
	OverallTimeTaken     time.Duration
}

DetectionResult represents the inference results from the network.

type YOLONetwork

type YOLONetwork struct {
	GPUDeviceIndex           int
	NetworkConfigurationFile string
	WeightsFile              string
	Threshold                float32

	ClassNames []string
	Classes    int
	// contains filtered or unexported fields
}

YOLONetwork represents a neural network using YOLO.

func (*YOLONetwork) Close

func (n *YOLONetwork) Close() error

Close and release resources.

func (*YOLONetwork) Detect

func (n *YOLONetwork) Detect(img *DarknetImage) (*DetectionResult, error)

Detect specified image

func (*YOLONetwork) DetectAndLabelOnJpeg

func (n *YOLONetwork) DetectAndLabelOnJpeg(jpgBytes *pb.JpgBytes, outputCh *chan *pb.JpgBytes)

func (*YOLONetwork) DrawDetectionResult

func (n *YOLONetwork) DrawDetectionResult(img image.Image, dr *DetectionResult, nowTs int64) image.Image

Draw detected results

func (*YOLONetwork) Init

func (n *YOLONetwork) Init() error

Init the network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL