Overview: Need a mobile app that will take, as input, pictures of client addresses and output a recommended map to deliver them. Use: OCR (Optical Character Recognition) + Google Maps Use Tesseract

Play with OCR


In [ ]:
from PIL import Image 
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'c:/Tesseract-OCR/tesseract'

In [ ]:
path = 'c:/learnPython/tess/mm_address.jpg'
path2 = 'mm_address.jpg'
img = Image.open(path2) 
text = pytesseract.image_to_string(img)
print(text)
name = text.splitlines()[0]
street = text.splitlines()[2]
city = text.splitlines()[3]
customer = street + ', ' +  city
print('The street is: ', customer)

OCR for reading a volunteer list


In [ ]:
from PIL import Image 
import pytesseract
import sys
pytesseract.pytesseract.tesseract_cmd = 'c:/Tesseract-OCR/tesseract'

path = 'c:/Users/ginny/Desktop/running/thtrb.jpg'
path2 = 'thtrb.jpg'
img = Image.open(path2)
text = pytesseract.image_to_string(img)
print(text)

Play with Maps


In [ ]:
import googlemaps
from datetime import datetime
gmapsC = googlemaps.Client(key='Deleted')

In [ ]:
myHome = "2403 Englewood Ave, Durham, NC"
now = datetime.now()
wp=['300 N Roxboro St, Durham, NC 27701','911 W Cornwallis Rd, Durham, NC 27707', '345 W Main Street, Durham, NC 27701' ]
directions = gmapsC.directions("2403 Englewood Ave, Durham, NC",
                                     "Duke Memorial",
                                     mode="driving",
                                     waypoints=wp,
                                     optimize_waypoints=True,
                                     departure_time=now)

print(directions[0].keys())
print(directions[0]['summary']) 
print(directions[0]['waypoint_order'])
print(directions[0]['legs'])

In [ ]:
gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)

gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)
gmap.scatter(more_lats, more_lngs, '#3B0B39', size=40, marker=False)
gmap.scatter(marker_lats, marker_lngs, 'k', marker=True)
gmap.heatmap(heat_lats, heat_lngs)

gmap.draw("mymap.html")

In [ ]:
# Needed the Google Maps JavaScript API to run 
import googlemaps
from datetime import datetime
import gmaps
gmapsC = GoogleMaps.Client(key='deleted')
gmaps.configure(api_key='deleted')

In [ ]:
homeLong = '2403 Englewood Ave, Durham, NC 27705'
# lat, lng = gmapsC.address_to_latlng(home)
# print(lat, ' + ', lng)
home = (36.0160282, -78.9321707)
foodLion = (36.0193147,-78.9603636)
church = (35.9969749, -78.9091543)
m = gmaps.Map()
dl = gmaps.directions_layer(home, church, waypoints=[foodLion])
m.add_layer(dl)
m
# How do you use optimize:true with jupyter gmaps?

In [ ]: