Repository: jasur-2902/CarRecognition Branch: master Commit: d396d20b60f4 Files: 49 Total size: 85.2 KB Directory structure: gitextract_t1gc80l7/ ├── .gitignore ├── .idea/ │ ├── assetWizardSettings.xml │ ├── codeStyles/ │ │ └── Project.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── inspectionProfiles/ │ │ └── Project_Default.xml │ ├── misc.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── google-services.json │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── uz/ │ │ └── shukurov/ │ │ └── carrecognition/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── assets/ │ │ │ └── index.html │ │ ├── java/ │ │ │ └── uz/ │ │ │ └── shukurov/ │ │ │ └── carrecognition/ │ │ │ ├── MainActivity.java │ │ │ ├── ResultActivity.java │ │ │ ├── SplashActivity.java │ │ │ └── other/ │ │ │ ├── InternetCheck.java │ │ │ ├── MyBounceInterpolator.java │ │ │ └── RequestCode.java │ │ └── res/ │ │ ├── anim/ │ │ │ └── bounce.xml │ │ ├── drawable/ │ │ │ ├── camera_button_click.xml │ │ │ ├── gallery_button_click.xml │ │ │ ├── ic_arrow_back.xml │ │ │ └── ic_launcher_background.xml │ │ ├── drawable-v24/ │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout/ │ │ │ ├── activity_main.xml │ │ │ ├── activity_result.xml │ │ │ └── activity_splash.xml │ │ ├── menu/ │ │ │ └── main_menu.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── xml/ │ │ └── file_paths.xml │ └── test/ │ └── java/ │ └── uz/ │ └── shukurov/ │ └── carrecognition/ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.iml .gradle /local.properties /.idea/caches/build_file_checksums.ser /.idea/libraries /.idea/modules.xml /.idea/workspace.xml .DS_Store /build /captures .externalNativeBuild ================================================ FILE: .idea/assetWizardSettings.xml ================================================ ================================================ FILE: .idea/codeStyles/Project.xml ================================================ ================================================ FILE: .idea/encodings.xml ================================================ ================================================ FILE: .idea/gradle.xml ================================================ ================================================ FILE: .idea/inspectionProfiles/Project_Default.xml ================================================ ================================================ FILE: .idea/misc.xml ================================================ ================================================ FILE: .idea/runConfigurations.xml ================================================ ================================================ FILE: .idea/vcs.xml ================================================ ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 Jasur Shukurov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Due to the hight cost and usage, I've stopped the server :`( . This project isn't supported anymore. You can use the android client side tho, but it won't return anything. # CarRecognition - AI Model This is one of the best vehicle recognition applications. It can determine the car's license plate number, color, model, brand, and year. **Author: Jasurbek Shukurov** ## Why? This model runs with the highest accuracy compared to other models existing in the market. ## Features - **License Plate Recognition**: Accurately detects and recognizes license plate numbers from images. - **Vehicle Color Detection**: Identifies the primary color of the vehicle. - **Model and Brand Identification**: Determines the specific model and brand of the vehicle. - **Year Estimation**: Estimates the manufacturing year of the vehicle. ## Installation Clone the repository: ``` bash git clone https://github.com/jasur-2902/Car-Recognition.git cd Car-Recognition ``` ##Usage Upload an image of a vehicle. The application will process the image and display the detected information, including license plate number, vehicle color, model, brand, and estimated year. ##How it Works The CarRecognition app uses a deep learning model trained on a large dataset of vehicle images. It processes the input image, extracts relevant features, and then applies a series of classification algorithms to determine the car's details. ###Contributing If you'd like to contribute to this project, please fork the repository and use a feature branch. Pull requests are warmly welcome. ###License This project is licensed under the MIT License - see the LICENSE file for details. ###Contact For any inquiries or support, please contact jasur.shukurov29@gmail.com. ## Screenshots alt text alt text alt text

alt text alt text

