Detect when an image touch a building - mapbox-gl-js

How can I solve that I put an image on a certain coordinate and send message to console if the image touch any building?

Interesting question. I think you can achieve this as follows:
Use a Marker to add the image to a location (see https://docs.mapbox.com/mapbox-gl-js/example/custom-marker-icons/ )
Given the HTML element for the marker, el, use getBoundingClientRect() to find the pixel positions of it, relative to the viewport.
Do some maths to find those positions relative to the map.
Call map.queryRenderedFeatures() with those positions, to detect if there is any building within the area of the marker image.

Related

Flutter: Only detect gestures within a image

I'm having some trouble with Gesture Detector. I have a set of images that I want to add a GestureDetector to. However, I only want the GestureDetector to be active within a border of the image. As seen in the images below. I have some images with random shapes that are transparent behind the images. I want to make a gesture detector that only detects the inside of these random shapes. The parts that are marked with green. I did this for the circle by taking the local.position of the taping and then checking if it was within a circle with x^2 + y^2 = ... However this can not be done with custom shapes. Could someone help me with an idea of how to solve this? If I just mark the image with a gesturedetector then is it also possible to tap on the transparent part of the image, which I dont want. Thanks
Image
This is not something, you will be able to do natively in Flutter. If you want to extract the exact region of interest, you will need to do image processing to find the right shape. Your best bet to do the image processing live is C/C++.
Dart has the ability to execute native C, take a look at this: https://dart.dev/guides/libraries/c-interop
You should attempt to extract a polygon bounding box of the image areas and then use the polygon path values to draw a path using a CustomPainter.
If you do not need to be exact, try to approximate the shape by a simple polygon path by hand. The user probably will not notice the difference.

Make a layer over an image and adjust its co-ordinates by touch

I need to make a layer over an image and adjust the layer to fit to image and get its co-ordinates of the layer.
I need to adjust the layer by touch and pinch.
The sample image is as below. I need to do this in ios, and can I get any ideas to do this?
Use coreImage's Face detection API to detect Bound of Face, and CGPoint of Left eye, Right eye and mouth. Use Bezier path to draw a purple line path against each face feature as you have shown in picture.
If you want to be more precise better use openCV to detect edges against each face feature.

How can I detect an upward-facing arrow in an image on iOS?

I have an image that contains an upward-facing arrow in its left-hand side. I would like to be able to detect that particular shape in that orientation, and if it's present, capture just that portion of the image. If the arrow faces downward, I want it to be ignored.
I've looked into using SURF descriptors and OpenCV to detect and match a shape like this, but there are licensing issues around the SURF algorithms. What alternative method(s) could I use to detect this shape in this particular orientation within an image on iOS?
A simple template matching can solve this. Build a template (or crop from an existing image) an 'upwards arrow.' Then use Normalized Cross Correlation to see where all the 'upwards arrows' are present in your test image. Since you are only looking for 'upwards arrows' on left-side of image, limit your Normalized Cross Correlation search in that region. Here is a good tutorial: http://www.mathworks.com/products/demos/image/cross_correlation/imreg.html

GPS Location on custom map

Is there a way to map the user's current location on an image view?
I have an map image of small area, and want to display the current location on it. Is there a way to calculate location on image from GPS coordinates?
Thanks
You need lat/long references on the image to do it. Either two corners or edges. Then you interpolate the user coordinates onto the image using the references.

how to swap images using Cocoa Touch

I am trying to build 15-puzzle game.
Here I need to swap a blank image with a clicked on image. I would like to know how to swap these images.
I have stored the co-ordinates of the two images,but don't know the format to identify the blank image and then set its origin to clicked image.
Present each tile as a CALayer. To swap two tiles, set each layer's position to the other's position.