Giter VIP home page Giter VIP logo

Comments (5)

yaguediop avatar yaguediop commented on May 23, 2024

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));
});

from cordova-plugin-openalpr.

iMicknl avatar iMicknl commented on May 23, 2024

@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?

from cordova-plugin-openalpr.

yaguediop avatar yaguediop commented on May 23, 2024

@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!

from cordova-plugin-openalpr.

iMicknl avatar iMicknl commented on May 23, 2024

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

from cordova-plugin-openalpr.

yaguediop avatar yaguediop commented on May 23, 2024

@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
}

}

/**

  • Take picture and send it to OpenALPR
  • @param input
    */
    scan(input: string) {
    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));
});
}

/**

  • Show error using a popup
  • @param text {string}
    */
    showError(text: string) {
    const alert = this.alertCtrl.create({
    title: 'Error',
    subTitle: text,
    buttons: ['OK']
    });
alert.present();

}

/**

  • Show result using a popup
  • @param result {OpenALPRResult}
    */
    showResult(result: OpenALPRResult) {
    const modal = this.modalCtrl.create(ResultPage, { licensePlate: result.number });
    modal.present();
    }

}

from cordova-plugin-openalpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.