Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.makan.face_auth_flutter"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.makan.face_auth_flutter">
<application
android:label="face_auth_flutter"
android:label="Metro Face Recognition"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Binary file added assets/icon/metro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/metro2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:camera/camera.dart';
import 'package:face_auth_flutter/page/face_recognition/camera_page.dart';
import 'package:face_auth_flutter/page/login_page.dart';
import 'package:face_auth_flutter/page/detection.dart';
import 'package:face_auth_flutter/utils/local_db.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -26,6 +26,6 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) => const MaterialApp(
debugShowCheckedModeBanner: false,
title: "Face Auth",
home: LoginPage(),
home: Detection(),
);
}
26 changes: 10 additions & 16 deletions lib/page/login_page.dart → lib/page/detection.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import 'package:face_auth_flutter/page/face_recognition/camera_page.dart';
import 'package:face_auth_flutter/page/login_view.dart';
import 'package:face_auth_flutter/utils/local_db.dart';
import 'package:flutter/material.dart';

import '../utils/utils.dart';

class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key);
class Detection extends StatefulWidget {
const Detection({Key? key}) : super(key: key);

@override
State<LoginPage> createState() => _LoginPageState();
State<Detection> createState() => _DetectionState();
}

class _LoginPageState extends State<LoginPage> {
class _DetectionState extends State<Detection> {
@override
void initState() {
printIfDebug(LocalDB.getUser().name);
Expand All @@ -21,8 +22,8 @@ class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text("Face Authentication"),
centerTitle: true,
backgroundColor: Colors.transparent,
title: Image.asset("assets/metro2.png"),
),
body: Padding(
padding: const EdgeInsets.all(32),
Expand All @@ -34,23 +35,15 @@ class _LoginPageState extends State<LoginPage> {
text: 'Register',
icon: Icons.app_registration_rounded,
onClicked: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const FaceScanScreen()));
Navigator.push(context, MaterialPageRoute(builder: (context) => const FaceScanScreen()));
},
),
const SizedBox(height: 24),
buildButton(
text: 'Login',
icon: Icons.login,
onClicked: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FaceScanScreen(
user: LocalDB.getUser(),
)));
Navigator.push(context, MaterialPageRoute(builder: (context) => const LoginView()));
},
),
],
Expand All @@ -66,6 +59,7 @@ class _LoginPageState extends State<LoginPage> {
}) =>
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black26,
minimumSize: const Size.fromHeight(50),
),
icon: Icon(icon, size: 26),
Expand Down
31 changes: 9 additions & 22 deletions lib/page/face_recognition/camera_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {

Future<void> detectFacesFromImage(CameraImage image) async {
InputImageData _firebaseImageMetadata = InputImageData(
imageRotation: rotationIntToImageRotation(
_cameraController.description.sensorOrientation),
imageRotation: rotationIntToImageRotation(_cameraController.description.sensorOrientation),
inputImageFormat: InputImageFormat.BGRA8888,
size: Size(image.width.toDouble(), image.height.toDouble()),
planeData: image.planes.map(
Expand Down Expand Up @@ -78,10 +77,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
await detectFacesFromImage(image);
if (facesDetected.isNotEmpty) {
User? user = await _mlService.predict(
image,
facesDetected[0],
widget.user != null,
widget.user != null ? widget.user!.name! : controller.text);
image, facesDetected[0], widget.user != null, widget.user != null ? widget.user!.name! : controller.text);
if (widget.user == null) {
// register case
Navigator.pop(context);
Expand All @@ -92,8 +88,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
Navigator.pop(context);
print("Unknown User");
} else {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const HomePage()));
Navigator.push(context, MaterialPageRoute(builder: (context) => const HomePage()));
}
}
}
Expand All @@ -108,10 +103,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
file = XFile(file.path);
_cameraController.setFlashMode(FlashMode.off);
} else {
showDialog(
context: context,
builder: (context) =>
const AlertDialog(content: Text('No face detected!')));
showDialog(context: context, builder: (context) => const AlertDialog(content: Text('No face detected!')));
}
}

Expand Down Expand Up @@ -144,24 +136,20 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: isControllerInitialized
? CameraPreview(_cameraController)
: null),
child: isControllerInitialized ? CameraPreview(_cameraController) : null),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(bottom: 100),
child: Lottie.asset("assets/loading.json",
width: MediaQuery.of(context).size.width * 0.7),
child: Lottie.asset("assets/loading.json", width: MediaQuery.of(context).size.width * 0.7),
),
),
TextField(
controller: controller,
decoration: const InputDecoration(
fillColor: Colors.white, filled: true),
decoration: const InputDecoration(fillColor: Colors.white, filled: true),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -172,7 +160,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
text: "Capture",
context: context,
isClickable: true,
onTap: (){
onTap: () {
bool canProcess = false;
_cameraController.startImageStream((CameraImage image) async {
if (canProcess) return;
Expand All @@ -195,8 +183,7 @@ class _FaceScanScreenState extends State<FaceScanScreen> {
flash = !flash;
});
flash
? _cameraController
.setFlashMode(FlashMode.torch)
? _cameraController.setFlashMode(FlashMode.torch)
: _cameraController.setFlashMode(FlashMode.off);
}),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/page/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:face_auth_flutter/page/login_page.dart';
import 'package:face_auth_flutter/page/detection.dart';
import 'package:face_auth_flutter/utils/local_db.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -37,7 +37,7 @@ class HomePage extends StatelessWidget {
style: TextStyle(fontSize: 20),
),
onPressed: () => Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const LoginPage()),
MaterialPageRoute(builder: (context) => const Detection()),
),
);
}
67 changes: 67 additions & 0 deletions lib/page/login_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:face_auth_flutter/page/face_recognition/camera_page.dart';
import 'package:flutter/material.dart';

class LoginView extends StatefulWidget {
const LoginView({
Key? key,
}) : super(key: key);

@override
State<LoginView> createState() => _LoginViewState();
}

class _LoginViewState extends State<LoginView> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SizedBox(
height: 500,
child: Column(
children: [
const Padding(
padding: EdgeInsets.all(8.0),
child: CustomText(text: "İsim"),
),
const Padding(
padding: EdgeInsets.all(8.0),
child: CustomText(text: "Soyisim"),
),
const Padding(
padding: EdgeInsets.all(8.0),
child: CustomText(text: "Sicil No"),
),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const FaceScanScreen(),
));
},
child: const Text("Giriş Yap"))
],
),
),
),
);
}
}

class CustomText extends StatelessWidget {
final String text;
const CustomText({
Key? key,
required this.text,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return TextField(
decoration: InputDecoration(
labelText: text,
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.black)),
errorBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.black))),
);
}
}
Loading