Closed ghost closed 4 years ago
Hello there! @x0rzkov I've made PR in example main.go file: https://github.com/LdDl/go-darknet/blob/master/example/main.go#L84
It uses https://github.com/disintegration/imaging (MIT license)
Convert darknet's bbox to image.Rectangle of standart library
minX, minY := float64(bBox.StartPoint.X), float64(bBox.StartPoint.Y)
maxX, maxY := float64(bBox.EndPoint.X), float64(bBox.EndPoint.Y)
rect := image.Rect(round(minX), round(minY), round(maxX), round(maxY))
Crop *image.NRGBAfrom image via provided rect (disintegration's library must be used)
rectcropimg := imaging.Crop(imgSrc, bbox)
And then you are good to go with saving *image.NRGBA to file:
f, err := os.Create(fname)
if err != nil {
return err
}
defer f.Close()
err = jpeg.Encode(f, rectcropimg, nil)
if err != nil {
return err
}
awesome, will try just now
works like a charm :-) Spassiba
glad to know it works :) closing
Hi,
Again ! :-)
I was wondering if there is a function to crop the content of the bounding box in separate pictures ?
Cheers, X.