Skip to content

Commit

Permalink
Removed the face detection sample code and the unit test (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
happyhuman authored Apr 26, 2018
1 parent 35f5c8e commit 1010dce
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 81 deletions.
72 changes: 0 additions & 72 deletions video-intelligence/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,6 @@

'use strict';

function analyzeFaces(gcsUri) {
// [START analyze_faces]
// Imports the Google Cloud Video Intelligence library
const video = require('@google-cloud/video-intelligence').v1;

// Creates a client
const client = new video.VideoIntelligenceServiceClient();

/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// const gcsUri = 'GCS URI of the video to analyze, e.g. gs://my-bucket/my-video.mp4';

const request = {
inputUri: gcsUri,
features: ['FACE_DETECTION'],
};

// Detects faces in a video
client
.annotateVideo(request)
.then(results => {
const operation = results[0];
console.log('Waiting for operation to complete...');
return operation.promise();
})
.then(results => {
// Gets faces
const faces = results[0].annotationResults[0].faceAnnotations;
faces.forEach((face, faceIdx) => {
console.log(`Face #${faceIdx}`);
console.log(`\tThumbnail size: ${face.thumbnail.length}`);
face.segments.forEach((segment, segmentIdx) => {
segment = segment.segment;
if (segment.startTimeOffset.seconds === undefined) {
segment.startTimeOffset.seconds = 0;
}
if (segment.startTimeOffset.nanos === undefined) {
segment.startTimeOffset.nanos = 0;
}
if (segment.endTimeOffset.seconds === undefined) {
segment.endTimeOffset.seconds = 0;
}
if (segment.endTimeOffset.nanos === undefined) {
segment.endTimeOffset.nanos = 0;
}
console.log(`\tAppearance #${segmentIdx}:`);
console.log(
`\t\tStart: ${segment.startTimeOffset.seconds}` +
`.${(segment.startTimeOffset.nanos / 1e6).toFixed(0)}s`
);
console.log(
`\t\tEnd: ${segment.endTimeOffset.seconds}.` +
`${(segment.endTimeOffset.nanos / 1e6).toFixed(0)}s`
);
});
console.log(`\tLocations:`);
});
})
.catch(err => {
console.error('ERROR:', err);
});
// [END analyze_faces]
}

function analyzeLabelsGCS(gcsUri) {
// [START analyze_labels_gcs]
// Imports the Google Cloud Video Intelligence library
Expand Down Expand Up @@ -410,12 +345,6 @@ function analyzeVideoTranscription(gcsUri) {

require(`yargs`)
.demand(1)
.command(
`faces <gcsUri>`,
`Analyzes faces in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
{},
opts => analyzeFaces(opts.gcsUri)
)
.command(
`shots <gcsUri>`,
`Analyzes shot angles in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
Expand Down Expand Up @@ -446,7 +375,6 @@ require(`yargs`)
{},
opts => analyzeVideoTranscription(opts.gcsUri)
)
.example(`node $0 faces gs://demomaker/larry_sergey_ice_bucket_short.mp4`)
.example(`node $0 shots gs://demomaker/sushi.mp4`)
.example(`node $0 labels-gcs gs://demomaker/tomatoes.mp4`)
.example(`node $0 labels-file cat.mp4`)
Expand Down
9 changes: 0 additions & 9 deletions video-intelligence/system-test/analyze.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ const url = `gs://nodejs-docs-samples-video/quickstart.mp4`;
const shortUrl = `gs://nodejs-docs-samples-video/quickstart_short.mp4`;
const file = `resources/cat.mp4`;

// analyze_faces
// This is under whitelist and therefore will fail in most circumstances.
test.skip(`should analyze faces in a GCS file`, async t => {
const output = await tools.runAsync(`${cmd} faces ${url}`, cwd);
t.regex(output, /Thumbnail size: \d+/);
t.regex(output, /Start:.*\d+\.\d+s/);
t.regex(output, /End:.*\d+\.\d+s/);
});

// analyze_labels_gcs (one scene)
test.serial(`should analyze labels in a GCS file with one scene`, async t => {
const output = await tools.runAsync(`${cmd} labels-gcs ${shortUrl}`, cwd);
Expand Down

0 comments on commit 1010dce

Please sign in to comment.