Skip to content

Commit

Permalink
added missing Empty method
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohce committed Aug 30, 2024
1 parent 26b4b0e commit 4c69183
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/face.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "face.h"

bool FaceRecognizer_Empty(FaceRecognizer fr) {
return (*fr)->empty();
}

void FaceRecognizer_Train(FaceRecognizer fr, Mats mats, IntVector labels_in) {
std::vector<int> labels;

Expand Down
4 changes: 4 additions & 0 deletions contrib/face.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type LBPHFaceRecognizer struct {
p C.LBPHFaceRecognizer
}

func (fr *LBPHFaceRecognizer) Empty() bool {
return faceRecognizer_Empty(C.FaceRecognizer(fr.p))
}

// NewLBPHFaceRecognizer creates a new LBPH Recognizer model.
//
// For further information, see:
Expand Down
4 changes: 4 additions & 0 deletions contrib/face.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct PredictResponse {
double confidence;
};

bool FaceRecognizer_Empty(FaceRecognizer fr);
void FaceRecognizer_Train(FaceRecognizer fr, Mats images, IntVector labels);
void FaceRecognizer_Update(FaceRecognizer fr, Mats images, IntVector labels);
int FaceRecognizer_Predict(FaceRecognizer fr, Mat sample);
Expand All @@ -44,6 +45,9 @@ int LBPHFaceRecognizer_GetGridX(LBPHFaceRecognizer fr);
int LBPHFaceRecognizer_GetGridY(LBPHFaceRecognizer fr);
void LBPHFaceRecognizer_Close(LBPHFaceRecognizer fr);




#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions contrib/face_recognizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

type FaceRecognizer interface {
Empty() bool
Train(images []gocv.Mat, labels []int)
Update(newImages []gocv.Mat, newLabels []int)
Predict(sample gocv.Mat) int
Expand All @@ -23,6 +24,11 @@ type FaceRecognizer interface {
Close() error
}

func faceRecognizer_Empty(fr C.FaceRecognizer) bool {
b := C.FaceRecognizer_Empty(fr)
return bool(b)
}

func faceRecognizer_Train(fr C.FaceRecognizer, images []gocv.Mat, labels []int) {
cparams := []C.int{}
for _, v := range labels {
Expand Down
2 changes: 2 additions & 0 deletions contrib/face_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func TestLBPHFaceRecognizer_Methods(t *testing.T) {
t.Errorf("Invalid NewLBPHFaceRecognizer call %v", model)
}

model.Empty()

labels := []int{1, 1, 1, 1, 2, 2, 2, 2}
images := []gocv.Mat{
gocv.IMRead("./att_faces/s1/1.pgm", gocv.IMReadGrayScale),
Expand Down

0 comments on commit 4c69183

Please sign in to comment.