iMicknl / cordova-plugin-openalpr

This Cordova plugin adds support for the OpenALPR (Automatic License Plate Recognition) library, which provides support for retrieving the license plate from a picture.
MIT License
33 stars 23 forks source link

Error in Success callbackId: OpenALPR1194570412 : TypeError: callback.success.apply is not a function #37

Closed yaguediop closed 5 years ago

yaguediop commented 5 years ago

Hello, thanks for yor good explanation, but after compiled the apk file if i take a picture from camera i get this error Error in Success callbackId: OpenALPR1194570412 : TypeError: callback.success.apply is not a function capture du 2019-01-09 20-47-20 Thanks!

yaguediop commented 5 years ago

Hello i get the solution with using the code

const cameraOptions: CameraOptions = {
    quality: 100,
    destinationType: this.camera.DestinationType.FILE_URI,
    encodingType: this.camera.EncodingType.JPEG,
    mediaType: this.camera.MediaType.PICTURE,
    sourceType: this.camera.PictureSourceType.CAMERA
}

const scanOptions: OpenALPROptions = {
    country: this.openalpr.Country.EU,
    amount: 3
}

this.camera.getPicture(cameraOptions).then((imageData) => {
    this.openALPR.scan(imageData)
        .then((result: [OpenALPRResult]) => console.log(result[0].number))
        .catch((error: Error) => console.error(error));
});
iMicknl commented 5 years ago

@yaguediop great! It looks like this is the example code from the readme for Ionic 3 or did you make any changes? What can we change in the documentation to make this more clear?

yaguediop commented 5 years ago

@iMicknl Thanks to you Mick. I downloaded the project "Ionic 3 Sample project" and I changed the content of the scan method at the home.ts level by the ionic code that you have set at your readme. Thanks!

iMicknl commented 5 years ago

@yaguediop cool! Could you maybe do a PR with your changes to home.ts?

yaguediop commented 5 years ago

@iMicknl Here the content of my new home.ts. You can use it.

import { Component } from '@angular/core'; import { Camera, CameraOptions } from '@ionic-native/camera'; import { OpenALPR, OpenALPROptions, OpenALPRResult } from 'cordova-plugin-openalpr/native'; import { AlertController, ModalController, Platform } from 'ionic-angular'; import { ResultPage } from './../result/result';

@Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage {

private cameraOptions: CameraOptions; public scanOptions: OpenALPROptions;

constructor(private camera: Camera, private openALPR: OpenALPR, private alertCtrl: AlertController, private modalCtrl: ModalController, private platform: Platform) {

this.cameraOptions = {
  quality: 80,
  destinationType: this.camera.DestinationType.DATA_URL,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE
}

this.scanOptions = {
  country: this.openALPR.Country.EU,
  amount: 3
}

}

/**

const scanOptions: OpenALPROptions = { country: this.openALPR.Country.EU, amount: 3 }

this.camera.getPicture(cameraOptions).then((imageData) => { this.openALPR.scan(imageData) .then((result: [OpenALPRResult]) => console.log(result[0].number)) .catch((error: Error) => console.error(error)); }); }

/**

}