The code
Let's write the code to bring the building access management System to life using AWS S3 and Rekognition.
The setup requires Node.js to be installed on Raspberry Pi, which we have already done quite a few times in the previous chapter. So, we'll not repeat that here and straight away start writing the code.
Index face module code
This code will extract the feature information of faces stored in the S3 bucket and store them in the piCollection
that we created earlier using the AWS CLI tool.
Create a file with the name indexFaces.js
and include the npm
modules aws-sdk
and fs
in it. Make sure these modules are installed or run npm install
command in the terminal to do the installation, as shown in Figure 7.28 and Figure 7.29:

Figure 7.28

Figure 7.29
In the indexFaces.js
file, add both modules using require
:
var AWS = require('aws-sdk'), fs = require('fs');
Now, we will add the access key and region configuration, which allows access to AWS services for a particular user in a particular region...