-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawing the bounding boxes on detection #46
Comments
Try this code, i am using another class which has the model, you just need to put the model here and load the model.
|
can you provide me with the loadercontroller and screenpreview code? |
Hello! Thank you for reaching out. It looks like you're making great progress with your Flutter app using Ultralytics YOLO. Unfortunately, I can't provide specific code for LoaderControllerThe import 'package:ultralytics_yolo/ultralytics_yolo.dart';
class LoaderController {
static YoloModel? model;
static Future<void> loadModel() async {
model = LocalYoloModel(
id: 'your_model_id',
modelPath: 'assets/model/BILI.tflite',
task: Task.detect,
format: Format.tflite,
metadataPath: 'assets/metadata/metadata.yaml',
);
await model!.load();
}
} ScreenPreviewThe import 'package:flutter/material.dart';
class ScreenPreview extends StatelessWidget {
const ScreenPreview({Key? key}) : super(key: key);
@hafidhhusna
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Screen Preview'),
),
body: Center(
child: Text('This is the screen preview.'),
),
);
}
} IntegrationMake sure to initialize the void main() async {
WidgetsFlutterBinding.ensureInitialized();
await LoaderController.loadModel();
runApp(const LiveView());
} If you encounter any issues, please ensure you are using the latest versions of the Ultralytics packages. If the problem persists, feel free to share more details, and we can troubleshoot further together. Happy coding! 😊 |
i have the problem on the bounding boxes not drawn when i tried to run the inference on my flutter app code
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:ultralytics_yolo/predict/detect/detect.dart';
import 'package:ultralytics_yolo/ultralytics_yolo.dart';
import 'package:ultralytics_yolo/yolo_model.dart';
class ScanController extends StatefulWidget {
const ScanController({super.key});
@OverRide
State createState() => _ScanControllerState();
}
class _ScanControllerState extends State {
final controller = UltralyticsYoloCameraController();
bool _cameraPermissionGranted = false;
ObjectDetector? predictor;
@OverRide
void initState() {
super.initState();
_checkCameraPermission();
}
Future _checkCameraPermission() async {
try {
final cameraStatus = await Permission.camera.status;
print('Initial Camera status: $cameraStatus');
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: !_cameraPermissionGranted
? Center(child: Text('Camera permission not granted'))
: FutureBuilder(
future: _initObjectDetector(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
print('Error initializing detector: ${snapshot.error}');
return Center(child: Text('Error initializing detector: ${snapshot.error}'));
}
}
Future _initObjectDetector() async {
final model = LocalYoloModel(
id: '',
modelPath: 'assets/model/BILI.tflite',
task: Task.classify,
format: Format.tflite,
metadataPath: 'assets/metadata/metadata.yaml',
);
}
}
class Times extends StatelessWidget {
final double? inferenceTime;
final double? fpsRate;
const Times({
Key? key,
required this.inferenceTime,
required this.fpsRate,
}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
return Positioned(
bottom: 10,
left: 10,
child: Column(
children: [
Text('Inference Time: ${inferenceTime?.toStringAsFixed(2) ?? 'N/A'} ms'),
Text('FPS Rate: ${fpsRate?.toStringAsFixed(2) ?? 'N/A'}'),
],
),
);
}
}
The text was updated successfully, but these errors were encountered: