Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change request type on certain inspection type #857

Merged
merged 1 commit into from
Sep 20, 2017
Merged
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
43 changes: 21 additions & 22 deletions video/cloud-client/src/main/java/com/example/video/Detect.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,9 @@ public static void analyzeFaces(String gcsUri) throws Exception {
// [START detect_faces]
// Instantiate a com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient
try (VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.create()) {
// detect shot and frame
LabelDetectionConfig labelDetectionConfig = LabelDetectionConfig.newBuilder()
.setLabelDetectionMode(LabelDetectionMode.SHOT_AND_FRAME_MODE)
.build();

VideoContext videoContext = VideoContext.newBuilder()
.setLabelDetectionConfig(labelDetectionConfig)
.build();

AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder()
.setInputUri(gcsUri)
.setVideoContext(videoContext)
.addFeatures(Feature.LABEL_DETECTION)
.addFeatures(Feature.FACE_DETECTION)
.build();

// asynchronously perform facial analysis on videos
Expand All @@ -140,17 +130,26 @@ public static void analyzeFaces(String gcsUri) throws Exception {
+ segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
System.out.printf("Segment location : %.3f:%.3f\n", startTime, endTime);
}
// printing info on the first frame
FaceFrame frame = faceAnnotation.getFrames(0);
double timeOffset = frame.getTimeOffset().getSeconds()
+ frame.getTimeOffset().getNanos() / 1e9;
System.out.printf("First frame time offset: %.3fs", timeOffset);
// print info on the first normalized bounding box
NormalizedBoundingBox box = frame.getNormalizedBoundingBoxesList().get(0);
System.out.printf("Left: %.3f\n", box.getLeft());
System.out.printf("Top: %.3f\n", box.getTop());
System.out.printf("Bottom: %.3f\n", box.getBottom());
System.out.printf("Right: %.3f\n", box.getRight());
try {
// printing info on the first frame
if (faceAnnotation.getFramesCount() > 0) {
System.out.println(faceAnnotation.getFramesList().get(0));
FaceFrame frame = faceAnnotation.getFrames(0);
double timeOffset = frame.getTimeOffset().getSeconds()
+ frame.getTimeOffset().getNanos() / 1e9;
System.out.printf("First frame time offset: %.3fs", timeOffset);
// print info on the first normalized bounding box
NormalizedBoundingBox box = frame.getNormalizedBoundingBoxesList().get(0);
System.out.printf("Left: %.3f\n", box.getLeft());
System.out.printf("Top: %.3f\n", box.getTop());
System.out.printf("Bottom: %.3f\n", box.getBottom());
System.out.printf("Right: %.3f\n", box.getRight());
} else {
System.out.println("No frames found in annotation");
}
} catch (IndexOutOfBoundsException ioe) {
System.out.println("Could not retrieve frame: " + ioe.getMessage());
}
}
}
if (!faceFound) {
Expand Down