Skip to content

Commit

Permalink
Use Close() functions for all PVL cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Sep 27, 2017
1 parent edcbf41 commit ece17da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 2 additions & 0 deletions examples/pvl_facedetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func main() {
defer img.Delete()

fd := pvl.NewFaceDetector()
defer fd.Close()

fd.SetTrackingModeEnabled(true)

fmt.Printf("start reading camera device: %v\n", deviceID)
Expand Down
8 changes: 2 additions & 6 deletions pvl/pvl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Face Face_New()
return new cv::pvl::Face();
}

void Face_Delete(Face face)
void Face_Close(Face face)
{
delete face;
}
Expand All @@ -32,17 +32,13 @@ Rect Face_GetRect(Face face)
return r;
}

void Faces_Delete(struct Faces fs) {
delete fs.faces;
}

// FaceDetector
FaceDetector FaceDetector_New()
{
return cv::pvl::FaceDetector::create();
}

void FaceDetector_Delete(FaceDetector f)
void FaceDetector_Close(FaceDetector f)
{
delete f;
}
Expand Down
12 changes: 6 additions & 6 deletions pvl/pvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func NewFace() Face {
return Face{p: C.Face_New()}
}

// Delete Face.
func (f *Face) Delete() {
C.Face_Delete(f.p)
// Close Face.
func (f *Face) Close() {
C.Face_Close(f.p)
f.p = nil
}

Expand All @@ -48,9 +48,9 @@ func NewFaceDetector() FaceDetector {
return FaceDetector{p: C.FaceDetector_New()}
}

// Delete object.
func (f *FaceDetector) Delete() {
C.FaceDetector_Delete(f.p)
// Close FaceDetector.
func (f *FaceDetector) Close() {
C.FaceDetector_Close(f.p)
f.p = nil
}

Expand Down
8 changes: 2 additions & 6 deletions pvl/pvl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@ typedef struct Faces {

// Face
Face Face_New();
void Face_Delete(Face f);
void Face_Close(Face f);
void Face_CopyTo(Face src, Face dst);
Rect Face_GetRect(Face f);

// Faces
struct Faces Faces_New();
void Faces_Delete(struct Faces fs);

// FaceDetector
FaceDetector FaceDetector_New();
void FaceDetector_Delete(FaceDetector f);
void FaceDetector_Close(FaceDetector f);
void FaceDetector_SetTrackingModeEnabled(FaceDetector f, bool enabled);
struct Faces FaceDetector_DetectFaceRect(FaceDetector f, Mat img);

Expand Down

0 comments on commit ece17da

Please sign in to comment.