Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting an error #40

Closed
denizme opened this issue Feb 20, 2017 · 3 comments
Closed

I'm getting an error #40

denizme opened this issue Feb 20, 2017 · 3 comments

Comments

@denizme
Copy link

denizme commented Feb 20, 2017

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
Copy link
Owner

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
Copy link
Author

denizme commented Feb 21, 2017

Hi, @SandroMachado

Thanks. The problem improved.

@Robbypatel1357
Copy link

still i have error can any one help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants