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:
In this post I am going to solve this problem, how to find simple shapes like triangular and square ( or rectangular) in the image. For simple shape like square or triangular I normally use this procedure:
1. Find Contours in the image ( image should be binary)
2. Approximate each contour using approxPolyDP function.
3. Check number of elements in the approximated contours of all the shapes to recognize the shape. For eg, triangular will have 3; for square or rectangle, it has to meet the following conditions:
* It is convex.
* It has 4 vertices.
* All angles are ~90 degree.
4. Assign the color, run the code for your test image, check its number, fill it with corresponding colors.
Assumptions: Shapes don’t overlap, both of them solid (meaning, there is no white pixels inside the shape (all shapes are black). There can be multiple shapes in the image and they can be rotated any arbitrary number of degrees, and they can be of any size. Important: Triangles are non-obtuse!
Background subtraction is a major preprocessing steps in many vision based applications. For example, consider the cases like visitor counter where a static camera takes the number of visitors entering or leaving the room, or a traffic camera extracting information about the vehicles etc. In all these cases, first you need to extract the person or vehicles alone. Technically, you need to extract the moving foreground from static background.
BackgroundSubtractorMOG: It is a Gaussian Mixture-based Background/Foreground Segmentation Algorithm. It was introduced in the paper “An improved adaptive background mixture model for real-time tracking with shadow detection” by P. KadewTraKuPong and R. Bowden in 2001. It uses a method to model each background pixel by a mixture of K Gaussian distributions (K = 3 to 5). The weights of the mixture represent the time proportions that those colours stay in the scene. The probable background colours are the ones which stay longer and more static.
While coding, we need to create a background object using the function, cv2.createBackgroundSubtractorMOG(). It has some optional parameters like length of history, number of gaussian mixtures, threshold etc. It is all set to some default values. Then inside the video loop, use backgroundsubtractor.apply() (in my code fgbg.apply()) method to get the foreground mask. (read more about this function here)
The Canny Edge Detection is a popular edge detection algorithm. It was developed by John F. Canny in 1986. It is a multi-stage algorithm. Also known to many as the optimal detector, Canny algorithm aims to satisfy three main criteria:
- Low error rate: Meaning a good detection of only existent edges.
- Good localization: The distance between edge pixels detected and real edge pixels have to be minimized.
- Minimal response: Only one detector response per edge.
Canny Edge Detection in OpenCV: cv2.Canny().