Browse Source

Auto stash before merge of "yigit" and "origin/efe"

old
Yiğit Çolakoğlu 6 years ago
parent
commit
6c72b3cbbb
34 changed files with 99627 additions and 1130022 deletions
  1. +17
    -4
      MyCity/app/build.gradle
  2. +11
    -2
      MyCity/app/src/main/AndroidManifest.xml
  3. +6
    -2
      MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java
  4. +233
    -0
      MyCity/app/src/main/java/gq/yigit/mycity/ParkFragment.java
  5. +0
    -67
      MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java
  6. +3
    -1
      MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java
  7. +0
    -29
      MyCity/app/src/main/res/layout/activity_take_photo.xml
  8. +53
    -0
      MyCity/app/src/main/res/layout/fragment_park.xml
  9. +1
    -1
      MyCity/app/src/main/res/values/strings.xml
  10. +1
    -0
      MyCity/gradle.properties
  11. +1
    -1
      bus_stop/bus_stop.iml
  12. +3
    -1
      server_side/api/app.py
  13. +3
    -1
      server_side/api/modules/SpotSelector.py
  14. BIN
      server_side/api/modules/__pycache__/denunciation.cpython-37.pyc
  15. BIN
      server_side/api/modules/__pycache__/smart_park.cpython-37.pyc
  16. BIN
      server_side/api/modules/__pycache__/user_info.cpython-37.pyc
  17. +3451
    -86
      server_side/api/modules/databases/bus.json
  18. +18
    -12
      server_side/api/modules/databases/locations.json
  19. +95647
    -1129515
      server_side/api/modules/databases/park_data.json
  20. +126
    -122
      server_side/api/modules/databases/users.json
  21. +0
    -119
      server_side/api/modules/detectSpot.py
  22. BIN
      server_side/api/modules/lot.jpg
  23. BIN
      server_side/api/modules/parking_images/1.jpg
  24. BIN
      server_side/api/modules/parking_images/2.jpg
  25. BIN
      server_side/api/modules/parking_images/3.jpg
  26. BIN
      server_side/api/modules/parking_images/4.jpg
  27. BIN
      server_side/api/modules/parking_images/5.jpg
  28. BIN
      server_side/api/modules/parking_images/6.jpg
  29. BIN
      server_side/api/modules/parking_images/7.jpg
  30. BIN
      server_side/api/modules/parking_images/8.jpg
  31. BIN
      server_side/api/modules/parking_images/main.jpg
  32. +52
    -30
      server_side/api/modules/smart_park.py
  33. +0
    -28
      server_side/api/modules/smart_parking.py
  34. +1
    -1
      server_side/api/modules/user_info.py

+ 17
- 4
MyCity/app/build.gradle View File

@ -11,20 +11,29 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
api 'cz.msebera.android:httpclient:4.4.1.2'
implementation 'com.github.chathuralakmal:AndroidImagePopup:1.2.1'
implementation ('com.github.chathuralakmal:AndroidImagePopup:1.2.1',{
exclude module: "com.github.bumptech.glide"
})
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.android.support:design:27.1.1'
@ -36,5 +45,9 @@ dependencies {
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'
implementation 'com.google.android.libraries.places:places:1.1.0'
}
implementation ('com.google.android.libraries.places:places:1.1.0',{
exclude group: "com.github.bumptech.glide"
})
implementation 'com.google.android.gms:play-services-maps:16.1.0'
}

+ 11
- 2
MyCity/app/src/main/AndroidManifest.xml View File

@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gq.yigit.mycity">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.CAMERA" />
@ -16,8 +20,13 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".TakePhoto">
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"


+ 6
- 2
MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java View File

