Closed yaguediop closed 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));
});
@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?
@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!
@yaguediop cool! Could you maybe do a PR with your changes to home.ts?
@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)); }); }
/**
@param text {string} */ showError(text: string) { const alert = this.alertCtrl.create({ title: 'Error', subTitle: text, buttons: ['OK'] });
alert.present(); }
/**
}
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 Thanks!