commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
1.03k stars 1.23k forks source link

If front-facing camera, warn that selfies are off-topic #1898

Open nicolas-raoul opened 6 years ago

nicolas-raoul commented 6 years ago
  1. Check whether the picture was taken with the front camera or back camera
  2. If front-camera, display a warning: "Most selfies are off-topic on Commons. Please upload only pictures of notable people or other encyclopedic content"

Unfortunately, EXIF does not have a front/rear property, but if we find a database of phone models we can be guessed it from the model and lens resolution as tipped at https://photo.stackexchange.com/questions/79179/rear-or-front-facing-camera-through-exif-data (also asked at https://softwarerecs.stackexchange.com/questions/52141/library-to-determine-whether-a-smartphone-picture-was-taken-with-front-or-rear-c)

(Inspired from a part of #74 but might be a bit easier to implement)

neslihanturan commented 6 years ago

Great idea! If user still proceeds, can we add a category (first we have to create this category on commons) as "possibly from front-facing camera" so that it will be easier to delete them later if they are inappropriate?

nicolas-raoul commented 6 years ago

Apparently some phone have the front/back information in EXIF, so a first implementation could use that, and ignoring pictures that do not have the information in their EXIF.

VojtechDostal commented 6 years ago

I don't understand Android development at all but I'm just wondering about some potential risks.

1) Can we rule out fake positives?

2) Will this not grow the code too much? looks like a fairly difficult image-recognition task.

3) Will the uploading be smooth? I am worried about long waiting times for the recognition tool to finish its task.

VojtechDostal commented 6 years ago

Oh sorry, this is not meant to recognize the image. It's just a warning for the front camera. Please disregard me :)

neslihanturan commented 6 years ago

I am late to answer but, @VojtechDostal image recognition was the first thing came to my mind when I first read this task. Then I recognized (as you did) the task does not require it (thanksfully):)

misaochan commented 6 years ago

We have a suggestion at https://meta.wikimedia.org/wiki/Grants_talk:Project/Commons_app/Commons_Android_app_v3#Selfies

Don't try to solve 100% -- there's no point. Instead think smart and focus on the popular cameras. Have a look at Flickr Cameras. You can click on the mobile phone brands to get numbers for various models. iPhone is the majority camera now, though this is just the android app. You can see that Samsung's numbers are 5-10x those of Sony, LG, Moto, etc. So by coming up with a solution for the top 20 android phones, say, you'd probably reach 95% or more of all photos taken with an Android. Even if you had to resort to focal length & aperture to guess, a table of 20 items would be easy to implement. And if some brands (OnePlus?) name the camera used, then that might work for all models in that brand. Extracting sample photos from Commons per model and then examining the Exif with EXIFTOOL sounds relatively simple. A whole lot simpler than assuming the Android face recognition is going to help you -- is that API even available in all cameras -- or working out what percentage constitutes a selfie. -- Colin (talk) 12:18, 29 November 2018 (UTC)

I personally think this could be quite an interesting way of handling selfie detection, although it would still require a bit of maintenance (since the top 20 phones next year won't be the same as the top 20 phones this year). What do you guys think? Please feel free to chime in on the discussion on-wiki. @nicolas-raoul

nicolas-raoul commented 6 years ago

If we can find an up-to-date small database of focal length of the most popular phones, that would be great :-)

ilgazer commented 5 years ago

Can't we retrieve the focal length data from Android SDK Camera2 API?

nicolas-raoul commented 5 years ago

@ilgazer For pictures taken within the app, probably. But I guess this API can not be used for pictures found in the gallery, right?

ilgazer commented 5 years ago

The api just gives us the camera specs. So we wouldn’t be able to detect selfies taken from that phone but not selfies taken from another phone.

5 Temmuz 2019 Cuma tarihinde Nicolas Raoul notifications@github.com yazdı:

@ilgazer https://github.com/ilgazer For pictures taken within the app, probably. But I guess this API can not be used for pictures found in the gallery, right?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/commons-app/apps-android-commons/issues/1898?email_source=notifications&email_token=AB2EXI3HGZZQRSD465XIPA3P52T3XA5CNFSM4FU2NHO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZILL5A#issuecomment-508605940, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2EXIZRQYPSQ3EW3PLGD6LP52T3XANCNFSM4FU2NHOQ .

nicolas-raoul commented 5 years ago

That API only gives you the available focal lengthes of the camera, right? It does not say what focal length was actually used to create 4352.JPG even if 4352.JPG has been shot on the same phone.

Mishrasubha commented 4 years ago

Can we integrate a Machine Learning model which recognizes images containing selfies and then display the warning and ask the user if he/she wishes to upload the image anyway? @nicolas-raoul

VojtechDostal commented 4 years ago

Can we integrate a Machine Learning model which recognizes images containing selfies and then display the warning and ask the user if he/she wishes to upload the image anyway? @nicolas-raoul

Isn't machine learning a bit too much for our little uploading app? :-) I'd suggest we keep it simple and easy-to-maintain. Anyways, how big problem selfies are nowadays?

misaochan commented 4 years ago

Just thinking about how best to implement this. We have a few options:

  1. See if there is an externally-maintained database of focal lengths etc that we can use. The upside is that we don't have to maintain it, the downside is that it's entirely possible that it could just disappear/be moved/change etc without us realizing.
  2. Maintain our own data, similar to https://github.com/commons-app/campaigns . Upside: We have total control over it. Downside: We have to update it... probably not too often, I guess once every 6 months or even 12 months could suffice.
  3. It seems that some cameras DO save a "lens facing" EXIF field: https://softwarerecs.stackexchange.com/questions/52141/library-to-determine-whether-a-smartphone-picture-was-taken-with-front-or-rear-c#comment72430_52141 . This would actually be the absolute simplest way to implement this IMO, but there would be a tradeoff of coverage. I guess it depends on how many popular phone cameras save this field.
macgills commented 4 years ago

I'd implement 3 only as it is the simplest, or at least just focus on that easy win for now.

I am always wary of targeting samsung devices because they are notorious for mangling apis/resources and returning nonsense values. Unless we can absolutely verify it makes me a tiny bit nervous. There are some services where we can request test time on specific devices, we could run an instrumented test that verifies the phone gets detected properly? Bit annoying to write probably

misaochan commented 4 years ago

Thanks for the input @macgills . I am personally leaning towards option 3 as well, at the very least I figure we could start with that and then step up the complexity if we find that there is a need later on.

There are some services where we can request test time on specific devices, we could run an instrumented test that verifies the phone gets detected properly?

Is there a free one that you could recommend?

macgills commented 4 years ago

Firebase Test Lab is sort of free? Kiwix used bitbar some time ago and somebody on the repo was looking into BrowserStack, I don't have any particular insight into these services