I built the SMS bot using the Twilio API and Python, which allows you to send a Twilio number messages and get answers back. I got the inspiration of this project and some part of the codes from Make webpage. For this work I used Twilio API, Ngrok, Flask, Wolfram Alpha API, Wikipedia, and yWeather.
1. Install ngrok and add the exec file in Mac:
2. Go to twilio webpage (https://www.twilio.com/)and get free API and number (number should have sms capability)
3. Install ngrok and add the exe file here (open /usr/local/bin)
4. You need to get API from Wolfram Alpha (https://products.wolframalpha.com/api/) and add that API to getReply.py line 43.
5. Run run.py
6. Type in terminal (same path as run.py)
ngrok http port_number
You will see on you screen:
copy one of the Forwarding address (something like http:// …. .io)
7. Go to your Twilio dashboard and press the “#” on the left. Click on your Twilio number, scroll down and enter the http address into the space that says “A message comes in” in Messaging part. Make sure the dropdown is set to “webhook”. Now paste the Forwarding address here!
8. Open sms app on your mobile and type your question and send in to your Twilio number. (e.g., wiki Barak Obama )
9. Thanks to Sophia Smith and me, now you have working SMS chatbot 🙂
For distance between two GPS coordinates as I googled I realized the best method to use is haversine formula.
The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes. It is a special case of a more general formula in spherical trigonometry, the law of haversines, relating the sides and angles of spherical “triangles”.
The Google Static Maps API returns an image (either GIF, PNG or JPEG) in response to an HTTP request via a URL. For each request, you can specify the location of the map, the size of the image, the zoom level, the type of map, and the placement of optional markers at locations on the map. You can additionally label your markers using alphanumeric characters.
In this post I decided to write a function to generating a Google Static Maps with marker as easy as possible here is my version:
Cropping result for corners points of [(444, 203), (623, 243), (691, 177), (581, 26)]
As all you know sometimes cropping image can be challenging. Some days ago I had some issues in cropping part of my training image. My problem was my region wasn’t rectangular, so here is my solution to non-rectangular region cropping. I hope in would be useful for us as well 🙂
For solving part of my problem I needed to find the transformation matrix between the rotated image and its original so I told myself why not write the post in my blog about this problem. For this post I am going to show you how we can transform rotated image to the original image. Let’s start:
%% Input images.
Detect features in both images and match the features: