mirror of
https://github.com/LdDl/go-darknet.git
synced 2025-10-05 15:46:49 +08:00
remove defer for image
This commit is contained in:
@@ -25,6 +25,12 @@ type DetectionResult struct {
|
||||
OverallTimeTaken time.Duration
|
||||
}
|
||||
|
||||
// func (dr *DetectionResult) Close() error {
|
||||
// C.free_detections(dr.Detections, len(dr.Detections))
|
||||
// dr.Detections = nil
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func makeDetection(img *DarknetImage, det *C.detection, threshold float32, classes int, classNames []string) *Detection {
|
||||
if det == nil {
|
||||
return &Detection{}
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
|
||||
"time"
|
||||
darknet "github.com/LdDl/go-darknet"
|
||||
"github.com/disintegration/imaging"
|
||||
)
|
||||
@@ -61,13 +61,13 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer imgDarknet.Close()
|
||||
|
||||
|
||||
dr, err := n.Detect(imgDarknet)
|
||||
if err != nil {
|
||||
printError(err)
|
||||
return
|
||||
}
|
||||
imgDarknet.Close()
|
||||
|
||||
log.Println("Network-only time taken:", dr.NetworkOnlyTimeTaken)
|
||||
log.Println("Overall time taken:", dr.OverallTimeTaken, len(dr.Detections))
|
||||
@@ -92,6 +92,7 @@ func main() {
|
||||
// }
|
||||
}
|
||||
}
|
||||
time.Sleep(100*time.Millisecond)
|
||||
}
|
||||
|
||||
func imageToBytes(img image.Image) ([]byte, error) {
|
||||
|
Reference in New Issue
Block a user