Skip to content

Commit

Permalink
Removed DLLs and added ArUco detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Feb 7, 2024
1 parent ed472e3 commit ef60d9e
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/src/isolates/opencv.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "package:opencv_ffi/opencv_ffi.dart";
import "package:burt_network/burt_network.dart";
import "package:burt_network/logging.dart";
import "package:video/src/utils/aruco.dart";

import "package:video/video.dart";

Expand Down Expand Up @@ -35,7 +36,10 @@ class OpenCVCameraIsolate extends CameraIsolate {
/// - If the quality is already low, alerts the dashboard
@override
void sendFrames() {
final frame = camera.getJpg(quality: details.quality);
final matrix = camera.getFrame();
detectAndAnnotateFrames(matrix);
final frame = encodeJpg(matrix, quality: details.quality);
matrix.dispose();
if (frame == null) { // Error getting the frame
sendLog(LogLevel.warning, "Camera $name didn't respond");
updateDetails(CameraDetails(status: CameraStatus.CAMERA_NOT_RESPONDING));
Expand Down
6 changes: 5 additions & 1 deletion lib/src/isolates/realsense.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "package:burt_network/generated.dart";
import "package:burt_network/logging.dart";
import "package:protobuf/protobuf.dart";
import "package:opencv_ffi/opencv_ffi.dart";
import "package:video/src/utils/aruco.dart";

import "package:video/video.dart";

Expand Down Expand Up @@ -76,9 +77,12 @@ class RealSenseIsolate extends CameraIsolate {
sendFrame(colorizedJpg);
}

// Compress RGB frame
// Get RGB frame
final Pointer<Uint8> rawRGB = frames.ref.rgb_data;
final Pointer<Mat> rgbMatrix = getMatrix(camera.height, camera.width, rawRGB);
detectAndAnnotateFrames(rgbMatrix); // detect ArUco tags

// Compress the RGB frame into a JPG
final OpenCVImage? rgbJpg = encodeJpg(rgbMatrix, quality: details.quality);
if (rgbJpg == null) {
sendLog(LogLevel.debug, "Could not encode RGB frame");
Expand Down
10 changes: 10 additions & 0 deletions lib/src/utils/aruco.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "dart:ffi";

import "package:opencv_ffi/opencv_ffi.dart";

/// Detect ArUco tags in the cv::aruco::DICT_4X4_50 dictionary and annotate them
void detectAndAnnotateFrames(Pointer<Mat> image) {
final Pointer<ArucoMarkers> markers = detectArucoMarkers(image, dictionary: 0);
drawMarkers(image, markers);
markers.dispose();
}
Binary file removed opencv_core480d.dll
Binary file not shown.
Binary file removed opencv_ffi.dll
Binary file not shown.
Binary file removed opencv_highgui480d.dll
Binary file not shown.
Binary file removed opencv_imgcodecs480d.dll
Binary file not shown.
Binary file removed opencv_imgproc480d.dll
Binary file not shown.
Binary file removed opencv_videoio480d.dll
Binary file not shown.

0 comments on commit ef60d9e

Please sign in to comment.