@ -28,6 +28,7 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import gq.yigit.mycity.navigation.TransitFragment;
import gq.yigit.mycity.tools.*;
import gq.yigit.mycity.tools.WebRequest.responseListener;
@ -54,6 +55,7 @@ public class MainActivity extends AppCompatActivity
TransitFragment.OnFragmentInteractionListener,
QRFragment.OnFragmentInteractionListener,
OnFragmentInteractionListener,
ParkFragment.OnFragmentInteractionListener,
responseListener,
imageListener {
@ -75,7 +77,6 @@ public class MainActivity extends AppCompatActivity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
cntxt = getApplicationContext();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
@ -172,7 +173,10 @@ public class MainActivity extends AppCompatActivity
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
} else if (id == R.id.parking) {
ParkFragment fragment = new ParkFragment();
fragmentTransaction.replace(R.id.app_bar_main, fragment);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
} else if (id == R.id.transit) {
TransitFragment fragment = new TransitFragment();
fragmentTransaction.replace(R.id.app_bar_main, fragment);


+ 233
- 0
MyCity/app/src/main/java/gq/yigit/mycity/ParkFragment.java View File

@ -0,0 +1,233 @@
package gq.yigit.mycity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.LocationListener;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.RectangularBounds;
import com.google.android.libraries.places.api.net.PlacesClient;
import com.google.android.libraries.places.widget.Autocomplete;
import com.google.android.libraries.places.widget.AutocompleteActivity;
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
import gq.yigit.mycity.tools.FileActions;
import gq.yigit.mycity.tools.WebRequest;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import static gq.yigit.mycity.MainActivity.apikey;
import static gq.yigit.mycity.MainActivity.cntxt;
public class ParkFragment extends Fragment implements WebRequest.responseListener, OnMapReadyCallback {
private OnFragmentInteractionListener mListener;
private ImageView spot_img;
private TextView place_name;
private String url;
private String latitude;
private String longitude;
private double lat_orig;
private double lng_orig;
private GoogleMap map;
MapView mapFragment;
public ParkFragment() {
// Required empty public constructor
}
public static ParkFragment newInstance(String param1, String param2) {
ParkFragment fragment = new ParkFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_park, container, false);
mapFragment = rootView.findViewById(R.id.spot_loc);
mapFragment.onCreate(savedInstanceState);
spot_img = rootView.findViewById(R.id.spot_img);
LinearLayout search_button = rootView.findViewById(R.id.search_layout_park);
mapFragment.getMapAsync(this);
search_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Places.initialize(getContext(), apikey);
int AUTOCOMPLETE_REQUEST_CODE = 1;
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME,Place.Field.LAT_LNG);
Intent intent = new Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields).
setLocationRestriction(RectangularBounds.newInstance(new LatLng(39.7281252,32.4848006),new LatLng(40.061707,32.9889204)))
.build(getContext());
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
}
});
place_name = rootView.findViewById(R.id.place_name_park);
try {
lat_orig = 39.9127897;
lng_orig = 32.8073577;
}catch (SecurityException e){
Log.e("[ERROR]","An error occured with location permissions");
}
return rootView;
}
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
Place place = Autocomplete.getPlaceFromIntent(data);
place_name.setText(place.getName());
FileActions file_manager = new FileActions();
url = file_manager.readFromFile(cntxt,"server.config").trim();
WebRequest request = new WebRequest(url + "/parking",true, new HashMap<String, String>(),0);
request.addListener(this);
request.execute();
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
Status status = Autocomplete.getStatusFromIntent(data);
Log.i("[INFO]", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
}
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
@Override
public void receivedResponse(boolean success, String data, int code){
if(success){
try{
JSONObject spot = new JSONObject(data);
byte[] decodedString = Base64.decode(spot.getString("img"), Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
spot_img.setImageBitmap(decodedByte);
latitude = spot.getString("lat");
longitude = spot.getString("lng");
LatLng spot_loc = new LatLng(Integer.parseInt(latitude), Integer.parseInt(longitude));
map.addMarker(new MarkerOptions().position(spot_loc).title("Parking Spot"));
LatLng loc = new LatLng(lat_orig, lng_orig);
map.addMarker(new MarkerOptions().position(loc).title("Location"));
map.moveCamera(CameraUpdateFactory.newLatLng(loc));
}catch(JSONException e){
Log.e("[ERROR]","Error parsing json from parking service");
}
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
}
@Override
public void onResume() {
super.onResume();
mapFragment.onResume();
}
@Override
public void onPause() {
super.onPause();
mapFragment.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mapFragment.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapFragment.onLowMemory();
}
}

+ 0
- 67
MyCity/app/src/main/java/gq/yigit/mycity/TakePhoto.java View File

@ -1,67 +0,0 @@
package gq.yigit.mycity;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class TakePhoto extends AppCompatActivity {
private Button takePictureButton;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_take_photo);
takePictureButton = (Button) findViewById(R.id.button_image);
imageView = (ImageView) findViewById(R.id.imageview);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
takePictureButton.setEnabled(false);
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 0) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) {
takePictureButton.setEnabled(true);
}
}
}
public void takePicture(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 100);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 100) {
Log.d("[BOOKMARK]","Actvitity resulted");
if (resultCode == RESULT_OK) {
if (data == null) {
Log.d("[BOOKMARK]","Received image");
// TODO Do something with the full image stored
// in outputFileUri. Perhaps copying it to the app folder
}
}
}
}
}

