Skip to content

Commit

Permalink
Deallocate Mats in feature-matching example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedll authored and deadprogram committed May 15, 2023
1 parent 2cc0671 commit 5b45349
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/feature-matching/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ func main() {
defer sift.Close()

// detecting and computing keypoints using SIFT method
kp1, des1 := sift.DetectAndCompute(query, gocv.NewMat())
kp2, des2 := sift.DetectAndCompute(train, gocv.NewMat())
queryMask := gocv.NewMat()
defer queryMask.Close()
kp1, des1 := sift.DetectAndCompute(query, queryMask)
defer des1.Close()

trainMask := gocv.NewMat()
defer trainMask.Close()
kp2, des2 := sift.DetectAndCompute(train, trainMask)
defer des2.Close()

// finding K best matches for each descriptor
bf := gocv.NewBFMatcher()
Expand Down Expand Up @@ -77,6 +84,7 @@ func main() {

// new matrix for output image
out := gocv.NewMat()
defer out.Close()
// drawing matches
gocv.DrawMatches(query, kp1, train, kp2, good, &out, c1, c2, mask, gocv.DrawDefault)

Expand Down

0 comments on commit 5b45349

Please sign in to comment.