Skip to content

Instantly share code, notes, and snippets.

@Wizpna
Last active July 11, 2021 01:32
Show Gist options
  • Save Wizpna/887f75d5c7bc603b8bf83787aefff51b to your computer and use it in GitHub Desktop.
Save Wizpna/887f75d5c7bc603b8bf83787aefff51b to your computer and use it in GitHub Desktop.
A simple project demonstrating how to build a face filter app using Flutter and Deep AR
import 'package:rwa_deep_ar/rwa_deep_ar.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
CameraDeepArController cameraDeepArController;
int currentPage = 0;
final vp = PageController(viewportFraction: .24);
Effects currentEffect = Effects.none;
Filters currentFilter = Filters.none;
Masks currentMask = Masks.none;
bool isRecording = false;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Stack(
children: [
CameraDeepAr(
onCameraReady: (isReady) {
print("Camera status $isReady");
},
onImageCaptured: (path) {
print("Image Taken $path");
},
onVideoRecorded: (path) {
print("Video Recorded @ $path");
},
//Enter the App key generate from Deep AR
androidLicenceKey:
"d8e8fde709fb2f6823a48d407ad860c09dd2c5a0b874db5282d0af664d3d1516a87a88a213259f9f",
iosLicenceKey:
"53618212114fc16bbd7499c0c04c2ca11a4eed188dc20ed62a7f7eec02b41cb34d638e72945a6bf6",
cameraDeepArCallback: (c) async {
cameraDeepArController = c;
setState(() {});
}),
Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: EdgeInsets.fromLTRB(20, 0, 20, 5),
//height: 250,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: List.generate(Masks.values.length, (p) {
bool active = currentPage == p;
return GestureDetector(
onTap: () {
currentPage = p;
cameraDeepArController.changeMask(p);
setState(() {});
},
child: Container(
margin: EdgeInsets.all(5),
width: active ? 40 : 30,
height: active ? 50 : 40,
alignment: Alignment.center,
decoration: BoxDecoration(
color:
active ? Colors.green : Colors.white,
shape: BoxShape.circle),
child: Text(
"$p",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: active ? 16 : 14,
color: Colors.black, fontWeight: FontWeight.w800),
)),
);
}),
),
)
],
),
),
)
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment