Browse Source

Merge remote-tracking branch 'origin/efe' into yigit

yigit
Yiğit Çolakoğlu 6 years ago
parent
commit
111a205423
7 changed files with 79 additions and 30 deletions
  1. +17
    -5
      MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java
  2. +16
    -2
      MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java
  3. +8
    -3
      MyCity/app/src/main/res/layout/fragment_main.xml
  4. +22
    -17
      MyCity/app/src/main/res/layout/fragment_votes_list.xml
  5. BIN
      server_side/api/modules/__pycache__/navigation.cpython-37.pyc
  6. BIN
      server_side/api/modules/__pycache__/smart_park.cpython-37.pyc
  7. +16
    -3
      traffic_analyzer/ambulance_detect.py

+ 17
- 5
MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java View File

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -37,6 +38,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene
private TextView pres_text; private TextView pres_text;
private ImageView weather_img; private ImageView weather_img;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private SwipeRefreshLayout swipeRefreshLayout;
private String key = "d6907927a2b9224a0b60d0565c207377"; private String key = "d6907927a2b9224a0b60d0565c207377";
private String url; private String url;
@ -65,6 +67,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene
pres_text = rootView.findViewById(R.id.pressure); pres_text = rootView.findViewById(R.id.pressure);
weather_img = rootView.findViewById(R.id.forecast_img); weather_img = rootView.findViewById(R.id.forecast_img);
recyclerView = rootView.findViewById(R.id.anouncements); recyclerView = rootView.findViewById(R.id.anouncements);
swipeRefreshLayout = rootView.findViewById(R.id.simpleSwipeRefreshLayout);
HashMap<String,String> params = new HashMap<>(); HashMap<String,String> params = new HashMap<>();
params.put("q","Ankara,tr"); params.put("q","Ankara,tr");
@ -76,10 +79,22 @@ public class MainFragment extends Fragment implements WebRequest.responseListene
WebRequest request = new WebRequest("https://api.openweathermap.org/data/2.5/weather",true,params,0); WebRequest request = new WebRequest("https://api.openweathermap.org/data/2.5/weather",true,params,0);
request.addListener(this); request.addListener(this);
request.execute(); request.execute();
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeRefreshLayout.setRefreshing(false);
refresh();
}
});
return rootView; return rootView;
} }
public void refresh() {
WebRequest request = new WebRequest(url + "/announcements",true,new HashMap<String, String>(),1);
request.addListener(this);
request.execute();
}
public void onButtonPressed(Uri uri) { public void onButtonPressed(Uri uri) {
if (mListener != null) { if (mListener != null) {
mListener.onFragmentInteraction(uri); mListener.onFragmentInteraction(uri);
@ -151,10 +166,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene
@Override @Override
public void imageDownloaded(Bitmap img) { public void imageDownloaded(Bitmap img) {
weather_img.setImageBitmap(Bitmap.createScaledBitmap(img,100,100,true)); weather_img.setImageBitmap(Bitmap.createScaledBitmap(img,100,100,true));
WebRequest request = new WebRequest(url + "/announcements",true,new HashMap<String, String>(),1);
request.addListener(this);
request.execute();
refresh();
} }
public interface OnRecyclerViewInteractionListener { public interface OnRecyclerViewInteractionListener {


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

@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -30,6 +31,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
private int mColumnCount = 1; private int mColumnCount = 1;
private OnListFragmentInteractionListener mListener; private OnListFragmentInteractionListener mListener;
public RecyclerView recyclerView; public RecyclerView recyclerView;
public SwipeRefreshLayout swipeRefreshLayout;
public String url; public String url;
public int img_count = 0; public int img_count = 0;
public JSONArray votes; public JSONArray votes;
@ -59,7 +61,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_votes_list, container, false); View view = inflater.inflate(R.layout.fragment_votes_list, container, false);
// swipeRefreshLayout = view.findViewById(R.id.simpleSwipeRefreshLayout);
// Set the adapter // Set the adapter
if (view instanceof RecyclerView) { if (view instanceof RecyclerView) {
Context context = view.getContext(); Context context = view.getContext();
@ -75,10 +77,22 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
web_manager.addListener(this); web_manager.addListener(this);
web_manager.execute(); web_manager.execute();
} }
/* swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeRefreshLayout.setRefreshing(false);
refresh();
}
});
*/
return view; return view;
} }
public void refresh() {
WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap<String,String>(),0);
web_manager.addListener(this);
web_manager.execute();
}
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);


+ 8
- 3
MyCity/app/src/main/res/layout/fragment_main.xml View File

@ -52,7 +52,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp" android:layout_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp"
android:textColor="#000000" android:layout_marginBottom="15dp" android:layout_marginLeft="7dp"/> android:textColor="#000000" android:layout_marginBottom="15dp" android:layout_marginLeft="7dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/anouncements" android:layout_marginLeft="14dp"/>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/simpleSwipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/anouncements" android:layout_marginLeft="14dp"/>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout> </LinearLayout>

+ 22
- 17
MyCity/app/src/main/res/layout/fragment_votes_list.xml View File

@ -1,18 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="gq.yigit.mycity.VotesFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="60dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context=".votesFragment.VotesFragment"
tools:listitem="@layout/votes_list_item"
android:divider="@android:color/transparent"
android:dividerHeight="100.0sp"
android:clipChildren="false" android:clipToPadding="false" android:scrollbars="vertical"/>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/simpleSwipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="gq.yigit.mycity.VotesFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="60dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context=".votesFragment.VotesFragment"
tools:listitem="@layout/votes_list_item"
android:divider="@android:color/transparent"
android:dividerHeight="100.0sp"
android:clipChildren="false" android:clipToPadding="false" android:scrollbars="vertical"/>
</android.support.v4.widget.SwipeRefreshLayout>

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


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


+ 16
- 3
traffic_analyzer/ambulance_detect.py View File

@ -19,6 +19,14 @@ from io import BytesIO
import psutil import psutil
switch = 1 switch = 1
import io
import socket
import struct
import time
import pickle
import zlib
# This is needed since the notebook is stored in the object_detection folder. # This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..") sys.path.append("..")
import time import time
@ -29,9 +37,12 @@ if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
# What model to download. # What model to download.
#MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_17' #not even worth trying
MODEL_NAME="ssd_inception_v2_coco_11_06_2017" # not bad and fast
MODEL_NAME="rfcn_resnet101_coco_11_06_2017" # WORKS BEST BUT takes 4 times longer per image
encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90]
MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_17' #not even worth trying
#MODEL_NAME="ssd_inception_v2_coco_11_06_2017" # not bad and fast
#MODEL_NAME="rfcn_resnet101_coco_11_06_2017" # WORKS BEST BUT takes 4 times longer per image
#MODEL_NAME = "faster_rcnn_resnet101_coco_11_06_2017" # too slow #MODEL_NAME = "faster_rcnn_resnet101_coco_11_06_2017" # too slow
MODEL_FILE = MODEL_NAME + '.tar.gz' MODEL_FILE = MODEL_NAME + '.tar.gz'
DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/' DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/'
@ -123,6 +134,8 @@ def run_inference_for_single_image(image, graph):
output_dict['detection_scores'] = output_dict['detection_scores'][0] output_dict['detection_scores'] = output_dict['detection_scores'][0]
if 'detection_masks' in output_dict: if 'detection_masks' in output_dict:
output_dict['detection_masks'] = output_dict['detection_masks'][0] output_dict['detection_masks'] = output_dict['detection_masks'][0]
return output_dict return output_dict
cut=[-175,-1,-175,-1] cut=[-175,-1,-175,-1]
cut_send = [0,0,0,0] cut_send = [0,0,0,0]


Loading…
Cancel
Save