1//
2// Copyright (C) 2011 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// Imports ---------------------------------------------------
18@import android.filterpacks.videosrc;
19@import android.filterpacks.videosink;
20@import android.filterpacks.ui;
21@import android.filterpacks.base;
22@import android.filterpacks.imageproc;
23
24@import com.google.android.filterpacks.facedetect;
25
26@setting autoBranch = "synced";
27
28// Externals -------------------------------------------------
29
30@external textureSourceCallback;
31@external recordingWidth;
32@external recordingHeight;
33@external recordingProfile;
34@external recordingDoneListener;
35
36@external previewSurfaceTexture;
37@external previewWidth;
38@external previewHeight;
39
40// Not used by this graph, but simplifies higher-level
41// graph initialization code.
42@external orientation;
43
44// Filters ---------------------------------------------------
45
46// Camera input
47@filter SurfaceTextureSource source {
48  sourceListener = $textureSourceCallback;
49  width = $recordingWidth;
50  height = $recordingHeight;
51  closeOnTimeout = true;
52}
53
54// Face detection
55@filter ToPackedGrayFilter toPackedGray {
56  owidth = 320;
57  oheight = 240;
58  keepAspectRatio = true;
59}
60
61@filter MultiFaceTrackerFilter faceTracker {
62  numChannelsDetector = 3;
63  quality = 0.0f;
64  smoothness = 0.2f;
65  minEyeDist = 25.0f;
66  rollRange = 45.0f;
67  numSkipFrames = 9;
68  trackingError = 1.0;
69  mouthOnlySmoothing = 0;
70  useAffineCorrection = 1;
71  patchSize = 15;
72}
73
74// Goofyface
75@filter GoofyFastRenderFilter goofyrenderer {
76  distortionAmount = 1.0;
77}
78
79// Display output
80@filter SurfaceTextureTarget display {
81  surfaceTexture = $previewSurfaceTexture;
82  width = $previewWidth;
83  height = $previewHeight;
84  renderMode = "stretch";
85}
86
87// Orientation rotation filter
88@filter FixedRotationFilter rotate {
89    rotation = 0;
90}
91
92// Orientation rotation filter for facemeta data
93@filter FaceMetaFixedRotationFilter metarotate {
94    rotation = 0;
95}
96
97
98// Recording output
99@filter MediaEncoderFilter recorder {
100  recordingProfile = $recordingProfile;
101  recordingDoneListener = $recordingDoneListener;
102  recording = false;
103  width = $recordingWidth;
104  height = $recordingHeight;
105  // outputFile, orientationHint, inputRegion,
106  // audioSource, listeners, captureRate
107  // will be set when recording starts
108}
109
110// Connections -----------------------------------------------
111// camera -> faceTracker
112@connect source[video] => rotate[image];
113@connect rotate[image] => toPackedGray[image];
114@connect toPackedGray[image] => faceTracker[image];
115// camera -> goofy
116@connect source[video] => goofyrenderer[image];
117// faceTracker -> metarotate -> goofy
118@connect faceTracker[faces] => metarotate[faces];
119@connect metarotate[faces] => goofyrenderer[faces];
120// goofy -> display out
121@connect goofyrenderer[outimage] => display[frame];
122// goofy -> record
123@connect goofyrenderer[outimage] => recorder[videoframe];
124