Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance : dependencies upgrade #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ First, you need to load and parse the binary classifier, then convert the image
and finally run the cascade function which returns a slice containing the row, column, scale and the detection score.

```Go
cascadeFile, err := ioutil.ReadFile("/path/to/cascade/file")
cascadeFile, err := os.ReadFile("/path/to/cascade/file")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand Down
5 changes: 2 additions & 3 deletions core/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ Package pigo is a lightweight pure Go face detection, pupil/eyes localization an
based on Pixel Intensity Comparison-based Object detection paper (https://arxiv.org/pdf/1305.4537.pdf).
Is platform agnostic and does not require any external dependencies and third party modules.


Face detection API example
# Face detection API example

First you need to load and parse the binary classifier, then convert the image to grayscale mode
and finally to run the cascade function which returns a slice containing the row, column, scale and the detection score.

cascadeFile, err := ioutil.ReadFile("/path/to/cascade/file")
cascadeFile, err := os.ReadFile("/path/to/cascade/file")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions core/flploc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package pigo

import (
"errors"
"io/ioutil"
"math"
"os"
"path/filepath"
"sync"
)
Expand All @@ -25,7 +25,7 @@ var flplocPool = sync.Pool{
// UnpackFlp unpacks the facial landmark points cascade file.
// This will return the binary representation of the cascade file.
func (plc *PuplocCascade) UnpackFlp(cf string) (*PuplocCascade, error) {
flpc, err := ioutil.ReadFile(cf)
flpc, err := os.ReadFile(cf)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -58,7 +58,7 @@ func (plc *PuplocCascade) GetLandmarkPoint(leftEye, rightEye *Puploc, img ImageP

// ReadCascadeDir reads the facial landmark points cascade files from the provided directory.
func (plc *PuplocCascade) ReadCascadeDir(path string) (map[string][]*FlpCascade, error) {
cascades, err := ioutil.ReadDir(path)
cascades, err := os.ReadDir(path)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions core/flploc_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package pigo_test

import (
"io/ioutil"
"log"
"os"
"runtime"
"testing"

Expand All @@ -14,7 +14,7 @@ var flpc []byte
const perturb = 63

func init() {
flpc, err = ioutil.ReadFile("../cascade/lps/lp42")
flpc, err = os.ReadFile("../cascade/lps/lp42")
if err != nil {
log.Fatalf("missing cascade file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"image/color"
"image/color/palette"
"image/draw"
"io/ioutil"
"os"
"path/filepath"
"testing"
)

func TestGetImage(t *testing.T) {
path := filepath.Join("../testdata", "test.png")
_, err := ioutil.ReadFile(path)
_, err := os.ReadFile(path)
if err != nil {
t.Fatalf("unable to read the file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/pigo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package pigo_test

import (
"image"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
"testing"
Expand All @@ -20,7 +20,7 @@ var (
)

func init() {
faceCasc, err = ioutil.ReadFile("../cascade/facefinder")
faceCasc, err = os.ReadFile("../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/puploc_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package pigo_test

import (
"io/ioutil"
"log"
"os"
"runtime"
"testing"

Expand All @@ -18,7 +18,7 @@ var (
)

func init() {
puplocCasc, err = ioutil.ReadFile("../cascade/puploc")
puplocCasc, err = os.ReadFile("../cascade/puploc")
if err != nil {
log.Fatalf("error reading the puploc cascade file: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/blinkdet/blinkdet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "C"

import (
"io/ioutil"
"log"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -101,7 +101,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that the face detection classifier is loaded only once.
if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand All @@ -117,7 +117,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that we load the pupil localization cascade only once
if len(puplocCascade) == 0 {
puplocCascade, err := ioutil.ReadFile("../../cascade/puploc")
puplocCascade, err := os.ReadFile("../../cascade/puploc")
if err != nil {
log.Fatalf("Error reading the puploc cascade file: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/facedet/pigo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "C"

import (
"io/ioutil"
"log"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -73,7 +73,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {
}

if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/facial_landmark/flploc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "C"

import (
"io/ioutil"
"log"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -136,7 +136,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that the face detection classifier is loaded only once.
if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand All @@ -152,7 +152,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that we load the pupil localization cascade only once
if len(puplocCascade) == 0 {
puplocCascade, err := ioutil.ReadFile("../../cascade/puploc")
puplocCascade, err := os.ReadFile("../../cascade/puploc")
if err != nil {
log.Fatalf("Error reading the puploc cascade file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/masquerade/puploc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import "C"

import (
"io/ioutil"
"log"
"math"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -112,7 +112,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that the face detection classifier is loaded only once.
if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand All @@ -128,7 +128,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that we load the pupil localization cascade only once
if len(puplocCascade) == 0 {
puplocCascade, err := ioutil.ReadFile("../../cascade/puploc")
puplocCascade, err := os.ReadFile("../../cascade/puploc")
if err != nil {
log.Fatalf("Error reading the puploc cascade file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/puploc/puploc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "C"

import (
"io/ioutil"
"log"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -101,7 +101,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that the face detection classifier is loaded only once.
if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand All @@ -117,7 +117,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that we load the pupil localization cascade only once
if len(puplocCascade) == 0 {
puplocCascade, err := ioutil.ReadFile("../../cascade/puploc")
puplocCascade, err := os.ReadFile("../../cascade/puploc")
if err != nil {
log.Fatalf("Error reading the puploc cascade file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/talk_detector/talkdet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import "C"

import (
"io/ioutil"
"log"
"math"
"os"
"runtime"
"unsafe"

Expand Down Expand Up @@ -166,7 +166,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that the face detection classifier is loaded only once.
if len(cascade) == 0 {
cascade, err = ioutil.ReadFile("../../cascade/facefinder")
cascade, err = os.ReadFile("../../cascade/facefinder")
if err != nil {
log.Fatalf("Error reading the cascade file: %v", err)
}
Expand All @@ -182,7 +182,7 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {

// Ensure that we load the pupil localization cascade only once
if len(puplocCascade) == 0 {
puplocCascade, err := ioutil.ReadFile("../../cascade/puploc")
puplocCascade, err := os.ReadFile("../../cascade/puploc")
if err != nil {
log.Fatalf("Error reading the puploc cascade file: %s", err)
}
Expand Down
5 changes: 2 additions & 3 deletions examples/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"image/color"
"image/jpeg"
"io"
"io/ioutil"
"log"
"math"
"mime/multipart"
Expand Down Expand Up @@ -79,7 +78,7 @@ func webcam(w http.ResponseWriter, r *http.Request) {
}
cmd.Start()

cascadeFile, err := ioutil.ReadFile(*cascadeFile)
cascadeFile, err := os.ReadFile(*cascadeFile)
if err != nil {
log.Fatalf("[ERROR] reading the cascade file: %v", err)
}
Expand All @@ -104,7 +103,7 @@ func webcam(w http.ResponseWriter, r *http.Request) {
return
}

data, err := ioutil.ReadAll(p)
data, err := io.ReadAll(p)
if err != nil {
log.Println("[ERROR] reading from bytes ", err)
continue
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.22
require (
github.com/disintegration/imaging v1.6.2
github.com/fogleman/gg v1.3.0
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407
golang.org/x/term v0.23.0
)

require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf // indirect
golang.org/x/image v0.19.0 // indirect
golang.org/x/sys v0.24.0 // indirect
)
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzP
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf h1:kt3wY1Lu5MJAnKTfoMR52Cu4gwvna4VTzNOiT8tY73s=
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407 h1:5zh5atpUEdIc478E/ebrIaHLKcfVvG6dL/fGv7BcMoM=
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5 changes: 2 additions & 3 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand All @@ -20,12 +19,12 @@ func DownloadImage(url string) (*os.File, error) {
}
defer res.Body.Close()

data, err := ioutil.ReadAll(res.Body)
data, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.New(fmt.Sprintf("unable to read response body: %s", err))
}

tmpfile, err := ioutil.TempFile("/tmp", "image")
tmpfile, err := os.CreateTemp("/tmp", "image")
if err != nil {
return nil, errors.New(fmt.Sprintf("unable to create temporary file: %v", err))
}
Expand Down
Loading