Commit c398f80d authored by Jayashanki T.R.C's avatar Jayashanki T.R.C

Merge branch 'master' into 'IT19013206'

Master merge to IT19013206

See merge request !8
parents a0c10949 99bbafcd
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="45">
<item index="0" class="java.lang.String" itemvalue="opencv-python" />
<item index="1" class="java.lang.String" itemvalue="cmake" />
<item index="2" class="java.lang.String" itemvalue="numpy" />
<item index="3" class="java.lang.String" itemvalue="dlib" />
<item index="4" class="java.lang.String" itemvalue="thop" />
<item index="5" class="java.lang.String" itemvalue="scikit-image" />
<item index="6" class="java.lang.String" itemvalue="opencv-contrib-python" />
<item index="7" class="java.lang.String" itemvalue="wincertstore" />
<item index="8" class="java.lang.String" itemvalue="networkx" />
<item index="9" class="java.lang.String" itemvalue="tifffile" />
<item index="10" class="java.lang.String" itemvalue="Flask-Cors" />
<item index="11" class="java.lang.String" itemvalue="PyYAML" />
<item index="12" class="java.lang.String" itemvalue="torch" />
<item index="13" class="java.lang.String" itemvalue="torchvision" />
<item index="14" class="java.lang.String" itemvalue="mysql-connector-python" />
<item index="15" class="java.lang.String" itemvalue="pandas" />
<item index="16" class="java.lang.String" itemvalue="tqdm" />
<item index="17" class="java.lang.String" itemvalue="regex" />
<item index="18" class="java.lang.String" itemvalue="mediapipe" />
<item index="19" class="java.lang.String" itemvalue="seaborn" />
<item index="20" class="java.lang.String" itemvalue="better-profanity" />
<item index="21" class="java.lang.String" itemvalue="colorama" />
<item index="22" class="java.lang.String" itemvalue="PyWavelets" />
<item index="23" class="java.lang.String" itemvalue="imutils" />
<item index="24" class="java.lang.String" itemvalue="pytz" />
<item index="25" class="java.lang.String" itemvalue="torchaudio" />
<item index="26" class="java.lang.String" itemvalue="Flask" />
<item index="27" class="java.lang.String" itemvalue="Pillow" />
<item index="28" class="java.lang.String" itemvalue="flashtext" />
<item index="29" class="java.lang.String" itemvalue="unidecode" />
<item index="30" class="java.lang.String" itemvalue="sklearn" />
<item index="31" class="java.lang.String" itemvalue="nltk" />
<item index="32" class="java.lang.String" itemvalue="beautifulsoup4" />
<item index="33" class="java.lang.String" itemvalue="chardet" />
<item index="34" class="java.lang.String" itemvalue="pdfminer.six" />
<item index="35" class="java.lang.String" itemvalue="six" />
<item index="36" class="java.lang.String" itemvalue="certifi" />
<item index="37" class="java.lang.String" itemvalue="MarkupSafe" />
<item index="38" class="java.lang.String" itemvalue="scipy" />
<item index="39" class="java.lang.String" itemvalue="chumpy" />
<item index="40" class="java.lang.String" itemvalue="matplotlib" />
<item index="41" class="java.lang.String" itemvalue="opendr" />
<item index="42" class="java.lang.String" itemvalue="protobuf" />
<item index="43" class="java.lang.String" itemvalue="grpcio" />
<item index="44" class="java.lang.String" itemvalue="click" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/activity_dashboard.xml" value="0.22826086956521738" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/activity_login.xml" value="0.22826086956521738" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/activity_main.xml" value="0.22826086956521738" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/activity_parking_slots.xml" value="0.22826086956521738" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/activity_register.xml" value="0.2" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/custom_entrance_details.xml" value="0.22826086956521738" />
<entry key="..\:/Users/dilsh/AndroidStudioProjects/VehicleParkingSystem/app/src/main/res/layout/custom_parking_violation.xml" value="0.22826086956521738" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (tf_obj_detect)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>
\ No newline at end of file
......@@ -78,4 +78,6 @@ Vehicle Parking System(2022-235)
Objective:-
Ensure the safety of the vehicle while parked in the vehicle-park using image processing and Machine Learning.
Also display of unsecured status by notification.
\ No newline at end of file
Also display of unsecured status by notification.
test
\ No newline at end of file
from flask import Flask, request
from flask_cors import CORS
import json
import cv2
import base64
import component_1.slot_detector as slot_detector
import component_1.waiting_time_pred as waiting_time_pred
import component_2.parking_violation as parking_violation_obj
import component_3.video_tester as number_plate_detector
import component_3.parking_traffic_pred as parking_traffic_pred
import component_4.human_action_detector as human_action_detector
app = Flask(__name__)
CORS(app)
@app.route('/slot_availability', methods=['GET', 'POST'])
def slot_availability():
slot_list = slot_detector.get_number_of_space()
return_str = '{ '
for i in range(0, 12):
return_str += '"' + str(i) + '" : ' + str(slot_list[i]) + ','
return_str += ' "average_waiting_time" : ' + str(waiting_time_pred.get_waiting_time()) + '}'
print(return_str)
return json.loads(return_str)
@app.route('/parking_violation', methods=['GET', 'POST'])
def parking_violation():
if parking_violation_obj.is_vehicle_parked_correctly():
return_str = ' { "status" : 1 }'
else:
return_str = ' { "status" : 0 }'
return json.loads(return_str)
@app.route('/enternce', methods=['GET', 'POST'])
def enternce():
number_plate = number_plate_detector.get_number_plate()
return_str = '{ "number_plate" : "' + str(number_plate) + '", "type" : "car" }'
return json.loads(return_str)
@app.route('/traffic', methods=['GET', 'POST'])
def traffic():
traffic_data = parking_traffic_pred.get_traffic_next_week()
return_str = '{ "parking_traffic_next_week" : ['
for i in range(len(traffic_data)):
if i == len(traffic_data) - 1:
return_str += str(traffic_data[i])
else:
return_str += str(traffic_data[i]) + ', '
return_str += ']}'
return json.loads(return_str)
@app.route('/threat', methods=['GET', 'POST'])
def threat():
if human_action_detector.get_human_thred_temp():
return_str = '{ "status" : 1 }'
else:
return_str = '{ "status" : 0 }'
return json.loads(return_str)
@app.route('/image', methods=['GET', 'POST'])
def image():
return_str = '{ "base64_image" : "' + str(get_base_64()) + '" }'
return json.loads(return_str)
def get_base_64():
img = cv2.imread('test.jpg')
retval, buffer = cv2.imencode('.jpg', img)
jpg_as_text = base64.b64encode(buffer)
return jpg_as_text
if __name__ == '__main__':
app.run(host="0.0.0.0", port=3000, debug=True)
package com.example.vehicleparkingsystem;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import android.app.AlertDialog;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;
import com.example.vehicleparkingsystem.Models.BaseURL;
import com.example.vehicleparkingsystem.SQLite.Sqlitedb;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Objects;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class Dashboard extends AppCompatActivity {
Button button1;
Button button2;
Button button3;
Button button4;
Button button5;
String type;
String number;
int threatStatus;
int parkingStatus;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
button1 = findViewById(R.id.parking);
button2 =findViewById(R.id.logout);
button3 =findViewById(R.id.entrance);
button4 =findViewById(R.id.violation);
button5 =findViewById(R.id.threat);
new entranceDetection().execute();
new ParkingViolation().execute();
new threatDetection().execute();
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent = new Intent(Dashboard.this,ParkingSlots.class);
Dashboard.this.startActivity(mainIntent);
Dashboard.this.finish();
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent = new Intent(Dashboard.this,Login.class);
Dashboard.this.startActivity(mainIntent);
Dashboard.this.finish();
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new entranceDetection().execute();
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ParkingViolation().execute();
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new threatDetection().execute();
}
});
}
private class entranceDetection extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected void onPostExecute(String s) {
// AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Dashboard.this);
// LayoutInflater inflater = LayoutInflater.from(Dashboard.this);
// View view1 = inflater.inflate(R.layout.custom_entrance_details, null);
// dialogBuilder.setView(view1);
//
// final TextView textView1 = (TextView) view1.findViewById(R.id.num);
// final TextView textView2 = (TextView) view1.findViewById(R.id.ty);
//
// textView1.setText(number);
// textView2.setText(type);
//
// final AlertDialog alertDialog = dialogBuilder.create();
// alertDialog.show();
String message = "vehicle type is "+type+ " and vehicle number "+number+"";
int reqCode = 1;
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
showNotification(Dashboard.this, "Entrance Detection", message, intent, reqCode);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected String doInBackground(String... strings) {
try {
String Url = BaseURL.get_url() + "enternce";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(Url)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
ResponseBody body = response.body();
JSONArray json = new JSONArray(body.string());
System.out.println(json);
for (int i = 0; i < json.length(); i++) {
JSONObject joo = json.getJSONObject(i);
type = joo.getString("type");
number = joo.getString("number_plate");
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
return null;
} finally {
}
}
}
private class threatDetection extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected void onPostExecute(String s) {
if (threatStatus == 1){
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You have a threat. Be careful!!!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String message = "You have a threat. Be careful!!!";
int reqCode = 1;
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
showNotification(Dashboard.this, "Threat Detection", message, intent, reqCode);
}else{
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You have no threats. You are safe!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String message = "You have no threats. You are safe!";
int reqCode = 1;
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
showNotification(Dashboard.this, "Threat Detection", message, intent, reqCode);
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected String doInBackground(String... strings) {
try {
String Url = BaseURL.get_url() + "threat";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(Url)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
ResponseBody body = response.body();
JSONArray json = new JSONArray(body.string());
System.out.println(json);
for (int i = 0; i < json.length(); i++) {
JSONObject joo = json.getJSONObject(i);
threatStatus = joo.getInt("status");
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
return null;
} finally {
}
}
}
private class ParkingViolation extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected void onPostExecute(String s) {
if (parkingStatus == 1){
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You Parked very well!!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String message = "You Parked very well!!";
int reqCode = 1;
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
showNotification(Dashboard.this, "Parking Violation Detection", message, intent, reqCode);
}else{
AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
builder1.setMessage("You are not parked well!!!");
builder1.setCancelable(true);
builder1.setPositiveButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Dashboard.this);
LayoutInflater inflater = LayoutInflater.from(Dashboard.this);
View view1 = inflater.inflate(R.layout.custom_parking_violation, null);
dialogBuilder.setView(view1);
final VideoView videoView = (VideoView) view1.findViewById(R.id.videoView);
MediaController mediaController;
mediaController = new MediaController(Dashboard.this);
mediaController.setAnchorView(videoView);
Uri localUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.parking);
videoView.setVideoURI(localUri);
videoView.setMediaController(mediaController);
videoView.start();
final AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected String doInBackground(String... strings) {
try {
String Url = BaseURL.get_url() + "parking_violation";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(Url)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
ResponseBody body = response.body();
JSONArray json = new JSONArray(body.string());
System.out.println(json);
for (int i = 0; i < json.length(); i++) {
JSONObject joo = json.getJSONObject(i);
parkingStatus = joo.getInt("status");
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
return null;
} finally {
}
}
}
public void showNotification(Context context, String title, String message, Intent intent, int reqCode) {
// SharedPreferenceManager sharedPreferenceManager = SharedPreferenceManager.getInstance(context);
PendingIntent pendingIntent = PendingIntent.getActivity(context, reqCode, intent, PendingIntent.FLAG_ONE_SHOT);
String CHANNEL_ID = "channel_name";// The id of the channel.
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.car)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "Channel Name";// The user-visible name of the channel.
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
notificationManager.createNotificationChannel(mChannel);
}
notificationManager.notify(reqCode, notificationBuilder.build()); // 0 is the request code, it should be unique id
Log.d("showNotification", "showNotification: " + reqCode);
}
}
\ No newline at end of file
package com.example.vehicleparkingsystem;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import com.example.vehicleparkingsystem.Models.BaseURL;
import com.example.vehicleparkingsystem.SQLite.Sqlitedb;
import org.json.JSONArray;
import org.json.JSONException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class ParkingSlots extends AppCompatActivity {
LinearLayout L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12;
Button button;
String l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12;
ArrayList<Map<String, String>> SavedData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parking_slots);
L1 = findViewById(R.id.l1);
L2 = findViewById(R.id.l2);
L3 = findViewById(R.id.l3);
L4 = findViewById(R.id.l4);
L5 = findViewById(R.id.l5);
L6 = findViewById(R.id.l6);
L7 = findViewById(R.id.l7);
L8 = findViewById(R.id.l8);
L9 = findViewById(R.id.l9);
L10 = findViewById(R.id.l10);
L11 = findViewById(R.id.l11);
L12 = findViewById(R.id.l12);
button = findViewById(R.id.availability);
L1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L1","1", L1);
}
});
L2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L2","1", L2);
}
});
L3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L3","1", L3);
}
});
L4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L4","1", L4);
}
});
L5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L5","10", L5);
}
});
L6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L6","1", L6);
}
});
L7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L7","1", L7);
}
});
L8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L8","1", L8);
}
});
L9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L9","1", L9);
}
});
L10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L10","1", L10);
}
});
L11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L11","1", L11);
}
});
L12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirmAlert("L12","1", L12);
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new SlotsIdentify().execute();
}
});
}
private class SlotsIdentify extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// SavedData = Sqlitedb.Search(ParkingSlots.this,"SELECT * FROM ParkingSlots",3);
// System.out.println(SavedData);
//
// if(!SavedData.isEmpty()){
// l1 = SavedData.get(0).get("2");
// l2 = SavedData.get(0).get("2");
// l3 = SavedData.get(0).get("2");
// l4 = SavedData.get(0).get("2");
// l5 = SavedData.get(0).get("2");
// l6 = SavedData.get(0).get("2");
// l7 = SavedData.get(0).get("2");
// l8 = SavedData.get(0).get("2");
// l9 = SavedData.get(0).get("2");
// l10 = SavedData.get(0).get("2");
// l11 = SavedData.get(0).get("2");
// l12 = SavedData.get(0).get("2");
//
//
// if(Objects.equals(l1, "1")){
// L1.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l2, "1")){
// L2.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l3, "1")){
// L3.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l4, "1")){
// L4.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l5, "1")){
// L5.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l6, "1")){
// L6.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l7, "1")){
// L7.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l8, "1")){
// L8.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l9, "1")){
// L9.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l10, "1")){
// L10.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l11, "1")){
// L11.setBackgroundColor(Color.RED);
// }else if(Objects.equals(l12, "1")){
// L12.setBackgroundColor(Color.RED);
// }
// }
}
@Override
protected void onPostExecute(String s) {
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected String doInBackground(String... strings) {
try {
String Url = BaseURL.get_url() + "slot_availability";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(Url)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
ResponseBody body = response.body();
JSONArray json = new JSONArray(body.string());
System.out.println(json);
for (int i = 0; i < json.length(); i++) {
l1 = json.getJSONObject(0).getString("1");
l2 = json.getJSONObject(0).getString("2");
l3 = json.getJSONObject(0).getString("3");
l4 = json.getJSONObject(0).getString("4");
l5 = json.getJSONObject(0).getString("5");
l6 = json.getJSONObject(0).getString("6");
l7 = json.getJSONObject(0).getString("7");
l8 = json.getJSONObject(0).getString("8");
l9 = json.getJSONObject(0).getString("9");
l10 = json.getJSONObject(0).getString("10");
l11 = json.getJSONObject(0).getString("11");
l12 = json.getJSONObject(0).getString("12");
}
if(Objects.equals(l1, "1")){
L1.setBackgroundColor(Color.RED);
}if(Objects.equals(l2, "1")){
L2.setBackgroundColor(Color.RED);
}if(Objects.equals(l3, "1")){
L3.setBackgroundColor(Color.RED);
}if(Objects.equals(l4, "1")){
L4.setBackgroundColor(Color.RED);
}if(Objects.equals(l5, "1")){
L5.setBackgroundColor(Color.RED);
}if(Objects.equals(l6, "1")){
L6.setBackgroundColor(Color.RED);
}if(Objects.equals(l7, "1")){
L7.setBackgroundColor(Color.RED);
}if(Objects.equals(l8, "1")){
L8.setBackgroundColor(Color.RED);
}if(Objects.equals(l9, "1")){
L9.setBackgroundColor(Color.RED);
}if(Objects.equals(l10, "1")){
L10.setBackgroundColor(Color.RED);
}if(Objects.equals(l11, "1")){
L11.setBackgroundColor(Color.RED);
}if(Objects.equals(l12, "1")){
L12.setBackgroundColor(Color.RED);
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
return null;
} finally {
}
}
}
private void confirmAlert(String slot, String status, LinearLayout layout) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(ParkingSlots.this);
builder1.setMessage("Do you want to reserve this parking slot?");
builder1.setCancelable(true);
builder1.setPositiveButton(
"Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Sqlitedb.InsertData(ParkingSlots.this, "ParkingSlots",
"slot,status",
"'" + slot + "','" + status + "'");
layout.setBackgroundColor(Color.RED);
}
});
builder1.setNegativeButton(
"No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
}
}
\ No newline at end of file
package com.example.vehicleparkingsystem;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.vehicleparkingsystem.Models.Users;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class Register extends AppCompatActivity {
EditText editText1;
EditText editText2;
EditText editText3;
EditText editText4;
EditText editText5;
EditText editText6;
Button reg;
TextView textView;
FirebaseDatabase rootNode;
DatabaseReference reference;
FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
editText1=(EditText)findViewById(R.id.Uname);
editText2=(EditText)findViewById(R.id.Remail);
editText3=(EditText)findViewById(R.id.Age);
editText4=(EditText)findViewById(R.id.contct);
editText5=(EditText)findViewById(R.id.password);
editText6=(EditText)findViewById(R.id.vehicle);
reg=(Button)findViewById(R.id.register);
textView=(TextView)findViewById(R.id.gotologin);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Register.this, MainActivity.class);
startActivity(intent);
}
});
firebaseAuth=FirebaseAuth.getInstance();
reg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reference = FirebaseDatabase.getInstance().getReference("User");
// reference = rootNode.getReference("Users");
final String namee = editText1.getText().toString();
final String emaill = editText2.getText().toString();
final String age = editText3.getText().toString();
final String phonee = editText4.getText().toString();
final String pass = editText5.getText().toString();
final String vehicle = editText6.getText().toString();
if (!validateUserName() | !validateEmail() | !validateAge() | !validatePhone() | !validatePassword()) {
Toast.makeText(Register.this, "Sign up failed", Toast.LENGTH_SHORT).show();
}
else{
firebaseAuth.createUserWithEmailAndPassword(emaill, pass)
.addOnCompleteListener(Register.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String userid = user.getUid();
Users members = new Users(namee,emaill,age,phonee,vehicle,pass);
reference.child(userid).setValue(members);
System.out.println(members);
Toast.makeText(Register.this, "Sign up successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Register.this, Dashboard.class);
startActivity(intent);
} else {
Toast.makeText(Register.this, "Sign up failed", Toast.LENGTH_SHORT).show();
}
}
});
}
}
});
}
public boolean validateUserName() {
String value = editText1.getText().toString();
String noWhiteSpace = "\\A\\w{4,20}\\z";
if (value.isEmpty()) {
editText1.setError("Field cannot be empty");
return false;
} else if (value.length() >= 15) {
editText1.setError("Username too long. limit to 15 characters");
return false;
} else if (!value.matches(noWhiteSpace)) {
editText1.setError("White Spaces are not allowed");
return false;
} else {
editText1.setError(null);
return true;
}
}
public boolean validateEmail() {
String value = editText2.getText().toString();
String emailPattern = "[a-zA-Z0-9._-]+@[a-z].+[a-z]+\\.+[a-z]+"; //Regex Expression
if (value.isEmpty()) {
editText2.setError("Field cannot be empty");
return false;
} else if (!value.matches(emailPattern)) {
editText2.setError("Invalid email address");
return false;
} else {
editText2.setError(null);
return true;
}
}
public boolean validateAge() {
String value = editText3.getText().toString();
if (value.isEmpty()) {
editText3.setError("Field cannot be empty");
return false;
} else {
editText3.setError(null);
return true;
}
}
public boolean validatePhone() {
String value = editText4.getText().toString();
if (value.isEmpty()) {
editText4.setError("Field cannot be empty");
return false;
} else {
editText4.setError(null);
return true;
}
}
public boolean validatePassword() {
String value = editText5.getText().toString();
String password = "^" +
//"(?=.*[0-9])" + //at least 1 digit
//"(?=.*[a-z])" + //at least 1 lower case letter
//"(?=.*[A-Z])" + //at least 1 upper case letter
"(?=.*[a-zA-Z])" + //any letter
"(?=.*[@#$%^&+=])" + //at least 1 special character
"(?=\\S+$)" + //no white spaces
".{2,}" + //at least 2 characters
"$";
if (value.isEmpty()) {
editText5.setError("Field cannot be empty");
return false;
} else if (!value.matches(password)) {
editText5.setError("Password must have at least 1 special character, 2 numbers and letters");
return false;
} else {
editText5.setError(null);
return true;
}
}
}
\ No newline at end of file
pip install scikit-learn opencv-python mediapipe torch torchvision torchaudio statsmodels pmdarima
pip install opencv-python==4.5.5.64
save.png

129 KB

test.jpg

141 KB

from flask import Flask, request
from flask_cors import CORS
import json
app = Flask(__name__)
CORS(app)
@app.route('/slot_availability', methods=['GET', 'POST'])
def slot_availability():
return_str = '{ "1" : 0, "2" : 1,"3" : 0,"4" : 1,"5" : 1,"6" : 1,"7" : 0,"8" : 1,"9" : 0,"10" : 0, }'
return json.loads(return_str)
@app.route('/parking_violation', methods=['GET', 'POST'])
def parking_violation():
return_str = ' { "status" : 1" }'
return json.loads(return_str)
@app.route('/enternce', methods=['GET', 'POST'])
def enternce():
return_str = '{ "number_plate" : "KS-9908", "type" : "car" }'
return json.loads(return_str)
@app.route('/threat', methods=['GET', 'POST'])
def threat():
return_str = '{ "status" : 1 }'
return json.loads(return_str)
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000, debug=True)
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment