Giter Club home page Giter Club logo

Comments (4)

deadprogram avatar deadprogram commented on June 25, 2024 1

Keeping the same patterns as used by the other wrappers is the best bet. But I see from the PR that you already also came to that same conclusion 😸

Thanks for working on this @Cartermel

from gocv.

Cartermel avatar Cartermel commented on June 25, 2024

I noticed the keypoints are being copied back over to c++ in a couple of functions:

func DrawKeyPoints(src Mat, keyPoints []KeyPoint, dst *Mat, color color.RGBA, flag DrawMatchesFlag) {

func DrawMatches(img1 Mat, kp1 []KeyPoint, img2 Mat, kp2 []KeyPoint, matches1to2 []DMatch, outImg *Mat, matchColor color.RGBA, singlePointColor color.RGBA, matchesMask []byte, flags DrawMatchesFlag) {

Should be trivial to implement for BRIEF, I was originally worried about the performance impact of copying the keypoints since, for my use case at least, I'll be running this against thousands of images. But I ran some benchmarks and copying the struct between c++ / go is extremely lightweight, which makes sense since the keypoint struct is very small.

Here's some data for anyone curious:
(I only used time.Now() and time.Since() for measuring elapsed, there's probably a better way but I didn't search)

elapsed times are the average of 3 runs rounded to nearest 100ms

5000 iterations:
No copy: 26200ms
Copy:    27800ms
No copy 1600ms faster 
~5.9% difference

10000 iterations:
No copy: 52000ms
Copy:    55400ms
No copy 3400ms faster
~6.3% difference

This was using this function for computing the descriptors using BRIEF and copying from go (my vscode syntax highlighting is broken...) :
image

Where VectorOfKeyPoint is a custom struct that's just a ptr to a vectorcv::KeyPoint for testing. And the c++ implementation was:
image

And the native c++ implementation without copying was this:
image

Where I passed in the same FastFeatureDector from golang. Not shown is the code for creating the BriefDescriptorExtractor, but its the same as all the other feature2d alg initialization.

This is running on a Ryzen 7 5800X.

TLDR

Copying the keypoints from golang for use in BRIEF results in about a 6% time loss (on my minimal testing), but leaves all the existing keypoint implementation intact. Personally I think this is a fine trade off, I'm interested in knowing what everyone thinks!

In the meantime I'll create a PR for BRIEF and copy the golang keypoints, unless someone's currently building this!

from gocv.

Cartermel avatar Cartermel commented on June 25, 2024

Forgot to add, this was the simple benchmark function:
image

and the native c++ call was basically exactly the same but with the c call.
And it just uses the lenna photo from opencv.

from gocv.

deadprogram avatar deadprogram commented on June 25, 2024

Released as part of 0.36 so now closing. Thank you!

from gocv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.