================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ //noinspection GradleCompatible apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "uz.shukurov.carrecognition" minSdkVersion 18 targetSdkVersion 28 versionCode 2 versionName "1.0.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' //Design Elements implementation 'com.android.support:design:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' //Firebase implementation 'com.google.firebase:firebase-storage:16.0.5' implementation 'com.google.firebase:firebase-core:16.0.6' //Json implementation 'com.github.amirdew:JSON:v1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } apply plugin: 'com.google.gms.google-services' ================================================ FILE: app/google-services.json ================================================ { "project_info": { "project_number": "381266161153", "firebase_url": "https://car-recognition-app.firebaseio.com", "project_id": "car-recognition-app", "storage_bucket": "car-recognition-app.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "1:381266161153:android:75e10f795367faff", "android_client_info": { "package_name": "uz.shukurov.carrecognition" } }, "oauth_client": [ { "client_id": "381266161153-659ggmsld17svqnafah5ghn1rjgo1qkp.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "AIzaSyCN_0I1080BaTJso0-j-aXajr2thOhSXws" } ], "services": { "analytics_service": { "status": 1 }, "appinvite_service": { "status": 1, "other_platform_oauth_client": [] }, "ads_service": { "status": 2 } } } ], "configuration_version": "1" } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: app/src/androidTest/java/uz/shukurov/carrecognition/ExampleInstrumentedTest.java ================================================ package uz.shukurov.carrecognition; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see Testing documentation */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("uz.shukurov.carrecognition", appContext.getPackageName()); } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/assets/index.html ================================================ ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/MainActivity.java ================================================ package uz.shukurov.carrecognition; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.Toast; import com.google.android.gms.tasks.Continuation; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.storage.FirebaseStorage; import com.google.firebase.storage.StorageReference; import com.google.firebase.storage.UploadTask; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; import uz.shukurov.carrecognition.other.InternetCheck; import uz.shukurov.carrecognition.other.MyBounceInterpolator; import uz.shukurov.carrecognition.other.RequestCode; public class MainActivity extends AppCompatActivity { private StorageReference mStorageImage; private ImageButton mCapture, mTakePicture; private String downloadUri; private Uri mImageUri = null; private String url = "http://18.217.108.249/cgi-bin/recognize2.py?url="; private static final String TAG = MainActivity.class.getSimpleName(); private AlertDialog mDialog; private AlertDialog.Builder mBuilder; private LinearLayout mLinearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mStorageImage = FirebaseStorage.getInstance().getReference().child("images"); mCapture = findViewById(R.id.mCapture); mTakePicture = findViewById(R.id.mTakePicture); final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce); MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20); myAnim.setInterpolator(interpolator); mCapture.startAnimation(myAnim); mTakePicture.startAnimation(myAnim); mLinearLayout = findViewById(R.id.linearLayout); if (!InternetCheck.isInternetAvailable(this)) { initSnackbar(); mLinearLayout.setVisibility(View.INVISIBLE); } permissionRequest(); mCapture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent galleryIntent = new Intent(); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); galleryIntent.setType("image/*"); startActivityForResult(galleryIntent, RequestCode.GALLERY_REQUEST); } }); mTakePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dispatchTakePictureIntent(); } }); if (!isDeviceSupportCamera()) { Toast.makeText(getApplicationContext(), "Sorry! Your device doesn't support camera", Toast.LENGTH_LONG).show(); // will close the app if the device does't have camera finish(); } } private void initSnackbar() { final Snackbar snackbar = Snackbar.make(mLinearLayout, R.string.no_internet, Snackbar.LENGTH_INDEFINITE).setAction(R.string.retry, new View.OnClickListener() { @Override public void onClick(View view) { if (InternetCheck.isInternetAvailable(view.getContext())) { mLinearLayout.setVisibility(View.VISIBLE); } else initSnackbar(); } }); // snackbar.show(); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menu_item1: return true; case R.id.menu_item2: AlertDialog dialog; final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("About") .setMessage("This is one of the best vehicle recognition applications. It can identify the car's license plate number, color, model, brand and year. The project was created by Jasur Shukurov 2018-2019") .setPositiveButton("Okay!", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); dialog = builder.create(); dialog.show(); return true; case R.id.menu_item3: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://home.adelphi.edu/~ja21947/car/privacy_policy.html")); startActivity(browserIntent); default: return super.onOptionsItemSelected(item); } } private void permissionRequest() { if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Permission is not granted // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed; request the permission ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, RequestCode.MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case RequestCode.MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! Do the // contacts-related task you need to do. } else { // permission denied, boo! Disable the // functionality that depends on this permission. } return; } // other 'case' lines to check for other // permissions this app might request. } } String mCurrentPhotoPath; private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); File image = File.createTempFile( imageFileName, /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ ); // Save a file: path for use with ACTION_VIEW intents mCurrentPhotoPath = image.getAbsolutePath(); return image; } Uri photoURI; private void dispatchTakePictureIntent() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File } // Continue only if the File was successfully created if (photoFile != null) { photoURI = FileProvider.getUriForFile(this, "uz.shukurov.carrecognition.fileprovider", photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(takePictureIntent, RequestCode.REQUEST_TAKE_PHOTO); } } } private boolean isDeviceSupportCamera() { if (getApplicationContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_CAMERA)) { // this device has a camera return true; } else { // no camera on this device return false; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RequestCode.GALLERY_REQUEST && resultCode == RESULT_OK) { mImageUri = data.getData(); uploadImage(); } if (requestCode == RequestCode.REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) { mImageUri = photoURI; uploadImage(); } } //Uploading Image to Firebase private void uploadImage() { if (mImageUri != null) { final StorageReference filepath = mStorageImage.child(mImageUri.getLastPathSegment()); mBuilder = new AlertDialog.Builder(MainActivity.this); mBuilder.setTitle("Loading...") .setMessage("Please wait, it will take some time!") .setCancelable(false); mDialog = mBuilder.create(); mDialog.show(); filepath.putFile(mImageUri).continueWithTask(new Continuation>() { @Override public Task then(@NonNull Task task) throws Exception { if (!task.isSuccessful()) { mDialog.show(); throw task.getException(); } return filepath.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { downloadUri = task.getResult().toString(); String query = downloadUri.substring(87, downloadUri.length()); new DownloadTask().execute(url + query); } else { mDialog.cancel(); Toast.makeText(MainActivity.this, "Upload failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show(); } } }); } else { mDialog.cancel(); Toast.makeText(MainActivity.this, "Sorry, something went wrong!", Toast.LENGTH_SHORT).show(); } } private class DownloadTask extends AsyncTask { @Override protected String doInBackground(String... params) { //do your request in here so that you don't interrupt the UI thread try { return downloadContent(params[0]); } catch (IOException e) { return "Unable to retrieve data. URL may be invalid."; } } @Override protected void onPostExecute(String result) { //Here you are done with the task Intent intent = new Intent(MainActivity.this, ResultActivity.class); String[] extra = new String[2]; extra[0] = result; extra[1] = downloadUri; intent.putExtra("EXTRA_SESSION_ID", extra); mDialog.cancel(); if (result.length() < 600) { final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setMessage("Sorry, we can't identify this car! Please try one more time!") .setTitle("Error, cannot detect!") .setPositiveButton("Okay", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } else startActivity(intent); } } private String downloadContent(String myurl) throws IOException { InputStream is = null; try { URL url = new URL(myurl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(5000 /* milliseconds */); conn.setConnectTimeout(5500 /* milliseconds */); conn.setRequestMethod("GET"); conn.setDoOutput(true); conn.connect(); int response = conn.getResponseCode(); Log.d(TAG, "The response is: " + response); is = conn.getInputStream(); // Convert the InputStream into a string System.out.println("\nSending 'Get' request to URL : " + url + "--" + response); BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream())); String inputLine; StringBuffer response2 = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response2.append(inputLine); } in.close(); System.out.println("Response : -- " + response2.toString()); mDialog.cancel(); return response2.toString(); } finally { if (is != null) { is.close(); } } } } ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/ResultActivity.java ================================================ package uz.shukurov.carrecognition; import android.app.Activity; import android.app.ProgressDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import java.io.InputStream; import eu.amirs.JSON; import uz.shukurov.carrecognition.R; public class ResultActivity extends Activity { private String extra[] = new String[2]; private String result, plate, color, year, body_type, make_model, url_out, type, processingTime; private ImageView mImageView, mImageBodyType, mColorImageView; private TextView mType, mPlate, mColor, mModel, mBodyType, mYear, mProcessingTime; private ProgressDialog mProgressDialog; private JSON json; private int x1, x2, x3, x4, y1, y2, y3, y4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_result); toolbarMethod(); jsonConverting(); givingView(); new DownloadImage().execute(url_out); mPlate.setText(plate); settingDataToElements(); } private void settingDataToElements() { setColor(); mYear.setText(year); setBodyType(); String make_model_upperCase = make_model.substring(0, 1).toUpperCase() + make_model.substring(1); mModel.setText(make_model_upperCase); int separate = type.indexOf("_"); String brand = type.substring(0, separate); String model = type.substring(separate + 1); String car_type = brand.substring(0, 1).toUpperCase() + brand.substring(1) + " " + model.substring(0, 1).toUpperCase() + model.substring(1); mType.setText(car_type); mProcessingTime.setText("Processing Time: " + processingTime); } private void givingView() { mImageView = findViewById(R.id.imageView); mType = findViewById(R.id.mType); mPlate = findViewById(R.id.mPlate); mColor = findViewById(R.id.mColor); mModel = findViewById(R.id.mModel); mYear = findViewById(R.id.mYear); mBodyType = findViewById(R.id.mBodyType); mProcessingTime = findViewById(R.id.processingTime); mImageBodyType = findViewById(R.id.iv_body); mColorImageView = findViewById(R.id.mColorImage); } private void jsonConverting() { extra = getIntent().getStringArrayExtra("EXTRA_SESSION_ID"); result = extra[0]; url_out = extra[1]; json = new JSON(result); getJsonOutput(); } private void toolbarMethod() { Toolbar mToolbar = findViewById(R.id.toolbar); mToolbar.setTitle(R.string.app_name); mToolbar.setNavigationIcon(R.drawable.ic_arrow_back); mToolbar.setTitleTextColor(getResources().getColor(R.color.white)); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); } private void setColor() { String color_upperCase = color.substring(0, 1).toUpperCase() + color.substring(1); mColor.setText(color_upperCase); switch (color) { case ("white"): mColorImageView.setColorFilter(getResources().getColor(R.color.white)); break; case ("black"): mColorImageView.setColorFilter(getResources().getColor(R.color.black)); break; case ("blue"): mColorImageView.setColorFilter(getResources().getColor(R.color.blue)); break; case ("brown"): mColorImageView.setColorFilter(getResources().getColor(R.color.brown)); break; case ("gold-beige"): mColorImageView.setColorFilter(getResources().getColor(R.color.gold_beige)); break; case ("green"): mColorImageView.setColorFilter(getResources().getColor(R.color.green)); break; case ("orange"): mColorImageView.setColorFilter(getResources().getColor(R.color.orange)); break; case ("pink"): mColorImageView.setColorFilter(getResources().getColor(R.color.pink)); break; case ("purple"): mColorImageView.setColorFilter(getResources().getColor(R.color.purple)); break; case ("red"): mColorImageView.setColorFilter(getResources().getColor(R.color.red)); break; case ("silver-gray"): mColorImageView.setColorFilter(getResources().getColor(R.color.silver_gray)); break; case ("yellow"): mColorImageView.setColorFilter(getResources().getColor(R.color.yellow)); break; default: mColorImageView.setVisibility(View.INVISIBLE); } } private void setBodyType() { switch (body_type) { case "antique": mBodyType.setText(getString(R.string.antique)); break; case "missing": mBodyType.setText(getString(R.string.missing)); break; case "motorcycle": mBodyType.setText(getString(R.string.motorcycle)); mImageBodyType.setVisibility(View.INVISIBLE); break; case "sedan-compact": mBodyType.setText(getString(R.string.sedan_compact)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type6)); break; case "sedan-convertible": mBodyType.setText(getString(R.string.sedan_convertible)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type6)); break; case "sedan-sports": mBodyType.setText(getString(R.string.sedan_sports)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type5)); break; case "sedan-standard": mBodyType.setText(getString(R.string.sedan_standard)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type6)); break; case "sedan-wagon": mBodyType.setText(getString(R.string.sedan_wagon)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type1)); break; case "suv-crossover": mBodyType.setText(getString(R.string.suv_crossover)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type7)); break; case "suv-standard": mBodyType.setText(getString(R.string.suv_standard)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type7)); break; case "suv-wagon": mBodyType.setText(getString(R.string.suv_wagon)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type3)); break; case "tractor-trailer": mBodyType.setText(getString(R.string.tractor_trailer)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type4)); break; case "truck-standard": mBodyType.setText(getString(R.string.tractor_standard)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type8)); break; case "van-full": mBodyType.setText(getString(R.string.van_full)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type8)); break; case "van-mini": mBodyType.setText(getString(R.string.van_mini)); mImageBodyType.setImageDrawable(getResources().getDrawable(R.drawable.body_type2)); break; default: mBodyType.setText(body_type); } } private void getJsonOutput() { plate = json.key("results").index(0).key("plate").stringValue(); color = json.key("results").index(0).key("vehicle").key("color").index(0).key("name").stringValue(); make_model = json.key("results").index(0).key("vehicle").key("make").index(0).key("name").stringValue(); body_type = json.key("results").index(0).key("vehicle").key("body_type").index(0).key("name").stringValue(); year = json.key("results").index(0).key("vehicle").key("year").index(0).key("name").stringValue(); type = json.key("results").index(0).key("vehicle").key("make_model").index(0).key("name").stringValue(); processingTime = json.key("processing_time").key("plates").toString(); x1 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(0).key("x").stringValue()); y1 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(0).key("y").stringValue()); x2 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(1).key("x").stringValue()); y2 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(1).key("y").stringValue()); x3 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(2).key("x").stringValue()); y3 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(2).key("y").stringValue()); x4 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(3).key("x").stringValue()); y4 = Integer.valueOf(json.key("results").index(0).key("coordinates").index(3).key("y").stringValue()); } // DownloadImage AsyncTask private class DownloadImage extends AsyncTask { @Override protected void onPreExecute() { super.onPreExecute(); // Create a progressdialog mProgressDialog = new ProgressDialog(ResultActivity.this); // Set progressdialog title mProgressDialog.setTitle("Download Image Tutorial"); // Set progressdialog message mProgressDialog.setMessage("Loading..."); mProgressDialog.setIndeterminate(false); // Show progressdialog mProgressDialog.show(); } @Override protected Bitmap doInBackground(String... URL) { String imageURL = URL[0]; Bitmap bitmap = null; try { // Download Image from URL InputStream input = new java.net.URL(imageURL).openStream(); // Decode Bitmap bitmap = BitmapFactory.decodeStream(input); } catch (Exception e) { e.printStackTrace(); } return bitmap; } @Override protected void onPostExecute(Bitmap decodedByte) { Paint paint = new Paint(); paint.setColor(Color.RED); paint.setStrokeWidth(10); //Drawing line around plate Bitmap tempBitmap = Bitmap.createBitmap(decodedByte.getWidth(), decodedByte.getHeight(), Bitmap.Config.RGB_565); Canvas tempCanvas = new Canvas(tempBitmap); tempCanvas.drawBitmap(decodedByte, 0, 0, null); tempCanvas.drawLine(x1, y1, x2, y2, paint); tempCanvas.drawLine(x1, y1, x4, y4, paint); tempCanvas.drawLine(x3, y3, x4, y4, paint); tempCanvas.drawLine(x3, y3, x2, y2, paint); mImageView.setImageDrawable(new BitmapDrawable(getResources(), tempBitmap)); // Close progressdialog mProgressDialog.dismiss(); } } } ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/SplashActivity.java ================================================ package uz.shukurov.carrecognition; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.webkit.WebView; import android.widget.ImageView; public class SplashActivity extends AppCompatActivity { ImageView mImageAnimation; WebView webView; public boolean isFirstStart; Context mcontext; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); webView = findViewById(R.id.webView); webView.loadUrl("file:///android_asset/index.html"); new Handler().postDelayed(new Runnable() { @Override public void run() { SplashActivity.this.startActivity(new Intent(SplashActivity.this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); SplashActivity.this.finish(); } }, 3000); } } ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/other/InternetCheck.java ================================================ package uz.shukurov.carrecognition.other; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class InternetCheck { public static boolean isInternetAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); } } ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/other/MyBounceInterpolator.java ================================================ package uz.shukurov.carrecognition.other; public class MyBounceInterpolator implements android.view.animation.Interpolator { private double mAmplitude = 1; private double mFrequency = 10; public MyBounceInterpolator(double amplitude, double frequency) { mAmplitude = amplitude; mFrequency = frequency; } public float getInterpolation(float time) { return (float) (-1 * Math.pow(Math.E, -time/ mAmplitude) * Math.cos(mFrequency * time) + 1); } } ================================================ FILE: app/src/main/java/uz/shukurov/carrecognition/other/RequestCode.java ================================================ package uz.shukurov.carrecognition.other; public class RequestCode { public static final int MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE = 999; public static final int REQUEST_TAKE_PHOTO = 998; public static final int GALLERY_REQUEST = 997; } ================================================ FILE: app/src/main/res/anim/bounce.xml ================================================ ================================================ FILE: app/src/main/res/drawable/camera_button_click.xml ================================================ ================================================ FILE: app/src/main/res/drawable/gallery_button_click.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_arrow_back.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_result.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_splash.xml ================================================ ================================================ FILE: app/src/main/res/menu/main_menu.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #4285F4 #4285F4 #4285F4 #fff #000 #00f #654321 #ffd700 #00ff00 #ffa500 #ff69b4 #551a8b #ff0000 #c0c0c0 #ffff00 #c9c9c9 #00dc9e #fff ================================================ FILE: app/src/main/res/values/dimens.xml ================================================ 14sp ================================================ FILE: app/src/main/res/values/strings.xml ================================================ Vehicle Recognition Body type: VAN Mini VAN Full Tractor Standard Tractor Trailer SUV Wagon SUV Standard SUV Crossover Sedan Wagon Sedan Standard Sedan Sports Sedan Convertible Sedan Compact Motorcycle Missing Antique Processed Car Image Ops, we could not find an active internet connection… Retry Project was created by Jasur Shukurov Select from gallery Take a picture Take Picture Button OR Select from gallery button ================================================ FILE: app/src/main/res/values/styles.xml ================================================ ================================================ FILE: app/src/main/res/xml/file_paths.xml ================================================ ================================================ FILE: app/src/test/java/uz/shukurov/carrecognition/ExampleUnitTest.java ================================================ package uz.shukurov.carrecognition; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see Testing documentation */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } } ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.google.gms:google-services:4.2.0' // google-services plugin // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() // Google's Maven repository jcenter() maven { url "https://jitpack.io" } } } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true ================================================ FILE: gradlew ================================================ #!/usr/bin/env sh ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle ================================================ include ':app'