You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, everything is looking fine on Android, camera and opencv library are loaded, except detecting a target image. I tried to change targets and used png & jpg but no luck. Also image data is loaded to app but the image features detection is not working. Below is the javascript code.
Appreciate your help.
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
var imgDetectionPlugin = window.plugins.ImageDetectionPlugin || new ImageDetectionPlugin();
imgDetectionPlugin.startProcessing(true, function(success){console.log(success);}, function(error){console.log(error);});
imgDetectionPlugin.isDetecting(function(success){
console.log(success);
var resp = JSON.parse(success);
console.log(resp.index, "image detected - ", indexes[resp.index]);
}, function(error){console.log(error);});
function setAllPatterns(patterns) {
imgDetectionPlugin.setPatterns(patterns, function(success){console.log(success);}, function(error){console.log(error);});
}
var loadAllImg = 0;
var patternsHolder = [];
var indexes = {};
var limit = 1;
function ToDataURL (self) {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var dataURL;
canvas.height = self.height;
canvas.width = self.width;
ctx.drawImage(self, 0, 0);
dataURL = canvas.toDataURL("image/jpeg", 0.8);
//console.log(dataURL);
patternsHolder.push(dataURL);
indexes[loadAllImg] = self.src.substr(self.src.lastIndexOf("/") + 1);
loadAllImg += 1;
console.log("!!!", loadAllImg, indexes);
if(loadAllImg == limit){
console.log("patterns set", patternsHolder);
setAllPatterns(patternsHolder);
}
canvas = null;
}
var img = new Image();
img.crossOrigin = "Anonymous";
img.onload = function(){
ToDataURL(this)
};
img.src = "img/koclogo.png";
imgDetectionPlugin.setDetectionTimeout(2, function(success){console.log(success);}, function(error){console.log(error);});
}
};
app.initialize();
The text was updated successfully, but these errors were encountered:
Sorry for the late response @mkaouri, glad you managed to get it to work
Yes the plugin is using openCV feature matching to do the detection of similar images so the more rich in features the image is, the more likely it is for it to find a match
Hi, everything is looking fine on Android, camera and opencv library are loaded, except detecting a target image. I tried to change targets and used png & jpg but no luck. Also image data is loaded to app but the image features detection is not working. Below is the javascript code.
Appreciate your help.
The text was updated successfully, but these errors were encountered: