inspirit / jsfeat

JavaScript Computer Vision library.
MIT License
2.74k stars 374 forks source link

Help needed!!, ORB matching - How train pattern using image from image folder instead of webcam. #79

Open rohitkshirsagar opened 6 years ago

rohitkshirsagar commented 6 years ago

Could you please help me into it.

jinoantony commented 6 years ago

just get the image data using canvas

var image = new Image();
image.src = "image.jpg";

var c = document.getElementById("myCanvas");
var ctxx = c.getContext("2d");
c.width = image.width;
 c.height = image.height;
ctxx.drawImage(image, 0, 0, image.width, image.height);
var imgData = ctxx.getImageData(0, 0, c.width, c.height);

var imgg = new jsfeat.matrix_t(image.width, image.height, jsfeat.U8_t | jsfeat.C1_t);
jsfeat.imgproc.grayscale(imgData.data, image.width, image.height, imgg);

//Finally change this line in train_pattern()
jsfeat.imgproc.resample(img_u8, lev0_img, new_width, new_height);
//to this
jsfeat.imgproc.resample(imgg, lev0_img, new_width, new_height);
jinoantony commented 6 years ago

@rohitkshirsagar here is the html file

https://drive.google.com/file/d/19uFc0k3vkntF8YjXjRJwvXeHfJvEy07M/view?usp=sharing

rohitkshirsagar commented 6 years ago

@jinoantony Thank yo so much for your help !!