Skip to content

Commit

Permalink
cv core
Browse files Browse the repository at this point in the history
  • Loading branch information
calcitem committed Oct 27, 2024
1 parent 06db2f2 commit dfbeb35
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// board_detection.dart

import 'dart:math' as math;
import 'package:opencv_dart/opencv_dart.dart' as cv;
import 'package:opencv_core/opencv.dart' as cv;
import '../models/processing_config.dart';
import '../widgets/recognition_page.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:opencv_dart/opencv.dart';
import 'package:opencv_dart/opencv_dart.dart' as cv;
import 'package:opencv_core/opencv.dart';
import 'package:opencv_core/opencv.dart' as cv;

import '../../shared/services/environment_config.dart';
import '../../shared/services/logger.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:image/image.dart' as img;
import 'package:image_picker/image_picker.dart';
import 'package:opencv_dart/opencv_dart.dart' as cv;

import 'package:opencv_core/opencv.dart' as cv;
import '../../../shared/services/logger.dart';
import '../../shared/services/environment_config.dart';
import '../models/processing_config.dart';
Expand Down Expand Up @@ -338,7 +337,19 @@ class RecognitionPageState extends State<RecognitionPage> {

// Apply perspective transform to align the board
logger.i('Applying perspective transform to align board');
final cv.Mat warped = warpPerspective(mat, boardContour);
const int warpWidth = 500;
const int warpHeight = 500;

final cv.VecPoint dstPoints = cv.VecPoint.fromList(<cv.Point>[
cv.Point(0, 0),
cv.Point(warpWidth - 1, 0),
cv.Point(warpWidth - 1, warpHeight - 1),
cv.Point(0, warpHeight - 1),
]);

final cv.Mat M = cv.getPerspectiveTransform(boardContour, dstPoints);
const (int, int) dsize = (warpWidth, warpHeight);
final cv.Mat warped = cv.warpPerspective(mat, M, dsize);
logger.i(
'Perspective transformation completed, Warped Mat dimensions: ${warped.rows}x${warped.cols}');

Expand Down
2 changes: 1 addition & 1 deletion src/ui/flutter_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
logger: 2.4.0
marquee: 2.3.0
native_screenshot_widget: 0.0.8
opencv_dart: 1.3.0
opencv_core: 1.3.0
package_info_plus: 8.1.0
path: 1.9.0
path_provider: 2.1.4
Expand Down

0 comments on commit dfbeb35

Please sign in to comment.