+ 3
- 1
MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java View File

@ -17,6 +17,8 @@ import gq.yigit.mycity.tools.ImageDownload.imageListener;
import gq.yigit.mycity.votesFragment.VotesContent.VoteItem;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import static gq.yigit.mycity.tools.WebRequest.*;
@ -99,7 +101,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
}
public void receivedResponse(boolean success, String response,int id){
VotesContent.ITEMS.clear();
if(success) {
try {
votes = new JSONArray(response);


+ 0
- 29
MyCity/app/src/main/res/layout/activity_take_photo.xml View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TakePhoto">
<ImageView
android:id="@+id/imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/button_image"/>
<Button
android:id="@+id/button_image"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="takePicture"
android:text="Take a picture!"/>
</RelativeLayout>

+ 53
- 0
MyCity/app/src/main/res/layout/fragment_park.xml View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ParkFragment" android:layout_marginTop="45dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/search_layout_park"
android:background="@drawable/search_shape"
android:layout_marginHorizontal="10dp"
android:paddingHorizontal="5dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginTop="30dp" app:layout_constraintTop_toTopOf="parent"
>
<ImageView
android:layout_width="70dp"
android:layout_height="40dp" android:id="@+id/rate_item_img_park"
android:layout_weight="1"
android:layout_marginRight="5dp" app:srcCompat="@drawable/magnifier"
android:layout_marginVertical="5dp"
android:layout_marginLeft="10dp"/>
<TextView
android:text="Please select a place"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/place_name_park" android:layout_weight="1"
android:gravity="center_vertical" android:textColor="#FF616161" android:textSize="16sp"
android:layout_marginLeft="7dp"/>
</LinearLayout>
<ImageView
android:src="@drawable/app_icon"
android:layout_width="329dp"
android:layout_height="242dp" android:id="@+id/spot_img"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/search_layout_park"
app:layout_constraintStart_toStartOf="@+id/search_layout_park"
app:layout_constraintEnd_toEndOf="@+id/search_layout_park" android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.568"/>
<com.google.android.gms.maps.MapView
android:layout_width="332dp"
android:layout_height="205dp"
android:id="@+id/spot_loc" android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/spot_img" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:apiKey="AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk" app:layout_constraintHorizontal_bias="0.476"
app:layout_constraintVertical_bias="0.274"/>
</android.support.constraint.ConstraintLayout>

+ 1
- 1
MyCity/app/src/main/res/values/strings.xml View File

@ -9,7 +9,7 @@
<string name="transport">Transport</string>
<string name="foryou">For you</string>
<string name="mystore_password">yigit007</string>
<string name="google_maps_key">AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>


+ 1
- 0
MyCity/gradle.properties View File

@ -7,6 +7,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
GOOGLE_MAPS_API_KEY=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk
# 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


+ 1
- 1
bus_stop/bus_stop.iml View File

@ -3,7 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="10.0.2+13" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 3
- 1
server_side/api/app.py View File

@ -1,7 +1,7 @@
from flask import Flask, send_from_directory
from flask_restful import Api
from api.modules import user_info, voting_system, rating_system, utility, denunciation, navigation, bus_stops, announcements
from api.modules import user_info, voting_system, rating_system, utility, denunciation, navigation, bus_stops, announcements, smart_park
app = Flask(__name__)
api = Api(app)
@ -37,4 +37,6 @@ if __name__ == '__main__':
api.add_resource(announcements.Announcement, '/announcements', '/announcements/')
api.add_resource(smart_park.Empty, '/parking', '/parking/')
app.run(host='0.0.0.0', port=5000, ssl_context=context)

+ 3
- 1
server_side/api/modules/SpotSelector.py View File

@ -3,7 +3,9 @@ import cv2
import json
rects = []
im = cv2.imread("parking_images/main.jpg")
cam = cv2.VideoCapture("http://10.10.26.128:4747/mjpegfeed")
ret,im = cam.read()
if __name__ == '__main__' :


BIN
server_side/api/modules/__pycache__/denunciation.cpython-37.pyc View File


BIN
server_side/api/modules/__pycache__/smart_park.cpython-37.pyc View File


BIN
server_side/api/modules/__pycache__/user_info.cpython-37.pyc View File


+ 3451
- 86
server_side/api/modules/databases/bus.json
File diff suppressed because it is too large
View File


+ 18
- 12
server_side/api/modules/databases/locations.json View File

@ -1,23 +1,29 @@
{
"0": {
"x1": 462,
"y1": 146,
"x2": 686,
"y2": 502,
"x1": 212,
"y1": 342,
"x2": 378,
"y2": 426,
"lng": 33,
"lat": 34,
"priority": 0
},
"1": {
"x1": 480,
"y1": 504,
"x2": 684,
"y2": 870,
"x1": 388,
"y1": 344,
"x2": 516,
"y2": 416,
"lng": 33,
"lat": 34,
"priority": 1
},
"2": {
"x1": 484,
"y1": 918,
"x2": 686,
"y2": 1338,
"x1": 90,
"y1": 338,
"x2": 208,
"y2": 420,
"lng": 33,
"lat": 34,
"priority": 2
}
}

+ 95647
- 1129515
server_side/api/modules/databases/park_data.json
File diff suppressed because it is too large
View File


+ 126
- 122
server_side/api/modules/databases/users.json View File

@ -1,123 +1,127 @@
{
"efe": {
"id": "9vard12ty0ad2yvwp3q53rsf3h43r2vq",
"realname": "Efe Aydın",
"avatar": "/img/9vard12ty0ad2yvwp3q53rsf3h43r2vq.png",
"password": "827ccb0eea8a706c4c34a16891f84e7b",
"email": "efeaydin@mycity.com",
"TC": "11111111111",
"tel": "0555 555 55 55",
"health": ["antibiotic allergy", "peanut allergy", "asthma"],
"stats": {
"bus_usage_week": 1,
"bus_usage_month": 5,
"bus_usage_year": 67
},
"trustability": "16",
"daily_electricity_usage": [
32,
34,
29,
28,
35,
31,
36,
38,
37,
40,
45,
47,
45,
47,
48,
44,
49,
53,
55,
49,
46,
42,
37,
34
],
"daily_water_usage": [
32,
34,
29,
28,
35,
31,
36,
38,
37,
40,
45,
47,
45,
47,
48,
44,
49,
53,
55,
49,
46,
42,
37,
34
],
"ideal_electricity_usage": [
11,
11,
11,
11,
11,
12,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
16,
16,
15,
15,
14,
12
],
"ideal_water_usage": [
11,
11,
11,
11,
11,
12,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
16,
16,
15,
15,
14,
12
],
"points": 50,
"electricity_bill": 100,
"water_bill": 120
}
}
"efe": {
"id": "9vard12ty0ad2yvwp3q53rsf3h43r2vq",
"realname": "Efe Ayd\u0131n",
"avatar": "/img/9vard12ty0ad2yvwp3q53rsf3h43r2vq.png",
"password": "827ccb0eea8a706c4c34a16891f84e7b",
"email": "efeaydin@mycity.com",
"TC": "11111111111",
"tel": "0555 555 55 55",
"health": [
"antibiotic allergy",
"peanut allergy",
"asthma"
],
"stats": {
"bus_usage_week": 1,
"bus_usage_month": 5,
"bus_usage_year": 67
},
"trustability": "16",
"daily_electricity_usage": [
32,
34,
29,
28,
35,
31,
36,
38,
37,
40,
45,
47,
45,
47,
48,
44,
49,
53,
55,
49,
46,
42,
37,
34
],
"daily_water_usage": [
32,
34,
29,
28,
35,
31,
36,
38,
37,
40,
45,
47,
45,
47,
48,
44,
49,
53,
55,
49,
46,
42,
37,
34
],
"ideal_electricity_usage": [
11,
11,
11,
11,
11,
12,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
16,
16,
15,
15,
14,
12
],
"ideal_water_usage": [
11,
11,
11,
11,
11,
12,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
16,
16,
15,
15,
14,
12
],
"points": 45,
"electricity_bill": 100,
"water_bill": 120
}
}

+ 0
- 119
server_side/api/modules/detectSpot.py View File

@ -1,119 +0,0 @@
import cv2
import numpy as np
import json
from matplotlib import pyplot as plt
import cv2
import numpy as np
import json
import os
from matplotlib import pyplot as plt
import xml.etree.ElementTree as ET
import cv2
import numpy as np
import os
import json
from pysolar.solar import *
from datetime import datetime
def calcAvg(img,locations_xml):
locations_extracted = []
loc_images = {}
average_values = {}
for i in range( len( locations_xml ) ):
try:
locations_extracted.append([])
for j in range(4):
locations_extracted[i].append(locations_xml[i][1][j].attrib)
locations_extracted[i].append(locations_xml[i].attrib['occupied'])
locations_extracted[i].append(locations_xml[i].attrib['id'])
except Exception:
print("xml corrupt!")
return {}
for col in range(len(img)):
for pix in range(len(img[col])):
if (img[col][pix] == [255,255,255]).all():
img[col][pix] == [255,255,254]
for i in range(len(locations_extracted)):
temp = locations_extracted[i]
pts = np.array([[int(temp[0]['x']),int(temp[0]['y'])],
[int(temp[1]['x']),int(temp[1]['y'])],
[int(temp[2]['x']),int(temp[2]['y'])],
[int(temp[3]['x']),int(temp[3]['y'])]])
rect = cv2.boundingRect(pts)
x,y,w,h = rect
croped = img[y:y+h, x:x+w].copy()
pts = pts - pts.min(axis=0)
mask = np.zeros(croped.shape[:2], np.uint8)
cv2.drawContours(mask, [pts], -1, (255, 255, 255), -1, cv2.LINE_AA)
dst = cv2.bitwise_and(croped, croped, mask=mask)
bg = np.ones_like(croped, np.uint8)*255
cv2.bitwise_not(bg,bg, mask=mask)
dst2 = bg+ dst
blurred = cv2.GaussianBlur(dst2,(5,5),3)
edges = cv2.Canny(blurred,100,100)
if not temp[4] in loc_images:
loc_images[temp[4]] = {}
loc_images[temp[4]][temp[5]] = edges
for state in loc_images:
average_values[state] = {}
for lot in loc_images[state]:
reps = 0
for col in loc_images[state][lot]:
for pix in col:
if(pix == 255):
reps += 1
average_values[state][lot] = reps
print (average_values)
return average_values
def generateAvg():
dates = os.listdir('./PKLot/PKLot/PUCPR/Sunny')
imgs = []
averages={}
back_file = open("backup.json","w")
back_file.write("{")
for i in range(len(dates)):
imgs.append(os.listdir(os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i])))
for i in range(len(imgs)):
for j in range(len(imgs[i])):
if(imgs[i][j][-4:] == ".jpg"):
try:
img_location = os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i],imgs[i][j])
locs = ET.parse(img_location[:-4] + ".xml").getroot()
print(img_location,end=" ")
average = calcAvg(cv2.imread(img_location),locs)
if not(average == {}):
averages[img_location] = average
back_file.write("'"+img_location + "':" + str(average))
except Exception:
continue
back_file.write("}")
js = json.dumps(averages)
print(js)
fp = open('data.json', 'w')
fp.write(js)
fp.close()
generateAvg()

