Browse Source

changes

yigit
Yiğit Çolakoğlu 6 years ago
parent
commit
62f7746d4e
7 changed files with 103 additions and 40 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. +40
    -13
      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.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<String,String> 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<String, String>(),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<String, String>(),1);
request.addListener(this);
request.execute();
refresh();
}
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.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<String,String>(),0);
web_manager.addListener(this);
web_manager.execute();
}
@Override
public void onAttach(Context 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_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp"
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>

+ 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"?>
<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


+ 40
- 13
traffic_analyzer/ambulance_detect.py View File

@ -2,21 +2,23 @@
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import cv2
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from utils import label_map_util
from utils import visualization_utils as vis_util
from PIL import Image
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
@ -27,9 +29,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/'
@ -111,10 +116,13 @@ 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=[-225,-1,-225,-1]
a = 1
cam = cv2.VideoCapture(0)
cam = cv2.VideoCapture(1)
conn_switch = False
with detection_graph.as_default():
sess = tf.Session()
switch = 0
@ -141,9 +149,28 @@ while 1:
category_index,
instance_masks=output_dict.get('detection_masks'),
use_normalized_coordinates=True,
line_thickness=8)
line_thickness=8,
min_score_thresh=0.4)
image[cut[0]:cut[1],cut[2]:cut[3]] = image_np
cv2.imshow("Cam",np.concatenate((image,image_np),axis=0))
result, frame = cv2.imencode('.jpg', image, encode_param)
data = pickle.dumps(frame, 0)
size = len(data)
if(conn_switch):
pass
else:
try:
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('10.10.26.115', 8488))
connection = client_socket.makefile('wb')
conn_switch = True
except:
pass
try:
client_socket.sendall(struct.pack(">L", size) + data)
except:
conn_switch = False
cv2.imshow("Cam",image)
cv2.imshow("Cut",image_np)
t2 = time.time()
print("time taken for {}".format(t2-t1))


Loading…
Cancel
Save