Convert keypoints to point2f to store in a file or localstorage

Hi! :slight_smile:
according to the documentation, its possible to convert an KeyPoint into a point2f…

Well im trying to convert an array of keyPoints from cvOrb.

let orb = new cv.ORB();
    orb.setMaxFeatures(MAX_FEATURES);

    cv.cvtColor(object.im, object.gray, cv.COLOR_RGBA2GRAY, 0);
    orb.detectAndCompute(object.gray, new cv.Mat(), object.kp, object.descriptors);

    let t = new cv.Mat();
    object.kp.convertTo(t, )

basically i want to known how-to convert in javascript! :slight_smile:

https://docs.opencv.org/4.5.3/d2/d29/classcv_1_1KeyPoint.html#acfcc8e0dd1a634a7583686e18d372237

other alternative would be to use filestorage to store the keypoints as yaml

https://answers.opencv.org/question/4040/to-save-vector-keypoint-to-file-using-builtin-write-function/

I didn’t find any example, and try to check the bindings and source code, but didn’t get far. is this even possible? thanks.

may i ask, why you want to do this ?
what do you plan to do with the point locations ?
(you’d basically make a loop and extract the pt member from each keypoint)

then, you’re usually not allowed to access the file system from js,
and it’s the same here - no FileStorage

well, i want to do this, because i need to load 40 images everytime i start this app… and it takes time to generate all the keypoints needed. then i could boost the load of the app :slight_smile:
instead of needing to load all the images, i could just load a file with keypoints, and the features matrix.

well, the matching uses descriptors only , so it’s far more imprtant to save those

last, this sounds, like you ty to match a query image to a “gallery” – what is the purpose of it ? if it’s “finding similar images”, you’re probably on the wrong bus, the matching process here is the wrong approach for that (lookup “BagOfWords” then)

are you sure? In here the ORB detectAndCompute is using the keypoints.

this.matcher.orb.detectAndCompute(this.scene.gray, new cv.Mat(), this.scene.kp, this.scene.descriptors);

Anyway I am more focus on just solving on how-to store the keypoints, not on how to detect Images. because that has been debated before and we are happy ORB for our purpose. Anyway i didn’t understand what is your suggestion about that. can you make it more clear? :slight_smile: thanks

it is calculating keypoints here, not using presupplied ones

finally tell us, what that is. (i think, i asked 2 times already …)

you are absolutely correct! thanks :slight_smile:

sorry i didnt explain. so we have a collection of many images that need to be detect using a camera in the real world. When an image is detected the app will redirect the person to a specific url, image, sound, video, or even an AR mode using jsartoolkit5 :wink:

do you have an example of an “image that needs to be detected” and another “using a camera in the real world.” one ?

do you have any code proving your idea works ? how would you measure “similarity” here ?

I released this code (the example is not working yet):

So similarity is measured in here:

1 Like

nice, that you could finish this (without any docs or tuts !)
we now also have a working js example for feature matching here, good !
(ppl will come for this !)

as long as ALL your images come from the (same) camera, it might even give meaningful matching results (just DONT add a feature, where users can upload their own images, then it’ll break, comparing apples to pears)

im finishing up an example on how-to to use it :slight_smile:
what do you mean from the same camera? it works with many different setups. lemme finish this example :slight_smile:
I used many tutorials, and different stuff. opencv is cool!

its working now :slight_smile: you can test it here:
https://albjeremias.github.io/trigger-cv/example/index.htm

So what i want to do is to store the object descriptors in the local storage of the browser or as a file (generated previously)

I wonder if generating it previously bring problems, but i will make some tests. the issue is that i use the videoWidth to calculate the descriptors, but it seems a bit irrelevant, since the image size changes on the camera image too…

1 Like