diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java index 27819ce..b8dd28c 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v4.widget.SwipeRefreshLayout; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -37,6 +38,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene private TextView pres_text; private ImageView weather_img; private RecyclerView recyclerView; + private SwipeRefreshLayout swipeRefreshLayout; private String key = "d6907927a2b9224a0b60d0565c207377"; private String url; @@ -65,6 +67,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene pres_text = rootView.findViewById(R.id.pressure); weather_img = rootView.findViewById(R.id.forecast_img); recyclerView = rootView.findViewById(R.id.anouncements); + swipeRefreshLayout = rootView.findViewById(R.id.simpleSwipeRefreshLayout); HashMap params = new HashMap<>(); 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); request.addListener(this); request.execute(); - + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + swipeRefreshLayout.setRefreshing(false); + refresh(); + } + }); return rootView; } + public void refresh() { + WebRequest request = new WebRequest(url + "/announcements",true,new HashMap(),1); + request.addListener(this); + request.execute(); + } + public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); @@ -151,10 +166,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene @Override public void imageDownloaded(Bitmap img) { weather_img.setImageBitmap(Bitmap.createScaledBitmap(img,100,100,true)); - - WebRequest request = new WebRequest(url + "/announcements",true,new HashMap(),1); - request.addListener(this); - request.execute(); + refresh(); } public interface OnRecyclerViewInteractionListener { diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java index bb3d086..f6813d7 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java @@ -4,6 +4,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -30,6 +31,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi private int mColumnCount = 1; private OnListFragmentInteractionListener mListener; public RecyclerView recyclerView; + public SwipeRefreshLayout swipeRefreshLayout; public String url; public int img_count = 0; public JSONArray votes; @@ -59,7 +61,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_votes_list, container, false); - + // swipeRefreshLayout = view.findViewById(R.id.simpleSwipeRefreshLayout); // Set the adapter if (view instanceof RecyclerView) { Context context = view.getContext(); @@ -75,10 +77,22 @@ public class VotesFragment extends Fragment implements responseListener, imageLi web_manager.addListener(this); web_manager.execute(); } + /* swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + swipeRefreshLayout.setRefreshing(false); + refresh(); + } + }); + */ return view; } - + public void refresh() { + WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap(),0); + web_manager.addListener(this); + web_manager.execute(); + } @Override public void onAttach(Context context) { super.onAttach(context); diff --git a/MyCity/app/src/main/res/layout/fragment_main.xml b/MyCity/app/src/main/res/layout/fragment_main.xml index c55705d..fcf0605 100644 --- a/MyCity/app/src/main/res/layout/fragment_main.xml +++ b/MyCity/app/src/main/res/layout/fragment_main.xml @@ -52,7 +52,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp" android:textColor="#000000" android:layout_marginBottom="15dp" android:layout_marginLeft="7dp"/> - + + + \ No newline at end of file diff --git a/MyCity/app/src/main/res/layout/fragment_votes_list.xml b/MyCity/app/src/main/res/layout/fragment_votes_list.xml index fe5a0d3..bc3c84c 100644 --- a/MyCity/app/src/main/res/layout/fragment_votes_list.xml +++ b/MyCity/app/src/main/res/layout/fragment_votes_list.xml @@ -1,18 +1,23 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/server_side/api/modules/__pycache__/navigation.cpython-37.pyc b/server_side/api/modules/__pycache__/navigation.cpython-37.pyc index a1d2bf3..4ffa002 100644 Binary files a/server_side/api/modules/__pycache__/navigation.cpython-37.pyc and b/server_side/api/modules/__pycache__/navigation.cpython-37.pyc differ diff --git a/server_side/api/modules/__pycache__/smart_park.cpython-37.pyc b/server_side/api/modules/__pycache__/smart_park.cpython-37.pyc index b8d0815..96b65ed 100644 Binary files a/server_side/api/modules/__pycache__/smart_park.cpython-37.pyc and b/server_side/api/modules/__pycache__/smart_park.cpython-37.pyc differ diff --git a/traffic_analyzer/ambulance_detect.py b/traffic_analyzer/ambulance_detect.py index 854ff20..39cdb0d 100644 --- a/traffic_analyzer/ambulance_detect.py +++ b/traffic_analyzer/ambulance_detect.py @@ -19,6 +19,14 @@ from io import BytesIO import psutil 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. sys.path.append("..") import time @@ -29,9 +37,12 @@ if StrictVersion(tf.__version__) < StrictVersion('1.12.0'): # 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_FILE = MODEL_NAME + '.tar.gz' 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] if 'detection_masks' in output_dict: output_dict['detection_masks'] = output_dict['detection_masks'][0] + + return output_dict cut=[-175,-1,-175,-1] cut_send = [0,0,0,0]