mirror of
				https://github.com/esimov/pigo.git
				synced 2025-10-31 19:32:40 +08:00 
			
		
		
		
	Changed cmd exmple public functions to private
This commit is contained in:
		| @@ -48,8 +48,8 @@ var ( | |||||||
|  |  | ||||||
| var dc *gg.Context | var dc *gg.Context | ||||||
|  |  | ||||||
| // FaceDetector struct contains Pigo face detector general settings. | // faceDetector struct contains Pigo face detector general settings. | ||||||
| type FaceDetector struct { | type faceDetector struct { | ||||||
| 	cascadeFile  string | 	cascadeFile  string | ||||||
| 	minSize      int | 	minSize      int | ||||||
| 	maxSize      int | 	maxSize      int | ||||||
| @@ -58,9 +58,9 @@ type FaceDetector struct { | |||||||
| 	iouThreshold float64 | 	iouThreshold float64 | ||||||
| } | } | ||||||
|  |  | ||||||
| // DetectionResult contains the coordinates of the detected faces and the base64 converted image. | // detectionResult contains the coordinates of the detected faces and the base64 converted image. | ||||||
| type DetectionResult struct { | type detectionResult struct { | ||||||
| 	Faces []image.Rectangle | 	rects []image.Rectangle | ||||||
| } | } | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| @@ -90,19 +90,19 @@ func main() { | |||||||
| 	s.start("Processing...") | 	s.start("Processing...") | ||||||
| 	start := time.Now() | 	start := time.Now() | ||||||
|  |  | ||||||
| 	fd := NewFaceDetector(*cascadeFile, *minSize, *maxSize, *shiftFactor, *scaleFactor, *iouThreshold) | 	fd := newFaceDetector(*cascadeFile, *minSize, *maxSize, *shiftFactor, *scaleFactor, *iouThreshold) | ||||||
| 	faces, err := fd.DetectFaces(*source) | 	faces, err := fd.detectFaces(*source) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Fatalf("Detection error: %v", err) | 		log.Fatalf("Detection error: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	_, rects, err := fd.DrawFaces(faces, *circleMarker) | 	_, rects, err := fd.drawFaces(faces, *circleMarker) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Fatalf("Error creating the image output: %s", err) | 		log.Fatalf("Error creating the image output: %s", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	resp := DetectionResult{ | 	resp := detectionResult{ | ||||||
| 		Faces: rects, | 		rects: rects, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	out, err := json.Marshal(resp) | 	out, err := json.Marshal(resp) | ||||||
| @@ -114,9 +114,9 @@ func main() { | |||||||
| 	fmt.Printf("\nDone in: \x1b[92m%.2fs\n", time.Since(start).Seconds()) | 	fmt.Printf("\nDone in: \x1b[92m%.2fs\n", time.Since(start).Seconds()) | ||||||
| } | } | ||||||
|  |  | ||||||
| // NewFaceDetector initialises the constructor function. | // newFaceDetector initialises the constructor function. | ||||||
| func NewFaceDetector(cf string, minSize, maxSize int, shf, scf, iou float64) *FaceDetector { | func newFaceDetector(cf string, minSize, maxSize int, shf, scf, iou float64) *faceDetector { | ||||||
| 	return &FaceDetector{ | 	return &faceDetector{ | ||||||
| 		cascadeFile:  cf, | 		cascadeFile:  cf, | ||||||
| 		minSize:      minSize, | 		minSize:      minSize, | ||||||
| 		maxSize:      maxSize, | 		maxSize:      maxSize, | ||||||
| @@ -126,8 +126,8 @@ func NewFaceDetector(cf string, minSize, maxSize int, shf, scf, iou float64) *Fa | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| // DetectFaces run the detection algorithm over the provided source image. | // detectFaces run the detection algorithm over the provided source image. | ||||||
| func (fd *FaceDetector) DetectFaces(source string) ([]pigo.Detection, error) { | func (fd *faceDetector) detectFaces(source string) ([]pigo.Detection, error) { | ||||||
| 	src, err := pigo.GetImage(source) | 	src, err := pigo.GetImage(source) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -176,8 +176,8 @@ func (fd *FaceDetector) DetectFaces(source string) ([]pigo.Detection, error) { | |||||||
| 	return faces, nil | 	return faces, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| // DrawFaces marks the detected faces with a circle in case isCircle is true, otherwise marks with a rectangle. | // drawFaces marks the detected faces with a circle in case isCircle is true, otherwise marks with a rectangle. | ||||||
| func (fd *FaceDetector) DrawFaces(faces []pigo.Detection, isCircle bool) ([]byte, []image.Rectangle, error) { | func (fd *faceDetector) drawFaces(faces []pigo.Detection, isCircle bool) ([]byte, []image.Rectangle, error) { | ||||||
| 	var ( | 	var ( | ||||||
| 		qThresh float32 = 5.0 | 		qThresh float32 = 5.0 | ||||||
| 		rects   []image.Rectangle | 		rects   []image.Rectangle | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Endre Simo
					Endre Simo