LdDl / go-darknet

Go bindings for Darknet (YOLO v4 / v7-tiny / v3)
Apache License 2.0
82 stars 19 forks source link

add support detecting #10

Open Danile71 opened 3 years ago

Danile71 commented 3 years ago

need https://github.com/AlexeyAB/darknet/pull/6838 for libdarknet

example:


result, bboxs := darknet.Detect(*imageFile)
    if result != -1 {
        for _, bbox := range bboxs {
            fmt.Println(bbox.Rect, bbox.Confidence, bbox.ObjId)
        }
    }
LdDl commented 3 years ago

Do we really need tight OpenCV integration?

// #cgo windows  CPPFLAGS:   -IC:/opencv/build/install/include
// #cgo windows  LDFLAGS:    -LC:/opencv/build/install/x64/mingw/lib -lopencv_core420 -lopencv_face420 -lopencv_videoio420 -lopencv_imgproc420 -lopencv_highgui420 -lopencv_imgcodecs420 -lopencv_objdetect420 -lopencv_features2d420 -lopencv_video420 -lopencv_dnn420 -lopencv_xfeatures2d420 -lopencv_plot420 -lopencv_tracking420 -lopencv_img_hash420 -lopencv_calib3d420

although, you can get image.Image by using this GoCV method: https://godoc.org/gocv.io/x/gocv#Mat.ToImage then you can convert it do DarknetImage https://github.com/LdDl/go-darknet/blob/master/image.go#L61

pseudocode:

gocvMat := gocv.NewMat()
stdMat := gocvMat.ToImage()
darknetImage := darknet.Image2Float32(stdMat)
Danile71 commented 3 years ago

Do we really need tight OpenCV integration?

// #cgo windows  CPPFLAGS:   -IC:/opencv/build/install/include
// #cgo windows  LDFLAGS:    -LC:/opencv/build/install/x64/mingw/lib -lopencv_core420 -lopencv_face420 -lopencv_videoio420 -lopencv_imgproc420 -lopencv_highgui420 -lopencv_imgcodecs420 -lopencv_objdetect420 -lopencv_features2d420 -lopencv_video420 -lopencv_dnn420 -lopencv_xfeatures2d420 -lopencv_plot420 -lopencv_tracking420 -lopencv_img_hash420 -lopencv_calib3d420

although, you can get image.Image by using this GoCV method: https://godoc.org/gocv.io/x/gocv#Mat.ToImage then you can convert it do DarknetImage https://github.com/LdDl/go-darknet/blob/master/image.go#L61

pseudocode:

gocvMat := gocv.NewMat()
stdMat := gocvMat.ToImage()
darknetImage := darknet.Image2Float32(stdMat)

gocv can't work without opencv libs.

I will test, imho direct using mat will be faster, then converting

LdDl commented 3 years ago

Do we really need tight OpenCV integration?

// #cgo windows  CPPFLAGS:   -IC:/opencv/build/install/include
// #cgo windows  LDFLAGS:    -LC:/opencv/build/install/x64/mingw/lib -lopencv_core420 -lopencv_face420 -lopencv_videoio420 -lopencv_imgproc420 -lopencv_highgui420 -lopencv_imgcodecs420 -lopencv_objdetect420 -lopencv_features2d420 -lopencv_video420 -lopencv_dnn420 -lopencv_xfeatures2d420 -lopencv_plot420 -lopencv_tracking420 -lopencv_img_hash420 -lopencv_calib3d420

although, you can get image.Image by using this GoCV method: https://godoc.org/gocv.io/x/gocv#Mat.ToImage then you can convert it do DarknetImage https://github.com/LdDl/go-darknet/blob/master/image.go#L61 pseudocode:

gocvMat := gocv.NewMat()
stdMat := gocvMat.ToImage()
darknetImage := darknet.Image2Float32(stdMat)

gocv can't work without opencv libs.

I will test, imho direct using mat will be faster, then converting

gocv can't work without opencv libs.

I know about it :) You can check current workflow around mat/float32/raw bytes here: https://github.com/LdDl/odam