BIN
server_side/api/modules/lot.jpg View File

Before After
Width: 640  |  Height: 480  |  Size: 40 KiB

BIN
server_side/api/modules/parking_images/1.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 248 KiB

BIN
server_side/api/modules/parking_images/2.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 242 KiB

BIN
server_side/api/modules/parking_images/3.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 225 KiB

BIN
server_side/api/modules/parking_images/4.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 225 KiB

BIN
server_side/api/modules/parking_images/5.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 253 KiB

BIN
server_side/api/modules/parking_images/6.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 236 KiB

BIN
server_side/api/modules/parking_images/7.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 302 KiB

BIN
server_side/api/modules/parking_images/8.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 276 KiB

BIN
server_side/api/modules/parking_images/main.jpg View File

Before After
Width: 1440  |  Height: 1080  |  Size: 248 KiB

server_side/api/modules/detectSpots.py → server_side/api/modules/smart_park.py View File


+ 0
- 28
server_side/api/modules/smart_parking.py View File

@ -1,28 +0,0 @@
import os
import copy
import json
from flask import Flask, request
from flask_restful import Resource, Api, abort
app = Flask(__name__)
api = Api(app)
class Empty(Resource):
def get(self):
try:
rating = copy.deepcopy(ratings[rating_id - 1])
del rating['rates']
return rating
except:
abort(404, error="Rating {} doesn't exist".format(rating_id))

+ 1
- 1
server_side/api/modules/user_info.py View File

@ -94,7 +94,7 @@ class ReducePoints(Resource):
if user_id == v['id']:
username = k
users[username]['points'] -= request.form['reduce']
users[username]['points'] -= int(request.form['reduce'])
with open(db_path, 'w') as f:
json.dump(users, f, indent=4)
else:


Loading…
Cancel
Save