goofy_face.graph revision caf8466dcdf6d6c496e46961bb3132126363ef83
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@external audioSource;
36
37@external previewSurface;
38@external previewWidth;
39@external previewHeight;
40
41// Not used by this graph, but simplifies higher-level
42// graph initialization code.
43@external orientation;
44
45// Filters ---------------------------------------------------
46
47// Camera input
48@filter SurfaceTextureSource source {
49  sourceListener = $textureSourceCallback;
50  width = $recordingWidth;
51  height = $recordingHeight;
52  closeOnTimeout = true;
53}
54
55// Face detection
56@filter ToPackedGrayFilter toPackedGray {
57  owidth = 320;
58  oheight = 240;
59  keepAspectRatio = true;
60}
61
62@filter MultiFaceTrackerFilter faceTracker {
63  numChannelsDetector = 3;
64  quality = 0.0f;
65  smoothness = 0.2f;
66  minEyeDist = 25.0f;
67  rollRange = 45.0f;
68  numSkipFrames = 9;
69  trackingError = 1.0;
70  mouthOnlySmoothing = 0;
71  useAffineCorrection = 1;
72  patchSize = 15;
73}
74
75// Goofyface
76@filter GoofyFastRenderFilter goofyrenderer {
77  distortionAmount = 1.0;
78}
79
80// Display output
81@filter SurfaceTargetFilter display {
82  surface = $previewSurface;
83  owidth = $previewWidth;
84  oheight = $previewHeight;
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  audioSource = $audioSource;
101  recordingProfile = $recordingProfile;
102  recordingDoneListener = $recordingDoneListener;
103  recording = false;
104  // outputFile, orientationHint, inputRegion, listeners
105  // will be set when recording starts
106}
107
108// Connections -----------------------------------------------
109// camera -> faceTracker
110@connect source[video] => rotate[image];
111@connect rotate[image] => toPackedGray[image];
112@connect toPackedGray[image] => faceTracker[image];
113// camera -> goofy
114@connect source[video] => goofyrenderer[image];
115// faceTracker -> metarotate -> goofy
116@connect faceTracker[faces] => metarotate[faces];
117@connect metarotate[faces] => goofyrenderer[faces];
118// goofy -> display out
119@connect goofyrenderer[outimage] => display[frame];
120// goofy -> record
121@connect goofyrenderer[outimage] => recorder[videoframe];
122