SandroMachado / openalpr-android

Android Automatic License Plate Recognition library (http://www.openalpr.com) ported for android.
Apache License 2.0
770 stars 272 forks source link

I'm getting an error #40

Closed denizme closed 7 years ago

denizme commented 7 years ago

Hi, I get an error when I include the project.

Log output: D/OPEN ALPR: {"error":true,"msg":"Error initializing Open Alpr"}

gradle :

screenshot 83

gradle:app: screenshot 85

assets: screenshot 87

MainActivity:

import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

import org.openalpr.OpenALPR;
import org.openalpr.model.Results;
import org.openalpr.model.ResultsError;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    private String ANDROID_DATA_DIR;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Uri path = Uri.parse("android.resource://com.nikhil.material/" + R.drawable.car);

        ANDROID_DATA_DIR = this.getApplicationInfo().dataDir;
        final String openAlprConfFile = ANDROID_DATA_DIR + File.separatorChar + "runtime_data" + File.separatorChar + "openalpr.conf";
        AsyncTask.execute(new Runnable() {
            @Override
            public void run() {
                String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("eu", "", path.toString(), openAlprConfFile, 10);
                Log.d("OPEN ALPR", result);

                try {
                    final Results results = new Gson().fromJson(result, Results.class);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (results == null || results.getResults() == null || results.getResults().size() == 0) {
                                Toast.makeText(MainActivity.this, "It was not possible to detect the licence plate.", Toast.LENGTH_LONG).show();
                                Log.d("Error", "It was not possible to detect the licence plate.");
                            } else {
                                Log.d("Plate: ", results.getResults().get(0).getPlate());
                            }
                        }
                    });

                } catch (JsonSyntaxException exception) {
                    final ResultsError resultsError = new Gson().fromJson(result, ResultsError.class);

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Log.d("Error :", resultsError.getMsg());
                        }
                    });
                }

            }
        });

    }
}

Error :

screenshot 88

Where is the problem? Thanks.

SandroMachado commented 7 years ago

Hi @mehmetdniz,

you need to change to your package name in the openaplr.conf.

b329bd20-f77e-11e6-8460-2f747746d178

Did it fixed the issue?

denizme commented 7 years ago

Hi, @SandroMachado

Thanks. The problem improved.

Robbypatel1357 commented 7 years ago

still i have error can any one help me?