Hi there,
I am trying to wring a test app to use this plugin it it seems it does not work on Android device (did not have a chance to check on iOS yet). Here is more details about my environment and code:
Test device: Samsung Galaxy S8+ with Android 8.1
Android platform was added as
cordova platform add [email protected] (tried with 6.4.0, but result the same)
config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="au.com.test.test1234" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Test app 1</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://somewebsite.com">
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<preference name="Orientation" value="all" />
<config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
<true />
</config-file>
<config-file parent="UIViewControllerBasedStatusBarAppearance" platform="ios" target="*-Info.plist">
<false />
</config-file>
</platform>
<plugin name="cordova-plugin-camera" spec="^4.0.2" />
<plugin name="cordova-plugin-openalpr" spec="^2.0.0" />
<plugin name="phonegap-plugin-barcodescanner" spec="^7.1.0">
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
<engine name="ios" spec="^4.5.4" />
<engine name="android" spec="^6.3.0" />
</widget>
I added the following code to reeivedEvent method in index.js:
try{
navigator.camera.getPicture(function(filepath) {
alert("filepath=" + filepath)
try{
cordova.plugins.OpenALPR.scan(filepath, { country: 'au', amount: 3 },
function (results) {
alert(results);
alert(results.length);
}, function (error) {
alert(error.code + ': ' + error.message);
});
} catch (msg) {
alert(msg);
}
}, function() {
}, {
quality: 60,
destinationType: navigator.camera.DestinationType.FILE_URI, //DATA_URL
encodingType: navigator.camera.EncodingType.JPEG,
mediaType: navigator.camera.MediaType.PICTURE,
sourceType: navigator.camera.PictureSourceType.CAMERA
});
}catch(msg) {
alert(msg);
}
When the code is executed I receive a error message like "0: No image found for given file path". I found the following in OpenALPR.java:
if (imagePath == null || imagePath.length() > 0 || new File(imagePath).isFile()) {
//Otherwise return an error.
returnError("No image found for given file path", callbackContext);
}
It seems if statement has an issue. you must check imagePath.length() == 0 instead of > 0. Is ti correct? If so, can you please upload the fix?
I've applied a fix and if statement works correctly now, success call back is called with empty array (if you look at my code the second alert() displays 0).
Can you please help me what is wrong with it? Why rego cannot be recognised? Does you plugin send any request to external servers (for example, using Cloud API) to recognise rego or everything is recognised inside plugin? I tried online demo on openalpr.com web side and it recognises my rego correctly.
Thanks in advance for any help.