goofy_face.graph revision d979079aa0735beb302dd58797af0c6b600edfea
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 previewSurface;
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 SurfaceTargetFilter display {
81  surface = $previewSurface;
82  owidth = $previewWidth;
83  oheight = $previewHeight;
84}
85
86// Orientation rotation filter
87@filter FixedRotationFilter rotate {
88    rotation = 0;
89}
90
91// Orientation rotation filter for facemeta data
92@filter FaceMetaFixedRotationFilter metarotate {
93    rotation = 0;
94}
95
96
97// Recording output
98@filter MediaEncoderFilter recorder {
99  recordingProfile = $recordingProfile;
100  recordingDoneListener = $recordingDoneListener;
101  recording = false;
102  // outputFile, orientationHint, inputRegion,
103  // audioSource, listeners, captureRate
104  // will be set when recording starts
105}
106
107// Connections -----------------------------------------------
108// camera -> faceTracker
109@connect source[video] => rotate[image];
110@connect rotate[image] => toPackedGray[image];
111@connect toPackedGray[image] => faceTracker[image];
112// camera -> goofy
113@connect source[video] => goofyrenderer[image];
114// faceTracker -> metarotate -> goofy
115@connect faceTracker[faces] => metarotate[faces];
116@connect metarotate[faces] => goofyrenderer[faces];
117// goofy -> display out
118@connect goofyrenderer[outimage] => display[frame];
119// goofy -> record
120@connect goofyrenderer[outimage] => recorder[videoframe];
121