Small typo fix

This commit is contained in:
Endre Simo
2018-04-23 21:48:17 +03:00
4 changed files with 45 additions and 7 deletions

View File

@@ -10,6 +10,8 @@ import (
"log"
"math"
"os"
"os/signal"
"syscall"
"time"
"gocv.io/x/gocv"
@@ -114,6 +116,16 @@ func (c *Carver) ComputeSeams(img *image.NRGBA, p *Processor) []float64 {
for _, face := range faces {
draw.Draw(sobel, face.Bounds(), &image.Uniform{color.RGBA{255, 255, 255, 255}}, image.ZP, draw.Src)
}
// Capture CTRL-C signal and remove the generated temporary image.
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
for range c {
RemoveTempImage(TempImage)
os.Exit(1)
}
}()
}
if p.BlurRadius > 0 {
@@ -329,3 +341,11 @@ func (c *Carver) RotateImage270(src *image.NRGBA) *image.NRGBA {
}
return dst
}
// RemoveTempImage removes the temporary image generated during face detection process.
func RemoveTempImage(tmpImage string) {
// Remove temporary image file.
if _, err := os.Stat(tmpImage); err == nil {
os.Remove(tmpImage)
}
}