Как это можно сделать, например, чтобы отфильтровывать надоедливые сообщения? Как можно установить уровень логирования от Java?
В это время ( 2020-01) не может. Даже если бы API был доступен из Java, ошибка https://github.com/opencv/opencv/issues/12780 предотвратила бы его.
бы [перенаправить System.out и System.err на slf4j] [5 ] help?
Нет - см. Тестовый пример Junit ниже. Результат:
11:05:56.407 [main] DEBUG u.o.l.s.c.SysOutOverSLF4JInitialiser - Your logging framework class ch.qos.logback.classic.Logger should not need access to the standard println methods on the console, so you should not need to register a logging system package.
11:05:56.417 [main] INFO u.o.l.s.context.SysOutOverSLF4J - Replaced standard System.out and System.err PrintStreams with SLF4JPrintStreams
11:05:56.420 [main] INFO u.o.l.s.context.SysOutOverSLF4J - Redirected System.out and System.err to SLF4J for this context
11:05:56.421 [main] ERROR org.rcdukes.roi.TestROI - testing stderr via slf4j
[mjpeg @ 0x7f958b1b0400] unable to decode APP fields: Invalid data found when processing input
[mjpeg @ 0x7f958b027a00] unable to decode APP fields: Invalid data found when processing input
, где часть поля декодирования APP по-прежнему отображается через некоторых магов stderr c.
@Test
public void testLogStderr() throws Exception {
NativeLibrary.logStdErr();
System.err.println("testing stderr via slf4j");
NativeLibrary.load();
VideoCapture capture = new VideoCapture();
// Dorf Appenzell
//String url="http://213.193.89.202/axis-cgi/mjpg/video.cgi";
// Logitech Cam on test car
// url="http://picarford:8080/?action=stream";
File imgRoot = new File(testPath);
File testStream=new File(imgRoot,"logitech_test_stream.mjpg");
assertTrue(testStream.canRead());
capture.open(testStream.getPath());
Mat image=new Mat();
capture.read(image);
assertEquals(640,image.width());
assertEquals(480,image.height());
capture.release();
}
Забавный побочный факт
В соответствии с документацией ffmpeg раскраска журнала может быть отключена установкой переменной окружения AV_LOG_FORCE_NOCOLOR или NO_COLOR, или может быть принудительно установлена переменная окружения AV_LOG_FORCE_COLOR. Использование переменной среды NO_COLOR устарело и будет удалено в будущей версии FFmpeg
Но, похоже, нет возможности изменить уровень ведения журнала из переменной среды ...