I have an array of JSON real Points of Interest that came from an API (generated by Java) taken from a PostgreSQL database:
[
{
"code": 18554,
"lat": 43.36161686223077,
"lon": 3.15837302430637,
"taxon": {
"popularNameEN": "Moon trefoil",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/8/81/Cistus_creticus_1.jpg/240px-Moon_trefoil.jpg"
}
}
},
{
"code": 13826,
"lat": 42.36162882111323,
"lon": 3.158355343054932,
"taxon": {
"popularNameEN": "Rock rose",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Cistus_creticus_RJB2.JPG/240px-Cistus_creticus_RJB2.JPG"
}
}
}
]
(16000 PoI in an area of 14 hectares).
Currently my app draw them in a 2d regular map (with Leaflet) with the name and a thumbnail (I already have a function that show just the 8 closest, not all 16000).
I want to show same information in a simple and easy Augmented Reality way in Android phones.
I don't care if the result is not perfect because the compass, or anything. I care to use 100% free and open source software and avoid to use an external API, if it is possible. I need just something simple for a show to my client but maybe also something enough good to continue improving my app in the future. What framework/libraries should I use for this and how?
You can start with Google's AR kit.
https://developers.google.com/ar
It is easy and self-explanatory, but for now, it has limited support for devices.
Related
I am currently developing a website for a client. It consists of users being able to upload pictures to be shown in a gallery on the site.
The problem we have is that when a user uploads an image it would obviously need to be verified to make sure it is safe for the website (no pornographic or explicit pictures). However my client would not like to manually have to accept every image that is being uploaded as this would be time consuming and the users' images would not instantly be online.
I am writing my code in PHP. If needs be I could change to ASP.net or C#. Is there any way that this can be done?
2019 Update
A lot has changed since this original answer way back in 2013, the main thing being machine learning. There are now a number of libraries and API's available for programmatically detecting adult content:
Google Cloud Vision API, which uses the same models Google uses for safe search.
NSFWJS uses TensorFlow.js claims to achieve ~90% accuracy and is open source under MIT license.
Yahoo has a solution called Open NSFW under the BSD 2 clause license.
2013 Answer
There is a JavaScript library called nude.js which is for this, although I have never used it. Here is a demo of it in use.
There is also PORNsweeper.
Another option is to "outsource" the moderation work using something like Amazon Mechanical Turk, which is a crowdsourced platform which "enables computer programs to co-ordinate the use of human intelligence to perform tasks which computers are unable to do". So you would basically pay a small amount per moderation item and have an outsourced actual human to moderate the content for you.
The only other solution I can think of is to make the images user moderated, where users can flag inappropriate posts/images for moderation, and if nobody wants to manually moderate them they can simply be removed after a certain number of flags.
Here are a few other interesting links on the topic:
http://thomas.deselaers.de/publications/papers/deselaers_icpr08_porn.pdf
http://www.naun.org/multimedia/NAUN/computers/20-462.pdf
What is the best way to programmatically detect porn images?
The example below does not give you 100% accurate results but it should help you a least a bit and works out of the box.
<?php
$url = 'http://server.com/image.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/detect_nudity.php?url=' . $url));
if (#$data->success !== 1)
{
die('Failed');
}
echo 'Contains nudity? ' . $data->nudity . '<br>';
echo 'Nudity percentage: ' . $data->nudity_percentage . '<br>';
If you are looking for an API-based solution, you may want to check out Sightengine.com
It's an automated solution to detect things like adult content, violence, celebrities etc in images and videos.
Here is an example in PHP, using the SDK:
<?php
$client = new SightengineClient('YourApplicationID', 'YourAPIKey');
$output = $client>check('nudity')>image('https://sightengine.com/assets/img/examples/example2.jpg');
The output will then return the classification:
{
"status": "success",
"request": {
"id": "req_VjyxevVQYXQZ1HMbnwtn",
"timestamp": 1471762434.0244,
"operations": 1
},
"nudity": {
"raw": 0.000757,
"partial": 0.000763,
"safe": 0.999243
},
"media": {
"id": "med_KWmB2GQZ29N4MVpVdq5K",
"uri": "https://sightengine.com/assets/img/examples/example2.jpg"
}
}
Have a look at the documentation for more details: https://sightengine.com/docs/#nudity-detection
(disclaimer: I work there)
There is a free API that detects adult content (porn, nudity, NSFW).
https://market.mashape.com/purelabs/sensitive-image-detection
We've using it on our production environment and I would say it works pretty good so far. There are some false detections though, it seems they prefer to mark the image as unsafe if they are unsure.
It all depends on the level of accuracy you are looking for, simple skin tone detection (like nude.js) will prob get you 60-80% accuracy on a generous sample set, for anything more accurate than that, let's say 90-95%, you are going to need some specialized computer vision system with an evolving model that is revised over time. For the latter you might want to check out http://clarifai.com or https://scanii.com (which I work on)
Microsoft Azure has a very cool API called Computer Vision, which you can use for free (either through the UI or programmatically) and has tons of documentation, including for PHP.
It has some amazingly accurate (and sometimes humorous) results.
Outside of detecting adult and "racy" material, it will read text, guess your age, identify primary colours, etc etc.
You can try it out at azure.microsoft.com.
Sample output from a "racy" image:
FEATURE NAME: VALUE:
Description { "tags": [ "person", "man", "young", "woman", "holding",
"surfing", "board", "hair", "laying", "boy", "standing",
"water", "cutting", "white", "beach", "people", "bed" ],
"captions": [ { "text": "a man and a woman taking a selfie",
"confidence": 0.133149087 } ] }
Tags [ { "name": "person", "confidence": 0.9997446 },
{ "name": "man", "confidence": 0.9587285 },
{ "name": "wall", "confidence": 0.9546831 },
{ "name": "swimsuit", "confidence": 0.499717563 } ]
Image format "Jpeg"
Image dimensions 1328 x 2000
Clip art type 0
Line drawing type 0
Black and white false
Adult content true
Adult score 0.9845981
Racy true
Racy score 0.964191854
Categories [ { "name": "people_baby", "score": 0.4921875 } ]
Faces [ { "age": 37, "gender": "Female",
"faceRectangle": { "top": 317, "left": 1554,
"width": 232, "height": 232 } } ]
Dominant color background "Brown"
Dominant color foreground "Black"
Accent Color #0D8CBE
I have an android app that gets the lat&long from the device and uses googles reverse geocoding api to give back an address. Everything was working fine for some time but now all of a sudden I get zero_results/
I replicate it in my browser the request is:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.783783783783782,35.22879215957073&key=MY_KEY
but if I change it to:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.78,35.22&key=MY_KEY
which is just shortening the lat&lng to 2 decimals it works, but say if I round it to 2 decimals:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.78,35.23&key=MY_KEY
It doesnt work!!!
I cant rim it without rounding it, but now i am afraid in another case it wont work, I don't know what is going on with the API, everything was working fine before.
Any help solving this would be appreciated.
Thanks
This is because Google gives no support for disputed areas (such as Kinmen County, West Bank, Crimea, etc.). ZERO_RESULTS is the intended behaviour.
You can see the problem in google public issue tracker at https://issuetracker.google.com/issues/35826813
The bad news, your point is at the DMZ. As stated above: Google Reverse Geocoding won't work near the 1949 armistice lines (and not in what used to be Jordanian territories 1949-1967).
The not-so-bad news: There may be some kind of a workaround that's feasible for some: OpenStreetMap can also provide reverse geolocation. Your coordinate:
https://nominatim.openstreetmap.org/reverse?&format=jsonv2&lat=31.779975&lon=35.227901
Yields
{
"place_id": 199263301,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"osm_type": "relation",
"osm_id": 7880713,
"lat": "31.7782568",
"lon": "35.2315827592487",
"place_rank": 30,
"category": "historic",
"type": "heritage",
"importance": 0,
"addresstype": "historic",
"name": "Old City of Jerusalem and its Walls",
"display_name": "Old City of Jerusalem and its Walls, HaOmer, Jewish Quarter, Old City, Jerusalem, Jerusalem District, no, Israel",
"address": {
"address29": "Old City of Jerusalem and its Walls",
"footway": "HaOmer",
"suburb": "Old City",
"city": "Jerusalem",
"state": "Jerusalem District",
"postcode": "no",
"country": "Israel",
"country_code": "il"
},
"boundingbox": [
"31.7728081",
"31.7837416",
"35.2257013",
"35.2375582"
]
}
As you can see, they may be off by quite a few hundreds of meters. In this case (I was mean, choosing a case that augments the issue) it spells 15min diversion by foot, and no way by car.
Some may find it tolerable. For others it means sending someone to the wrong place.
On the other hand, as mentioned before, I did pick a nasty case. In most cases OSM are pretty much accurate to a few meters.
I just want to add that on 1/29/2018 I also started experiencing random results from the API. My code has been working great for more for a year. Now I can send a request with a well-defined location (not reverse; I start with an address or intersection in search of coordinates and geopolitical info) and I get no results. I can send again- no results. And I can send again- and I GET RESULTS! Same exact query, with differing responses. I think the root cause for my
Is it possible to get a response (true or false) if are a traffic jam from your position to your destination, using google maps android API? Or using google maps web api?
Can not find anythink about that.
I believe there is no direct Google endpoint that can answer this question. However, you can implement a workaround using a Distance Matrix API web service or Directions API web service. If you specify a departure time in the request, the response will contain fields duration and duration_in_traffic. So you can figure out if duration_in_traffic is much bigger than duration and decide if there is a traffic jam somewhere on this route.
For example,
I execute Distance Matrix API request for two points in Barcelona
https://maps.googleapis.com/maps/api/distancematrix/json?origins=av%20Diagonal%20198%2C%20Barcelona&destinations=plaza%20Espa%C3%B1a%2C%20Barcelona&departure_time=now&key=MY_API_KEY
The response is
{
"destination_addresses":[
"Av. del Paraŀlel, s/n, 08015 Barcelona, Spain"
],
"origin_addresses":[
"Avinguda Diagonal, 198, 08018 Barcelona, Spain"
],
"rows":[
{
"elements":[
{
"distance":{
"text":"6.0 km",
"value":6049
},
"duration":{
"text":"17 mins",
"value":1035
},
"duration_in_traffic":{
"text":"19 mins",
"value":1134
},
"status":"OK"
}
]
}
],
"status":"OK"
}
Comparing duration_in_traffic and duration from my response I can say that currently there are no traffic jams on this route.
I hope this helps!
I'm trying to create a tourism app for Android.
I need the user be guided by voice. I've been looking at the googlemaps Android API but there's nothing about voice directions.
Do you know any workaround for this? Is there any other API/SDK that I could use to implement this?
Thanks in advance.
That's a very cool idea. However, I do not know if you're ready to reinvent the wheel to do that. In case you are, I also have a solution but let me first introduce the way I would solve this problem:
On Android, there is the intent system which allows you to call internal apps in order to make your job easier. So why wouldn't you launch the Directions app (Google Maps with a special intent) since the user likely is familiar with the UI and probably likes it? Also, with this solution, you do not need to take care about keeping your stuff updated, you just ask the system and it'll provide the solution out of the box. And it is much much easier to proceed this way. :)
To do that, you will use plain basic URI that the system will recognise:
String address = "My Fake Address";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + address));
startActivity(intent);
After that, the user will be able to choose how he wants to go there and your job is done, the user is satisfied, and you did like 99% of the other apps (he has the vocal messages as well).
Then, if it is in your requirements to have it inside your app, it could be possible (based on Aster proposition) but you'll need to keep a track of the user yourself (to be able to send the good instruction at the right time). But first let's take a look at the Directions API of Google, if you correctly set up your App you should receive this kind of JSON (whole doc there):
{
"status": "OK",
"routes": [ {
"summary": "I-40 W",
"legs": [ {
"steps": [ {
"travel_mode": "DRIVING",
"start_location": {
"lat": 41.8507300,
"lng": -87.6512600
},
"end_location": {
"lat": 41.8525800,
"lng": -87.6514100
},
"polyline": {
"points": "a~l~Fjk~uOwHJy#P"
},
"duration": {
"value": 19,
"text": "1 min"
},
"html_instructions": "Head \u003cb\u003enorth\u003c/b\u003e on \u003cb\u003eS Morgan St\u003c/b\u003e toward \u003cb\u003eW Cermak Rd\u003c/b\u003e",
"distance": {
"value": 207,
"text": "0.1 mi"
}
},
...
... additional steps of this leg
...
... additional legs of this route
"duration": {
"value": 74384,
"text": "20 hours 40 mins"
},
"distance": {
"value": 2137146,
"text": "1,328 mi"
},
"start_location": {
"lat": 35.4675602,
"lng": -97.5164276
},
"end_location": {
"lat": 34.0522342,
"lng": -118.2436849
},
"start_address": "Oklahoma City, OK, USA",
"end_address": "Los Angeles, CA, USA"
} ],
"copyrights": "Map data ©2010 Google, Sanborn",
"overview_polyline": {
"points": "a~l~Fjk~uOnzh#vlbBtc~#tsE`vnApw{A`dw#~w\\|tNtqf#l{Yd_Fblh#rxo#b}#xxSfytAblk#xxaBeJxlcBb~t#zbh#jc|Bx}C`rv#rw|#rlhA~dVzeo#vrSnc}Axf]fjz#xfFbw~#dz{A~d{A|zOxbrBbdUvpo#`cFp~xBc`Hk#nurDznmFfwMbwz#bbl#lq~#loPpxq#bw_#v|{CbtY~jGqeMb{iF|n\\~mbDzeVh_Wr|Efc\\x`Ij{kE}mAb~uF{cNd}xBjp]fulBiwJpgg#|kHntyArpb#bijCk_Kv~eGyqTj_|#`uV`k|DcsNdwxAott#r}q#_gc#nu`CnvHx`k#dse#j|p#zpiAp|gEicy#`omFvaErfo#igQxnlApqGze~AsyRzrjAb__#ftyB}pIlo_BflmA~yQftNboWzoAlzp#mz`#|}_#fda#jakEitAn{fB_a]lexClshBtmqAdmY_hLxiZd~XtaBndgC"
},
"warnings": [ ],
"waypoint_order": [ 0, 1 ],
"bounds": {
"southwest": {
"lat": 34.0523600,
"lng": -118.2435600
},
"northeast": {
"lat": 41.8781100,
"lng": -87.6297900
}
}
} ]
}
So what could be possible is to take these html_instructions and to read them to the user with the Android TTS Lib when he is in a square around the start_location or the end_location. However, it can be very complicated to manage this square properly, that's why I would use the first option which is really respecting the Android Spirit.
BTW, here are the definition of these attributes:
start_location contains the latitude/longitude coordinates of the origin of this leg. Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road) at the start and end points, start_location may be different than the provided origin of this leg if, for example, a road is not near the origin.
end_location contains the latitude/longitude coordinates of the given destination of this leg. Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road) at the start and end points, end_location may be different than the provided destination of this leg if, for example, a road is not near the destination.
i would like to categorize applications.
When an app comes to foreground i should be able to detect that this app has video,audio,just text, or 3D graphics.
I tried using 2 options to categorize them:
to get the permissions used in the apps, but couldn't get permissions for 3rd party apps(only the native apps), is it true that you cannot get permissions for 3rd party apps? or am i missing something?
to pick out all installed apps based on mimeType, but i get only the native apps, or maybe certain apps(intents of apps) don't have the mimeType specified(am not sure).
is there any other way to categorize the installed applications? I would really appreciate it if someone could help me out with this?
thanks alot
Use the WhereDat API:
Create a raw JSON POST request, with an array of the packages you want to categorize:
{
"packages": [
"com.pixmix.mobileapp",
"com.nextstagesearch"
]
}
Send it to:
http://api.wheredatapp.com/data
And here's the response:
{
"apps": [
{
"category": "Productivity",
"rating": 4.5,
"updated": 1436741473,
"created": 1431028391,
"icon_url": "https://lh3.googleusercontent.com/q5pFGfXKZejowwcmlJl7M1IXGHVM4Zq_IjPpYb7zgkUFXO3QnZ2LyeOUUhMPaKPkJ3gR=w300",
"title": "WhereDat Beta",
"package": "com.nextstagesearch",
"ratings_count": 4,
"short_description": "WhereDat lets you easily search your device for contacts, apps, and recently accessed webpages without leaving your home screen. With deep linking you can search the c..."
},
{
"category": "Photography",
"rating": 4.0519609451293945,
"updated": 1435970764,
"created": 1430868349,
"icon_url": "https://lh3.ggpht.com/NgbwQzyo2mDR8su1Embio5jtHuPyScaMr0j4iub58YR5m19Ns0gVdeb9pYgNvMuFCcg=w300",
"title": "PixMix - Photo sharing",
"package": "com.pixmix.mobileapp",
"ratings_count": 2040,
"short_description": "Simple collage or photo sharing in just two clicks!★ See your photos in BEAUTIFUL albums★ Create beautiful album COLLAGE★ EASILY send albums to friends and family★ You..."
}
]
}