Comments (17)
Can you share your code please? @RobbyGit
from facerecognitionauth.
@SiddharthOza00 I had the same issue no face is detected on sign up but on the sign in everything seems fine. This is the sign-up.dart file.
import 'dart:async';
import 'dart:io';
import 'dart:math' as math;
import 'package:face_net_authentication/locator.dart';
import 'package:face_net_authentication/pages/widgets/FacePainter.dart';
import 'package:face_net_authentication/pages/widgets/auth-action-button.dart';
import 'package:face_net_authentication/pages/widgets/camera_header.dart';
import 'package:face_net_authentication/services/camera.service.dart';
import 'package:face_net_authentication/services/ml_service.dart';
import 'package:face_net_authentication/services/face_detector_service.dart';
import 'package:camera/camera.dart';
import 'package:google_ml_kit/google_ml_kit.dart';
import 'package:flutter/material.dart';
class SignUp extends StatefulWidget {
const SignUp({Key key}) : super(key: key);
@override
SignUpState createState() => SignUpState();
}
class SignUpState extends State<SignUp> {
String imagePath;
Face faceDetected;
Size imageSize;
bool _detectingFaces = false;
bool pictureTaken = false;
bool _initializing = false;
bool _saving = false;
bool _bottomSheetVisible = false;
// service injection
FaceDetectorService _faceDetectorService = locator<FaceDetectorService>();
CameraService _cameraService = locator<CameraService>();
MLService _mlService = locator<MLService>();
@override
void initState() {
super.initState();
_start();
}
@override
void dispose() {
_cameraService.dispose();
super.dispose();
}
_start() async {
setState(() => _initializing = true);
await _cameraService.initialize();
setState(() => _initializing = false);
_frameFaces();
}
Future<void> onShot() async {
if (faceDetected == null) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text('No face detected!'),
);
},
);
return false;
} else {
_saving = true;
await Future.delayed(Duration(milliseconds: 500));
await _cameraService.cameraController.stopImageStream();
await Future.delayed(Duration(milliseconds: 200));
XFile file = await _cameraService.takePicture();
imagePath = file.path;
setState(() {
_bottomSheetVisible = true;
pictureTaken = true;
});
return true;
}
}
_frameFaces() {
imageSize = _cameraService.getImageSize();
_cameraService.cameraController.startImageStream((image) async {
if (_cameraService.cameraController != null) {
if (_detectingFaces) return;
_detectingFaces = true;
try {
await _faceDetectorService.detectFacesFromImage(image);
if (_faceDetectorService.faces.isNotEmpty) {
if (_saving) {
_mlService.setCurrentPrediction(image, faceDetected);
setState(() {
_saving = false;
});
}
} else {
setState(() {
faceDetected = null;
});
}
_detectingFaces = false;
} catch (e) {
print(e);
_detectingFaces = false;
}
}
});
}
_onBackPressed() {
Navigator.of(context).pop();
}
_reload() {
setState(() {
_bottomSheetVisible = false;
pictureTaken = false;
});
this._start();
}
@override
Widget build(BuildContext context) {
final double mirror = math.pi;
final width = MediaQuery.of(context).size.width;
final height = MediaQuery.of(context).size.height;
Widget body;
if (_initializing) {
body = Center(
child: CircularProgressIndicator(),
);
}
if (!_initializing && pictureTaken) {
body = Container(
width: width,
height: height,
child: Transform(
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.cover,
child: Image.file(File(imagePath)),
),
transform: Matrix4.rotationY(mirror)),
);
}
if (!_initializing && !pictureTaken) {
body = Transform.scale(
scale: 1.0,
child: AspectRatio(
aspectRatio: MediaQuery.of(context).size.aspectRatio,
child: OverflowBox(
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.fitHeight,
child: Container(
width: width,
height:
width * _cameraService.cameraController.value.aspectRatio,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
CameraPreview(_cameraService.cameraController),
CustomPaint(
painter:
FacePainter(face: faceDetected, imageSize: imageSize),
),
],
),
),
),
),
),
);
}
return Scaffold(
body: Stack(
children: [
body,
CameraHeader(
"SIGN UP",
onBackPressed: _onBackPressed,
)
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: !_bottomSheetVisible
? AuthActionButton(
onPressed: onShot,
isLogin: false,
reload: _reload,
)
: Container());
}
}
from facerecognitionauth.
I am getting these errors. Can someone help me? @RobbyGit @KALU-KELECHI-GABRIEL @guruhyes
from facerecognitionauth.
its because variable faceDetected not set in _frameFaces,
yo need to set faceDetected , see image below
file sign-up.dart
function _frameFaces()
I dunno its the right way or not, but its should work
from facerecognitionauth.
@guruhyes I added the line it still does not work as expected. If you could share your entire sign-up.dart file please.
from facerecognitionauth.
@SiddharthOza00 try setting ur android studio to point at the correct SDK version
follow the steps here
https://stackoverflow.com/questions/56938436/first-flutter-app-error-cannot-resolve-symbol-properties
from facerecognitionauth.
here is my code
`import 'dart:async';
import 'dart:io';
import 'dart:math' as math;
import 'package:face_net_authentication/locator.dart';
import 'package:face_net_authentication/pages/widgets/FacePainter.dart';
import 'package:face_net_authentication/pages/widgets/auth-action-button.dart';
import 'package:face_net_authentication/pages/widgets/camera_header.dart';
import 'package:face_net_authentication/services/camera.service.dart';
import 'package:face_net_authentication/services/ml_service.dart';
import 'package:face_net_authentication/services/face_detector_service.dart';
import 'package:camera/camera.dart';
import 'package:google_ml_kit/google_ml_kit.dart';
import 'package:flutter/material.dart';
class SignUp extends StatefulWidget {
const SignUp({Key key}) : super(key: key);
@OverRide
SignUpState createState() => SignUpState();
}
class SignUpState extends State {
String imagePath;
Face faceDetected;
Size imageSize;
bool _detectingFaces = false;
bool pictureTaken = false;
bool _initializing = false;
bool _saving = false;
bool _bottomSheetVisible = false;
// service injection
FaceDetectorService _faceDetectorService = locator();
CameraService _cameraService = locator();
MLService _mlService = locator();
@OverRide
void initState() {
super.initState();
_start();
}
@OverRide
void dispose() {
_cameraService.dispose();
super.dispose();
}
_start() async {
setState(() => _initializing = true);
await _cameraService.initialize();
setState(() => _initializing = false);
_frameFaces();
}
Future onShot() async {
if (faceDetected == null) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text('No face detected!'),
);
},
);
return false;
} else {
_saving = true;
await Future.delayed(Duration(milliseconds: 500));
//await _cameraService.cameraController.stopImageStream();
//await Future.delayed(Duration(milliseconds: 200));
XFile file = await _cameraService.takePicture();
imagePath = file.path;
setState(() {
_bottomSheetVisible = true;
pictureTaken = true;
});
return true;
}
}
_frameFaces() {
imageSize = _cameraService.getImageSize();
_cameraService.cameraController.startImageStream((image) async {
if (_cameraService.cameraController != null) {
if (_detectingFaces) return;
_detectingFaces = true;
try {
await _faceDetectorService.detectFacesFromImage(image);
if (_faceDetectorService.faces.isNotEmpty) {
setState(() {
faceDetected = _faceDetectorService.faces[0];
});
if (_saving) {
_mlService.setCurrentPrediction(image, faceDetected);
setState(() {
_saving = false;
});
}
} else {
setState(() {
faceDetected = null;
});
}
_detectingFaces = false;
} catch (e) {
print(e);
_detectingFaces = false;
}
}
});
}
_onBackPressed() {
Navigator.of(context).pop();
}
_reload() {
setState(() {
_bottomSheetVisible = false;
pictureTaken = false;
});
this._start();
}
@OverRide
Widget build(BuildContext context) {
final double mirror = math.pi;
final width = MediaQuery.of(context).size.width;
final height = MediaQuery.of(context).size.height;
Widget body;
if (_initializing) {
body = Center(
child: CircularProgressIndicator(),
);
}
if (!_initializing && pictureTaken) {
body = Container(
width: width,
height: height,
child: Transform(
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.cover,
child: Image.file(File(imagePath)),
),
transform: Matrix4.rotationY(mirror)),
);
}
if (!_initializing && !pictureTaken) {
body = Transform.scale(
scale: 1.0,
child: AspectRatio(
aspectRatio: MediaQuery.of(context).size.aspectRatio,
child: OverflowBox(
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.fitHeight,
child: Container(
width: width,
height:
width * _cameraService.cameraController.value.aspectRatio,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
CameraPreview(_cameraService.cameraController),
CustomPaint(
painter:
FacePainter(face: faceDetected, imageSize: imageSize),
),
],
),
),
),
),
),
);
}
return Scaffold(
body: Stack(
children: [
body,
CameraHeader(
"SIGN UP",
onBackPressed: _onBackPressed,
)
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: !_bottomSheetVisible
? AuthActionButton(
onPressed: onShot,
isLogin: false,
reload: _reload,
)
: Container());
}
}
`
from facerecognitionauth.
thanks a lot @guruhyes . This works just had to change the @OverRide to @OverRide. Thank you.
from facerecognitionauth.
@KALU-KELECHI-GABRIEL Can you show me where you updated this
from facerecognitionauth.
@RobbyGit I don't understand the question
from facerecognitionauth.
If you have the code on your github can you share your updated project with the latest changes? @KALU-KELECHI-GABRIEL
from facerecognitionauth.
@KALU-KELECHI-GABRIEL Sorry I didnt finish. I added the lines that @guruhyes suggested and it does now see a face but I get when I hit capture. What do you get .
CameraException(No camera is streaming images, stopImageStream was called when no camera is streaming images.)
from facerecognitionauth.
@KALU-KELECHI-GABRIEL . I commented out await _cameraService.cameraController.stopImageStream(); and now its working .. Have to see what else has broken
from facerecognitionauth.
@KALU-KELECHI-GABRIEL . I commented out await _cameraService.cameraController.stopImageStream(); and now its working .. Have to see what else has broken
Yes commented will work, take a look to my code function onShot()
from facerecognitionauth.
Can someone help me with the errors in the images I sent before?
from facerecognitionauth.
Can someone help me with the errors in the images I sent before?
I did check up
from facerecognitionauth.
Hi Guys, sorry for the late answer, I just updated the project to null safety. I'm going to work on the issues found later, thanks for contribuiting!
from facerecognitionauth.
Related Issues (20)
- App throw exception, Interpreter is null HOT 1
- Hey devs if any body is stuck don't worry click on the link.
- Face detected but drawing the painter in wrong place
- CameraException when capturing picture
- How can i sign up with image from gallery, not from camera ? HOT 1
- Can we use anti spoofing by image? HOT 1
- Face not detected! HOT 1
- It will recognize any face as User 1, as long as it detected as human face
- Mobilefacenet Output Size
- State Error (BadState: No Element) HOT 1
- error Declaration of 'MLKTextRecognizedLanguage' when running on IOS
- no green square HOT 1
- Creating reusable library for just the services?
- it will log in anyone HOT 1
- When i using Android Emulator build app and it going to the splash screen and ask permission after i click the app is Lost connection to device . HOT 4
- Update Image package HOT 2
- [error] Failed to lookup symbol 'TFLGpuDelegateCreate' on IoS HOT 2
- No Face Detection
- Null check operator used on a null value while I pressed SignIn
- Camera service null issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facerecognitionauth.