Ask Your Question
0

unable to get keypoints in opencv.js by orb detect and compute.

asked 2019-07-20 05:38:46 -0600

asifk1997 gravatar image

updated 2019-07-20 06:28:51 -0600

berak gravatar image

here is the code

let orig = cv.imread(canvasOutput1);
let temp = cv.imread(canvasOutput2);
var orb = new cv.ORB(10000);
let des = new cv.Mat();
let img3 = new cv.Mat();
var noArray1 = new cv.Mat();
var kp1 = new cv.KeyPointVector();
// find the keypoints with ORB
orb.detect(orig, kp1, noArray1);
// compute the descriptors with ORB

var das=new cv.Mat();   
orb.compute(orig, kp1, das);

console.log(kp1);   //the keypoint vector is not showing any keypoints like python
for (i=0;i<kp1.size();i++)
{
    console.log(kp1[i].pt);  //this is giving error when trying to print points.
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-09-18 20:51:35 -0600

Hellcho gravatar image

updated 2019-09-18 21:05:21 -0600

Well you could try using kp1.get(0) to check the contents of the first keypoint you have.

Also if you use orb.detect without the noArray1 argument you'll get the keypoints for the whole image, the following code should print all your keypoints on your image.

let orig = cv.imread(canvasOutput1);
var orb = new cv.ORB(10000);
let des = new cv.Mat();
let img3 = new cv.Mat();
var kp1 = new cv.KeyPointVector();
// find the keypoints with ORB
orb.detect(orig, kp1);
// compute the descriptors with ORB
var das=new cv.Mat();   
orb.compute(orig, kp1, das);
cv.drawKeypoints(rsrc2, kp3, img3, [0, 255, 0, 255]);
cv.imshow('canvasID', img3);

Check if that work for you, if not maybe you could have some issue with your opencv.js file, what version are you using?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-07-20 05:38:46 -0600

Seen: 2,084 times

Last updated: Sep 18 '19