Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Cos #72

Merged
merged 5 commits into from
Apr 13, 2018
Merged

Cos #72

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bluemix/deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"type": "string"
},
"darkvision-region": {
"description": "The bluemix region",
"description": "The IBM Cloud region",
"type": "string"
},
"darkvision-organization": {
"description": "The bluemix org",
"description": "The Cloud Foundry org",
"type": "string"
},
"darkvision-space": {
"description": "The bluemix space",
"description": "The Cloud Foundry space",
"type": "string"
},
"darkvision-app-name": {
Expand Down
2 changes: 0 additions & 2 deletions .bluemix/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ stages:
type: secure
- name: CLOUDANT_db
value: ${CLOUDANT_db}
- name: OPENWHISK_API_HOST
value: "openwhisk.ng.bluemix.net"
- name: DOCKER_EXTRACTOR_NAME
value: "l2fprod/darkvision-extractor-master"
- name: WATSON_API_KEY
Expand Down
10 changes: 5 additions & 5 deletions DEPLOY_MANUALLY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deploy Dark Vision manually in Bluemix
# Deploy Dark Vision manually in IBM Cloud

## Get the code

Expand All @@ -10,12 +10,12 @@

* or Download and extract the source code from [this archive](https://github.com/IBM-Cloud/openwhisk-darkvisionapp/archive/master.zip)

## Create the Bluemix Services
## Create the IBM Cloud Services

***Note***: *if you have existing instances of these services, you don't need to create new instances.
You can simply reuse the existing ones.*

1. Open the IBM Bluemix console
1. Open the IBM Cloud console

1. Create a Cloudant NoSQL DB service instance named **cloudant-for-darkvision**

Expand Down Expand Up @@ -46,13 +46,13 @@ visualize the results of each frame analysis.

1. If you configured a Cloud Object Storage service, make sure to add its name to the list of services in the **manifest.yml** *services* section or to uncomment the existing **cloudobjectstorage-for-darkvision** entry.

1. Push the application to Bluemix:
1. Push the application to IBM Cloud:

```
bx cf push --nostart
```

1. By default, anyone can upload/delete/reset videos and images. You can restrict access to these actions by defining the environment variables *ADMIN_USERNAME* and *ADMIN_PASSWORD* on your application. This can be done in the Bluemix console or with the command line:
1. By default, anyone can upload/delete/reset videos and images. You can restrict access to these actions by defining the environment variables *ADMIN_USERNAME* and *ADMIN_PASSWORD* on your application. This can be done in the IBM Cloud console or with the command line:

```
bx cf set-env openwhisk-darkvision ADMIN_USERNAME admin
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Dark Vision is an application that processes videos to discover what's inside of

## Overview and Architecture

Built using IBM Bluemix, the application uses:
Built using IBM Cloud, the application uses:
* [Visual Recognition](https://console.bluemix.net/catalog/services/watson_vision_combined)
* [Speech to Text](https://console.bluemix.net/catalog/services/speech_to_text)
* [Natural Language Understanding](https://console.bluemix.net/catalog/services/natural-language-understanding)
Expand Down Expand Up @@ -163,20 +163,20 @@ audio_analysis

## Prerequisites

* IBM Bluemix account. [Sign up][bluemix_signup_url] for Bluemix, or use an existing account.
* IBM Cloud account. [Sign up][bluemix_signup_url] for Bluemix, or use an existing account.
* Docker Hub account. [Sign up](https://hub.docker.com/) for Docker Hub, or use an existing account.
* Node.js >= 6.9.1
* XCode 8.0, iOS 10, Swift 3 (For iOS application)

## Deploying Dark Vision automatically in Bluemix
## Deploying Dark Vision automatically in IBM Cloud

Dark Vision comes with a default toolchain you can use to deploy the solution with few clicks. If you want to deploy it manually, you can skip this section.

1. **Ensure your organization has enough quota for one web application using 256MB of memory and 4 services.**

1. Click ***Deploy to Bluemix*** to start the Bluemix DevOps wizard:
1. Click ***Deploy to IBM Cloud*** to start the IBM Cloud DevOps wizard:

[![Deploy to Bluemix](https://console.bluemix.net/devops/graphics/create_toolchain_button.png)](https://console.ng.bluemix.net/devops/setup/deploy/?repository=https%3A%2F%2Fgit.luolix.top/IBM-Cloud/openwhisk-darkvisionapp)
[![Deploy to IBM Cloud](https://console.bluemix.net/devops/graphics/create_toolchain_button.png)](https://console.bluemix.net/devops/setup/deploy/?repository=https%3A%2F%2Fgit.luolix.top/IBM-Cloud/openwhisk-darkvisionapp)

1. Select the **GitHub** box.

Expand Down Expand Up @@ -206,7 +206,7 @@ Dark Vision comes with a default toolchain you can use to deploy the solution wi

1. Access the Dark Vision app when it's ready and start uploading videos and images!

## Deploying Dark Vision manually in Bluemix
## Deploying Dark Vision manually in IBM Cloud

The automatic approach should be the best option for most users as it does everything for you automatically. But if you want to go through all the steps manually or if you want to run the web application locally we've got your covered. Follow [these instructions](./DEPLOY_MANUALLY.md).

Expand Down Expand Up @@ -262,7 +262,7 @@ The web app exposes an API to list all videos and retrieve the results.

### Cloud Functions - Frame extraction

The **frame extractor** runs as a Docker action created with the [Cloud Functions Docker SDK](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_reference.html#openwhisk_ref_docker):
The **frame extractor** runs as a Docker action created with the [Cloud Functions Docker SDK](https://console.bluemix.net/docs/openwhisk/openwhisk_reference.html#openwhisk_ref_docker):
* It uses *ffmpeg* to extract frames and audio from the video.
* It is written as a nodejs app to benefit from several nodejs helper packages (Cloudant, ffmpeg, imagemagick)

Expand Down Expand Up @@ -353,7 +353,7 @@ cf logs <appname>
```
to look at the live logs for the web application

[bluemix_signup_url]: https://console.ng.bluemix.net/?cm_mmc=GitHubReadMe
[bluemix_signup_url]: https://console.bluemix.net/?cm_mmc=GitHubReadMe

## License

Expand Down
27 changes: 15 additions & 12 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,14 @@ app.get('/images/:type/:id.jpg', (req, res) => {
const mediaStream = mediaStorage.read(req.params.id, `${req.params.type}.jpg`);
const imageFile = fs.createWriteStream(imageFilename);

let flow = mediaStream.on('response', (response) => {
mediaStream.on('response', (response) => {
// get the image from the storage
if (response.statusCode !== 200) {
res.status(response.statusCode).send({ ok: false });
}
});

if (!mediaStorage.fileStore) {
flow = flow.pipe(imageFile);
}

flow = flow.on('error', (err) => {
})
.pipe(imageFile)
.on('error', (err) => {
console.log('Can not cache image', err);
res.status(500).send({ ok: false });
})
Expand All @@ -201,13 +197,20 @@ app.get('/images/:type/:id.jpg', (req, res) => {
res.sendFile(imageFilename);
imageCache.set(cacheKey, true);
});

if (mediaStorage.fileStore) {
flow.pipe(imageFile);
}
}
});

/**
* Returns the video attachment for embedded player
*/
app.get('/videos/stream/:id.mp4', (req, res) => {
const mediaStream = mediaStorage.read(req.params.id, 'video.mp4');
mediaStream.pipe(res).on('error', (err) => {
console.log('Can not read video', err);
res.status(500).send({ ok: false });
});
});

/**
* Returns all standalone images (images not linked to a video)
*/
Expand Down
5 changes: 1 addition & 4 deletions web/lib/cloudobjectstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ function CloudObjectStorage(cosConfig, initializeStorageCallback) {
self.read = function(filename) {
console.log('[cloudobjectstorage]', 'Read', filename);

return self.cos.getObject({
Bucket: self.bucket,
Key: filename
}).createReadStream();
return require('request').get(`${self.storageUrl()}/${filename}`);
};

self.delete = function(filename, callback) {
Expand Down
2 changes: 1 addition & 1 deletion web/public/routes/upload-dialog.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>Upload</h2>
Dark Vision supports video files (.mp4) or images.
The upload might be password-protected.
If you don't have the permissions to upload in this application,
you can <a target="_blank" href="https://console.ng.bluemix.net/devops/setup/deploy/?repository=https%3A//github.com/IBM-Cloud/openwhisk-darkvisionapp">deploy your own copy of Dark Vision</a>.
you can <a target="_blank" href="https://console.bluemix.net/devops/setup/deploy/?repository=https%3A//github.com/IBM-Cloud/openwhisk-darkvisionapp">deploy your own copy of Dark Vision</a>.
</p>

<md-input-container layout="row" layout-align="none center">
Expand Down