3

I have created a python program which can detect the number of cars in a parking area(small scale MVP model)from a camera feed.I now need to create an Android application that shows the 'count' of the cars.The App continuously refresh by itself showing the latest 'count' value.

The python program will run on my pc while the connection to the Cell phone is done via a usb or a WiFI hotspot .No online hosting is done.

B.T.W I'm fairly new to developing Android application and I'm doing this as my final year project in college.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Johith Iype
  • 91
  • 1
  • 2
  • 5
  • see this https://stackoverflow.com/questions/4779963/how-can-i-access-my-localhost-from-my-android-device/15864222#15864222 – Gorgan Razvan Sep 02 '18 at 14:46

1 Answers1

0

I think you are missing some key concepts, you are doing online hosting even if its only available on a local intranet.

to accomplish this task you need to expose your program to the internet, flask makes this really really easy

my_python_server.py

from my_prog import count_cars_opencv
import flask
app = flask.Flask(__name__)

@app.route("/count_cars")
def do_count_some_cars():
    return "There are %d cars"%count_cars_opencv()

app.run(host="0.0.0.0",debug=True)

then the easiest is probably to use something like ionic to build a simple webpage that has an ajax call to your "server" and updates a div

something like

my_ionic.js

$("#my_info_div").load("http://192.168.1.133:5000/count_cars")

then just build the ionic app targeting the phonetype you want (android or ios or both) ... alternatively if you have already exposed that url... they could just open the url in their phones webbrowser

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • The AJAX call implemented in IONIC is not returning any value : AND, what do you mean by "server" ? BTW I was able to get flask right – Johith Iype Jan 26 '18 at 10:24