As my mate Simón was writing short time ago in his post Announcing the Gallery Tilt Shift plugin for the Nokia N9, we got published at Igalia some plugins for enhancing the experience of the built-in Gallery application in the N9/N950 through the Nokia Store: Enlarge & Shrink Plugin, Gallery Tilt Shift Plugin, and Facerecognition Resetter Plugin.
The Enlarge & Shrink Plugin is a filter developed by Antía Puentes for the built-in Gallery application which applies a radial distortion to a picture featuring an enlarge or shrink effect (also known as punch or pinch).
The Gallery Tilt Shift Plugin is a filter developed by Simón Pena for the built-in Gallery application which makes a picture look like a miniature.
Finally, Facerecognition Resetter Plugin was developed by me. It is a add-on for the built-in Gallery application which is not a real filter for the pictures. Instead, it is just a way of forcing the deletion or un/protection of the face recognition database through its usage from Gallery. The main reason for doing this is a well known bug in the face recognition feature.
If you are experiencing that the the N9 is not recognizing faces any more or it is not giving any more suggestions just install Facerecognition Resetter Plugin and click on the “Protect” button. You want to do this even if you are not suffering this problem since this will prevent it from appearing in the future.
BTW, comments and reviews in the Nokia Store will be welcomed 😀
But, specifically, why would we want to reset or un/protect the face recognition database? Or, actually, what the heck is that face recognition database? Let’s get to the beginning.
When Nokia released the PR1.2 update for the Harmattan platform they included a new feature which made the N9 to be the first smartphone with integrated automated face recognition.
This feature, when activated, let the Gallery or Camera application to automatically recognize faces on the pictures stored in the device, showing a white bubble with a question mark on top of the region detected as a face.
Clicking on such bubble you would be able to select one of your contacts to be assigned as the detected face.
The algorithm would be even learning as the user selected and assigned faces to contacts so at some point it would be also suggesting the proper contact for the detected faces. The user, then, would only have to double tap on the suggestion bubble to confirm such contact.
Everything seemed great but after a while, some users started to complain that this feature eventually stopped working. Either it was not suggesting anyone, when there were people tagged in a big number of pictures or it was just not recognizing faces any more.
As with any software, the face recognition feature contains bugs and this problem was the consequence of one that Nokia has not yet fixed to the current date.
The technical explanation is that the algorithm that performs the face detection relies in SQLite to store its learning parameters and contacts. This database is located at:
/home/user/.local/share/gallerycore/data/faces.db
This file and its directory are protected through the usage of the AEGIS “powered” gallerycoredata-user user and gallerycoredata-users group. Also, the file permissions mask for them are 070 in the case of the directory and 060 in the case of the file.
When doing transactions to the database file the SQLite driver may create some temporal files as the journal one, to be able to recover the database under disaster. This journal file gets the UID and GID of the running process and the permissions from a combination of the permissions of the original database file and the running process’ umask. As a consequence, the journal file usually has the permissions mask 040.
While using the Camera or Gallery application the SQLite file is open. Whether a disaster may happen, although we hold the journal file, the owner of that file is not able to read it. Hence, the SQLite database remains useless for the processes with the same UID than the owner of the journal file, even when they belong to the same group than that file.
What it happen afterwards is that the SQLite database remained waiting to be “recovered” using the journal file but as the journal could not be read, the face recognition algorithm could not provide the learned information and suggest contacts any more. The solution for this would have been as easy as to change the file permissions of the journal file but this is not even possible for the root user since only the gallerycore-user user and those belonging to the gallerycore-users group were allowed through AEGIS to read and change the files on the parent directory of the database file.
Hence, the only way of being able to do a hack that would solve this problem was that the actual application doing such changes would be either Gallery or Camera. Fortunately, Gallery had the possibility of being extended through plugins and that’s the reason why Facerecognition Resetter is such.
Following, you can watch a video featuring an usage introduction tutorial and a detailed explanation of its usage below it.
The plugin shows 3 buttons for its corresponding actions:
- Reset the database: As simple as that. It will delete the directory and files containing all the information gathered through the face recognition algorithm. From that on, the face recognition feature will start to work again but the learning gotten previously and powering the suggestions will be lost.
- Protect the database: This will correct the permissions of the directories and files containing all the information gathered through the face recognition algorithm. From that on, the face recognition feature will start to work again and the suggestions would have the learning gotten previously. The problem will not show up in the future ever again but the database will remain protected and only usable through Gallery and Camera (or any other application with the proper AEGIS tokens).
- Unprotect the database: This will correct the permissions of the directories and files containing all the information gathered through the face recognition algorithm. From that on, the face recognition feature will start to work again and the suggestions would have the learning gotten previously. The problem will not show up in the future ever again and the database will be available to any other application that would like to make use of it.
The permissions get corrected when un/protecting since the plugin sets the SGID bit to the parent directory of the database file so any other files created under it will belong to the same group than the directory and not to the GID of the running process that created that file. Also, the database will have now the 660 mask so any temporal file created by the SQLite drive will attempt to keep the same mask.
And with this, we can keep enjoying the usage of the face recognition feature of the N9 and go to celebrate it with some beers!!! 😀
This and the other plugins are Open Source, so you can go to their page at GitHub: Enlarge & Shrink, Gallery Tilt Shift and Facerecognition Resetter
Also, don’t forget to take a look at all the applications published by Igalia at the Nokia Store
So after reading through this, it sounds like “unprotect” is the most prudent option, just in case any other app/s (outside gallery & camera) want to use the db.
Is that the option you would recommend power-users select?
Also, like the Gallery plugins Igalia has created, is the native Camera app extendable through the use of plugins?
For a power-user, yes, maybe unprotect is the best option. I would reccommend always “Protect”, though, just as Nokia was doing this from the beginning.
If I recall correctly, Camera was using a private library for controlling the GStreamer pipeline and CameraBin2, so I don’t know how extendable would it be.
I recommend you to take a look to Aura, another of our apps:
http://store.ovi.com/content/266783
http://igalia.github.com/aura/
For the matter of the pictures, N9’s camera uses, as Gallery, the privative library gallerycore published in the PR1.0 SDK. Unfortunately, the plugins in PR1.2 and beyond are incompatible with that library from the SDK so you won’t be able to create new plug-ins for Gallery 🙁
“I would reccommend always “Protect”, though, just as Nokia was doing this from the beginning.”
Cool I’ve set it to “unprotect” (very longtime maemo/meego user here), was just curious if there was anything you know off-the-top-of-your-head, as-to-why that’s a bad thing (apart from obvious security concerns etc).
I noticed when you go back into it, it doesn’t give you any visual indication that it’s already been set, guess that wasn’t doable?
“If I recall correctly, Camera was using a private library for controlling the GStreamer pipeline and CameraBin2, so I don’t know how extendable would it be.”
Wow… that blows…. 🙁
“Unfortunately, the plugins in PR1.2 and beyond are incompatible with that library from the SDK so you won’t be able to create new plug-ins for Gallery”
So how was Igalia able to create it’s plugins then?
Thanks for your time!
Just not a priority to spend time in 😉
You can probably guess how. Nokia was kind enough to provide us the means 🙂
Thanks mate,
How open might they be in the future to facilitating the means again do you think?
(and for GStreamer pipeline & CameraBin2, not just Gallery)
Will it be like “pulling teeth” again? 🙁
Cheers!
The MeeGo team was dismantled and Nokia is fully focused on Windows Phone and the Lumia products.
There is no way I can see they will devote any hour to Harmattan but to finish dismantling the rest of the services related to it.
@tanty
Well, we dont know to what scale it was dismantled, I’ve spoken to quite a few former employees & none of them really know, they still think there’s some people there (mainly for maintenance), but exact size of the team (comparatively) is unknown.
Cheers.
Pingback: Face recognition | Usgamblinghist