rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
132 stars 18 forks source link

logging #173

Open abdelaziz-mahdy opened 3 months ago

abdelaziz-mahdy commented 3 months ago

how to enable logging for opencv i found this https://stackoverflow.com/questions/54828885/how-to-enable-logging-for-opencv but i didnt find any method to set log level in the dart interface.

rainyl commented 3 months ago

https://stackoverflow.com/a/67417220/18539998

This answer says opencv uses environment variable to set log level, I tested it on windows and it does work.

And the logs are written to stdout, maybe a redirection is needed if you want to capture them.

import 'package:opencv_dart/opencv_dart.dart' as cv;

void main(List<String> args) {
  final data3D = [
    [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9],
    ],
    [
      [10, 11, 12],
      [13, 14, 15],
      [16, 17, 18],
    ],
    [
      [19, 20, 21],
      [22, 23, 24],
      [25, 26, 27],
    ],
  ];
  final matFrom3DList = cv.Mat.from3DList(data3D, cv.MatType.CV_8UC3);

  print(matFrom3DList);

  final model = cv.Net.fromOnnx("test/models/googlenet-9.onnx");
}

image image

abdelaziz-mahdy commented 3 months ago

yeah we need to check for a way to capture the logs across all platforms , since people may need to capture logs from user devices to debug problems

a redirect to dart will be the best option, and then people can handle it the way they see fit or ignore it

rainyl commented 3 months ago

Setting log level is easy to implement, but I have no idea about how to capture the stdout from native/ffi, do you have any ideas?

abdelaziz-mahdy commented 3 months ago

Setting log level is easy to implement, but I have no idea about how to capture the stdout from native/ffi, do you have any ideas?

i dont know how too, and searched how to redirect opencv logs but couldnt find any resource, will need to look into it, for now setting logging level is a good start, then we can check how to redirect later dont you agree?

want me to start working on it?

rainyl commented 3 months ago

Setting log level is easy to implement, but I have no idea about how to capture the stdout from native/ffi, do you have any ideas?

i dont know how too, and searched how to redirect opencv logs but couldnt find any resource, will need to look into it, for now setting logging level is a good start, then we can check how to redirect later dont you agree?

Agree.

want me to start working on it?

Just do it if you want. 😄