AWS lambda backend app for the Autodesk Forge Reality Capture mobile app.
This server app calls the Forge Reality Capture API to process images found on your smartphone and generate an OBJ file. An OBJ file is an open geometry definition file format that represents 3D geometry alone.
The flow is simple:
The mobile app lets users select image files from the camera roll and upload them to a S3 bucket.
Before you start, make sure you read Serverless Code with Amazons AWS and Claudia to learn more about the setup.
npm install npm@latest -g
Redis Cloud is used here to store session data. AWS Lambda functions are stateless, hence the need to store session information and persist it elsewhere. Redis database will be used to persist the photoscenelink URL, photoscene ID and other parameters.
npm install
package.json
to change the app name on line 2. Pick a name that is unique to you.package.json
to update the Forge App ID and secret, Amazon S3 bucket and Redis password on the setvars script line --set-env FORGE_APP_ID=xxx,FORGE_APP_SECRET=yyy,S3_BUCKET=reality-capture-images,REDIS_PASSWORD=zzz
npm run create
to send everything up to AWS Lambda. It will return a 'new URL', make a note of its value as you will need to input the URL in the config.js file under the AWS_LAMBDA_BASE_ENDPOINT variable.npm run setvars
to push the environment variables to Lambda.Example: https://adc6qwtnce.execute-api.us-east-1.amazonaws.com/demo/
Remember to add a '/' or a '/index.html' to the URL.
Below I demonstrate 'Claudia.js' 'update' command to re-deploy a small code change. Claudia handles the task of zipping, uploading and re-wiring node.js endpoints to 'AWS-Lambda & API-Gateway' automatically.
npm run update
...Anytime you need to make code changes, you should use the 'update' command to push your changes to the AWS lambda function.
Go back to your mobile app to edit the ./constants/Config.js
file to have the correct AWS lambda endpoint in the variable named AWS_RECAP_LAMBDA_BASE_ENDPOINT. Save the change and submit 3 or more images for processing by pressing the button called "Process Photoscene".
This should generate a new OBJ file. You can validate the photoscenelink has the right data by browsing to the AWS lambda function endpoint /demo/redis/photoscenelink and use that URL to download the OBJ file locally.
Bastien Mazeran @BastienMazeran, Autodesk Inc.
This project is licensed under the MIT License - see the LICENSE file for details.
This code came from GITHUB-Express-Lambda
More information on Express/Serverless can be found here: Running Express Apps in AWS Lambda
The package.json was modified from here: Package.json
Inspired by this blog post, by Philippe Leefsma.