Closed denizme closed 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 :
gradle:app:
assets:
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 :
Where is the problem? Thanks.
Hi @mehmetdniz,
you need to change to your package name in the openaplr.conf.
openaplr.conf
Did it fixed the issue?
Hi, @SandroMachado
Thanks. The problem improved.
still i have error can any one help me?
Hi, I get an error when I include the project.
Log output: D/OPEN ALPR: {"error":true,"msg":"Error initializing Open Alpr"}
gradle :
gradle:app:![screenshot 85](https://cloud.githubusercontent.com/assets/5129736/23126281/9f48708a-f77e-11e6-8ac4-ed316b50d02e.png)
assets:![screenshot 87](https://cloud.githubusercontent.com/assets/5129736/23126297/b329bd20-f77e-11e6-8460-2f747746d178.png)
MainActivity:
Error :
Where is the problem? Thanks.