awawa-dev / HyperHDR

Highly optimized open source ambient lighting implementation based on modern digital video and audio stream analysis for Windows, macOS and Linux (x86 and Raspberry Pi / ARM).
http://www.hyperhdr.eu/
MIT License
1.06k stars 110 forks source link

LUT processing for MJPEG is broken, affects blue channel (was: Cannot run HyperHDR) #63

Closed setrin closed 3 years ago

setrin commented 3 years ago

Bug report, debug log and your config file (FULL LOGS ARE MANDATORY)

hyperhdr: /lib/x86_64-linux-gnu/libc.so.6: versionGLIBC_2.28' not found (required by /usr/share/hyperhdr/bin/../lib/libQt5Core.so.5)`

Steps to reproduce

Tried to run HyperHDR x86 64bit version and i got error above.

What is expected?

HyperHDR is running

What is actually happening?

I get error message above. I have also tried to compile it on my system as well, but i got another error /home/setrin/apps/hyperhdr/libsrc/boblightserver/BoblightClientConnection.h:9:10: fatal error: QStringView: No such file or directory

Full build error here: `[ 85%] Building CXX object libsrc/leddevice/CMakeFiles/leddevice.dir/leddevice_autogen/mocs_compilation.cpp.o [ 86%] Building CXX object libsrc/leddevice/CMakeFiles/leddevice.dir/leddevice_autogen/EWIEGA46WW/qrc_LedDeviceSchemas.cpp.o [ 86%] Linking CXX static library ../../lib/libleddevice.a [ 86%] Built target leddevice Scanning dependencies of target boblightserver [ 86%] Building CXX object libsrc/boblightserver/CMakeFiles/boblightserver.dir/boblightserver_autogen/mocs_compilation.cpp.o [ 86%] Building CXX object libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightClientConnection.cpp.o [ 86%] Building CXX object libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightServer.cpp.o In file included from /home/setrin/apps/hyperhdr/libsrc/boblightserver/BoblightServer.cpp:6:0: /home/setrin/apps/hyperhdr/libsrc/boblightserver/BoblightClientConnection.h:9:10: fatal error: QStringView: No such file or directory

include

      ^~~~~~~~~~~~~

compilation terminated. libsrc/boblightserver/CMakeFiles/boblightserver.dir/build.make:86: recipe for target 'libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightServer.cpp.o' failed make[2]: [libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightServer.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... In file included from /home/setrin/apps/hyperhdr/build/libsrc/boblightserver/boblightserver_autogen/EWIEGA46WW/moc_BoblightClientConnection.cpp:9:0, from /home/setrin/apps/hyperhdr/build/libsrc/boblightserver/boblightserver_autogen/mocs_compilation.cpp:3: /home/setrin/apps/hyperhdr/build/libsrc/boblightserver/boblightserver_autogen/EWIEGA46WW/../../../../../libsrc/boblightserver/BoblightClientConnection.h:9:10: fatal error: QStringView: No such file or directory

include

      ^~~~~~~~~~~~~

compilation terminated. libsrc/boblightserver/CMakeFiles/boblightserver.dir/build.make:110: recipe for target 'libsrc/boblightserver/CMakeFiles/boblightserver.dir/boblightserver_autogen/mocs_compilation.cpp.o' failed make[2]: *** [libsrc/boblightserver/CMakeFiles/boblightserver.dir/boblightserver_autogen/mocs_compilation.cpp.o] Error 1 In file included from /home/setrin/apps/hyperhdr/libsrc/boblightserver/BoblightClientConnection.cpp:26:0: /home/setrin/apps/hyperhdr/libsrc/boblightserver/BoblightClientConnection.h:9:10: fatal error: QStringView: No such file or directory

include

      ^~~~~~~~~~~~~

compilation terminated. libsrc/boblightserver/CMakeFiles/boblightserver.dir/build.make:62: recipe for target 'libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightClientConnection.cpp.o' failed make[2]: [libsrc/boblightserver/CMakeFiles/boblightserver.dir/BoblightClientConnection.cpp.o] Error 1 CMakeFiles/Makefile2:2000: recipe for target 'libsrc/boblightserver/CMakeFiles/boblightserver.dir/all' failed make[1]: [libsrc/boblightserver/CMakeFiles/boblightserver.dir/all] Error 2 Makefile:151: recipe for target 'all' failed make: *** [all] Error 2 `

If someone would be able to help me, i would really appreciate it

System

Server OS:

awawa-dev commented 3 years ago

I suspect your QT doesn't have QStringView. It was introduced in QT 5.10. You should get the version of your QT libraries during configuration phase with cmake. Migration to QStringView in v16 was necessary to comply with QT6 compatibility (and maintain some backward compatibility but supported QT 5.10 was introduced in 2017).

EDIT: Ok, I see it now Qt Version: 5.7.1

awawa-dev commented 3 years ago

There are linked system dependencies like GLIBC_2.28 that can't be provided alongside HyperHDR because they won't work anyway due to conflict with your system libraries and architecture. The "dependency hell" is here even worse that on Windows. Anyway should it work with most modern OS based on Ubuntu, Debian Buster/Bullseye distros (even minimal).

setrin commented 3 years ago

First of all, big thank you for quickest reaction i've seen 🥇

Sorry but i'm newby in terms of linux and libs and compiling stuff. I have followed "How to compile" page and it threw those errors. What would you suggest? Could you maybe point me somewhere? Now i'm just lost as i tried to google how to update Qt lib i couldn't find easy solution.

Thank you very much

awawa-dev commented 3 years ago

There should be brake-stop in the configuration phase to display an error about minimal QT version anyway (and I'll add it in one of next commits) but I guess it won't change much in your situation ;-) OK, there are two possible solutions: you can try to compile v15 from the sources as it uses older way of handling QT Strings and at least you should not receive that error during compiling "BoblightClientConnection.h" (it's advised to update your packages to QT 5.9 as their are available for your system). Second option is to install/build modern QT5.15 developing libraries from https://www.qt.io/ as elementary OS 5.1.7 provides only QT 5.9 max.

setrin commented 3 years ago

I have tried to update my QT lib but without success. It's too complicated for me :D I have installed QT 5.15 but cmake can't find it and still uses 5.9 which is installed by default. I tried to clone v15 of HyberHDR but i get other errors

CMake Error at dependencies/CMakeLists.txt:27 (add_subdirectory):
  The source directory

    /home/setrin/apps/hyperhdr/HyperHDR-15.0.0.0/dependencies/external/flatbuffers

  does not contain a CMakeLists.txt file.

CMake Error at dependencies/CMakeLists.txt:35 (export):
  export given target "flatc" which is not built by this project.

-- Using flatbuffers compiler: $<TARGET_FILE:flatc>
CMake Error at dependencies/CMakeLists.txt:86 (add_subdirectory):
  add_subdirectory given source "external/protobuf/cmake" which is not an
  existing directory.

CMake Error at dependencies/CMakeLists.txt:94 (export):
  export given target "protoc" which is not built by this project.

-- Using protobuf compiler: $<TARGET_FILE:protoc>
CMake Error at dependencies/CMakeLists.txt:223 (add_subdirectory):
  The source directory

    /home/setrin/apps/hyperhdr/HyperHDR-15.0.0.0/dependencies/external/mbedtls

  does not contain a CMakeLists.txt file.

-- Found ALSA: /usr/lib/x86_64-linux-gnu/libasound.so (found version "1.1.3") 
-- CPACK: Found RPM builder
-- CPACK: Found DEB builder
-- Configuring incomplete, errors occurred!
See also "/home/setrin/apps/hyperhdr/HyperHDR-15.0.0.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/setrin/apps/hyperhdr/HyperHDR-15.0.0.0/build/CMakeFiles/CMakeError.log".

Unfortunately, this doesn't make sense to me 😕

What i ultimately wanted is to get better color from HDR HDMI capture as current video using Hyperion is unusable

awawa-dev commented 3 years ago

I see that you used tar with sources. It does not contain external dependencies (in project:dependencies/external subfolders are empty) that's why you receive that errors.

It can be easily fixed. Again 2 possible solutions:

1) use git to get full v15 with external dependecies (easy step by step)

git clone --recursive https://github.com/awawa-dev/HyperHDR.git hyperhdrv15
cd hyperhdrv15
mkdir build
cd build
git reset --hard 90c1b636056fa7839ea21cb127ddbf362bf81dc4
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j $(nproc)
if you want to build also deb/rpm packages run: cpack as last command

2) brute force, not recommended: copy to /home/setrin/apps/hyperhdr/HyperHDR-15.0.0.0/dependencies/external content of your earlier downloaded v16 dependencies/external (git downloaded them)

setrin commented 3 years ago

So that's how you clone v15 repo. I was scratching my head how to do it and just downloaded source files instead. I will try it and keep you posted. Thank you very much for your support 🥇

setrin commented 3 years ago

So i finally been able to return to HyperHDR and after few hiccups v15 works great 🙂 Thank you for your guidance again I have an issue with getting correct color mapping tho. I tried to generate LUT table through generator. I have uploaded test image, applied LUT table, generated it and saved it, but result i see in HyperHDR live preview differs from the one in generator. LED after playing around with gamma/saturation/luminance and all those preprocessing properties shows correct colors to what what i see in Live preview, but it still differs from reality. Any idea what could help? Why there are different colors in LUT generator and Live preview?

Don't get me wrong, it's huge improvement compared to classic Hyperion style, but i wonder if it could be better. Here is LUT Generator: https://ibb.co/TMm1cj5 Here is Live Preview: https://ibb.co/HKdW3vv

awawa-dev commented 3 years ago

Did you activated HDR tone mapping in the grabber properties? And check in the logs if HyperHDR found your custom LUT table in the default paths.

awawa-dev commented 3 years ago

And I hope you worked on the sample image that was captured from the HyperHDR (Screenshot button) when the HDR tone mapping was OFF. Otherwise you will get overlapsed result (double HDR tone mapping).

awawa-dev commented 3 years ago

Change gamma/saturation/luminance in the grabber properties BEFORE taking sample and creating LUT table, otherwise preview in the LUT generator works on different input.

awawa-dev commented 3 years ago

Preprocessor/calibrations settings has completly no impact on the live preview. There are used to LED calibration.

setrin commented 3 years ago

Yep, i turned off HDR mapping and did the screenshot. I have cheep grabber with no hardware options, so i think i should be fine on that part. But I can see in logs this warning. Maybe LUT table is not correctly loaded 2021-05-19T22:52:12.726Z [V4L2:/DEV/VIDEO0] (WARNING) setHdrToneMappingMode to: enable, but the LUT file is currently unloaded

awawa-dev commented 3 years ago

During initializations it's normal

setrin commented 3 years ago

Yes, sorry i just read whole log and found

2021-05-19T22:52:12.748Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:99:GetSharedLut()) LUT folder location: '/usr/share/hyperhdr/lut'
2021-05-19T22:52:12.748Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:135:loadLutFile()) LUT file found: /home/setrin/.hyperhdr/lut_lin_tables.3d
2021-05-19T22:52:12.749Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:153:loadLutFile()) Index 0 for HDR RGB
2021-05-19T22:52:12.793Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:166:loadLutFile()) LUT file has been loaded

So this should be good as well.

It seems weird to me that same picture produces different results in Live Preview and in LUT Generator. The one in Generator is spot on Here is LUT Generator: https://ibb.co/TMm1cj5 Here is Live Preview: https://ibb.co/HKdW3vv

awawa-dev commented 3 years ago

I have taken your captured image and applied default LUT table (v16 shares the same LUT table as v15). And that should it look in the video preview with default LUT table and tone mapping ON. obraz OK, I dont know if you built DEB package because without it there is no LUT in /usr/share/hyperhdr/lut/lut_lin_tables.3d and you would go in the uncharted territories. 1) remove your LUT table from /home/setrin/.hyperhdr/lut_lin_tables.3d It's best to remove all the /home/setrin/.hyperhdr folder You need creating your own LUT table only for fine tuning. But default LUT is quite good as you can see. 2) install DEB package that you built with cpack 3) run hyperhdr and on the pause movie scene take a screen with tone mapping off and second with tone mapping on (of course if there is still a problem)

awawa-dev commented 3 years ago

And please dont change any saturation, hue, brigtness settings at all for now. If you did it earlier you may need to restart system because it stores v4l2 settings anyway. And best to delete /home/setrin/.hyperhdr before that to make sure default settings will be applied.

setrin commented 3 years ago

I have built DEB package and installed it from the beginning, so i have checked and there is default LUT in /usr/share/hyperhdr/lut/lut_lin_tables.3d

I have deleted whole /home/setrin/.hyperhdr folder and restarted HyperHDR.

I can still see difference on the blue at the bottom compared to your picture and also what default lut generator shows up: Screenshot 2021-05-20 at 01 34 13 Screenshot 2021-05-20 at 01 34 24

EDIT: I didn't mess with v4l2 settings, as my grabber only supports changes to resolution and framerate

awawa-dev commented 3 years ago

I give up ;) There is no possibility to achieve 2 different results with the same LUT table other than video stream properties has changed due to some playing with the grabbers settings .

setrin commented 3 years ago

Ok, that's fine 😄 I can live with the result, it's not too bad 🙂 i will try to mess around some more, maybe i will find something i've missed.

Thank you very much for all the help. Is there any way i could maybe support you and this project?

awawa-dev commented 3 years ago

I can still see difference on the blue at the bottom compared to your picture and also what default lut generator shows up:

Frankly blue channel is completely broken and unusable. So there is difference not only in the video preview but also in the generator which is different from my picture (which also come from the lut generator page)? Please take a screenshot of the whole www LUT generator page after you click 'apply'. Use this picture from archive as test sample: Clipboard01.zip

Is there any way i could maybe support you and this project?

Verifying HyperHDR translation/label's text would be appreciated ;)

awawa-dev commented 3 years ago

If you could post full logs at pastebin. Maybe it reveals something.

awawa-dev commented 3 years ago

and please screencapture your current video screen (whole WWW page on the grabber settings page with the live preview activated and visible) with tone mapping ON and second screenshot with hdr tone mapping OFF to compare a difference.

setrin commented 3 years ago

The LUT generator looks the same as your picture. Only Live preview has broken blue channel. Here is the lut generator screenshow with your picture Screenshot 2021-05-20 at 02 01 03

Here are the logs: https://pastebin.com/W6t8ying

Screenshot without tone mapping Screenshot 2021-05-20 at 02 08 25

Screenshot with tone mapping Screenshot 2021-05-20 at 02 08 37

awawa-dev commented 3 years ago

Thank you. Will try to analyze them later. First test shows different result (I applied default LUT on the first your screenshot - only live preview area matters): obraz

setrin commented 3 years ago

That's what i don't understand. Why LUT generator gives perfect results, but in live preview it's broken with tone mapping on and with same grabber settings.

Anyway, i have compensated it a little with gamma levels in image processing and increased saturation. Colors ale little off, but it much better than what Hyperion could offer wit HDR turn on on my playstation.

Verifying HyperHDR translation/label's text would be appreciated ;)

I can speak English on reasonable level (B2 maybe even C1) as well as Czech, but my mother tongue is Slovak. If you could use this, i'm happy to help :)

awawa-dev commented 3 years ago

There is something wrong in the processing but I can't explain it for now. Logs look normal. 1) Please disable Quarter of Frame mode and signal detection and check if changes something with HDR on. 2) Could you also post ip:8090/#about info because I want to make sure about architecture. 3) If your grabber supports multiple format try to force it for example to yuv or nv12 (check in logs if grabber switched it on)

EDIT: Czech/Slovak translation is also very welcome :)

awawa-dev commented 3 years ago

' Quarter of Frame mode ' is most suspected. But also there is strange resolution 800x450. Could you set some other resolution and make sure that width and height are divided by 4?

setrin commented 3 years ago
  1. I disabled it and no change
  2. Screenshot 2021-05-20 at 02 26 01
  3. I don't think it supports it. Before i tried HyperHDR i've tried just to just increase grabber's saturation using v4l2-ctl and i didn't get any available controls with v4l2-ctl -l command. Anyway, i tried it and it doesn't seems to do anything. Logs looks almost identical between yuv and nv12
    2021-05-20T00:29:09.296Z [V4L2:/DEV/VIDEO0] (INFO) Video FPS: 59.80, av. delay: 8ms, good: 3588, bad: 0 (60.00,15)
    2021-05-20T00:29:49.994Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:1522:setBrightnessContrastSaturationHue()) setBrightnessContrastSaturationHue nothing changed
    2021-05-20T00:29:49.995Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:211:setHdrToneMappingEnabled()) setHdrToneMappingMode nothing changed: Fullscreen
    2021-05-20T00:29:49.995Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:211:setHdrToneMappingEnabled()) setHdrToneMappingMode nothing changed: Fullscreen
    2021-05-20T00:29:49.995Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:181:setFpsSoftwareDecimation()) setFpsSoftwareDecimation to: 1
    2021-05-20T00:29:49.995Z [V4L2:/DEV/VIDEO0] (INFO) Signal detection area set to: 0.250000,0.250000 x 0.750000,0.750000
    2021-05-20T00:29:49.995Z [V4L2:/DEV/VIDEO0] (INFO) Signal threshold set to: {12, 12, 12} and frames: 200
    2021-05-20T00:29:49.996Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:1487:setEncoding()) Force encoding (setEncoding): yuyv (mjpeg)
    2021-05-20T00:29:49.996Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:1494:setEncoding()) Restarting V4L2Grabber grabber
    2021-05-20T00:29:49.996Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:228:uninit()) uninit grabber: /dev/video0
    2021-05-20T00:29:49.998Z [V4L2:/DEV/VIDEO0] (INFO) Stopped
    2021-05-20T00:29:49.998Z [V4L2:/DEV/VIDEO0] (INFO) Multithreading for V4L2 is enabled. Available thread's count 4
    2021-05-20T00:29:50.069Z [V4L2:/DEV/VIDEO0] (INFO) configured v4l device: /dev/video0
    2021-05-20T00:29:50.072Z [V4L2:/DEV/VIDEO0] (INFO) Set resolution to: 800 x 450
    2021-05-20T00:29:50.073Z [V4L2:/DEV/VIDEO0] (INFO) Set framerate to 30 FPS
    2021-05-20T00:29:50.074Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:99:GetSharedLut()) LUT folder location: '/usr/share/hyperhdr/lut'
    2021-05-20T00:29:50.074Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:121:loadLutFile()) LUT table: trying distro file location
    2021-05-20T00:29:50.074Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:135:loadLutFile()) LUT file found: /usr/share/hyperhdr/lut/lut_lin_tables.3d
    2021-05-20T00:29:50.074Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:153:loadLutFile()) Index 0 for HDR RGB
    2021-05-20T00:29:50.099Z [V4L2:/DEV/VIDEO0] (DEBUG) (V4L2Grabber.cpp:166:loadLutFile()) LUT file has been loaded
    2021-05-20T00:29:50.099Z [V4L2:/DEV/VIDEO0] (INFO) Pixel format: MJPEG
    2021-05-20T00:29:50.103Z [V4L2:/DEV/VIDEO0] (INFO) Started
    2021-05-20T00:29:50.103Z [V4L2:/DEV/VIDEO0] (INFO) setQFrameDecimation is now: disabled
    2021-05-20T00:29:50.103Z [V4L2:/DEV/VIDEO0] (ERROR) Frame index = 97160, inactive or critical VIDIOC_QBUF error in v4l2 driver. Buf index = 3, worker = 0, is_active = 1.
    2021-05-20T00:29:53.278Z [WEBSOCKET] (DEBUG) (JsonAPI.cpp:1080:handleLoggingCommand()) log streaming activated for client ::ffff:192.168.0.239
    2021-05-20T00:29:53.291Z [WEBSOCKET] (DEBUG) (JsonAPI.cpp:1089:handleLoggingCommand()) log streaming deactivated for client  ::ffff:192.168.0.239

I have also played around with resolution also with no improvement. The grabber supports fullhd 60fps max, but it's overkill for my machine, that's why i have used that weird 800x450 resolution and 20fps.

awawa-dev commented 3 years ago

Thanks. I will try later to put that test sample through full MJPEG pipeline and simulate your settings in HyperHDR to see if I could reproduce it.

setrin commented 3 years ago

I will be forever grateful if you would be able to find solution for this stubborn issue. And thank you for every bit of support. I really appreciate it 😍 I assume that translations go to this file HyperHDR/assets/webconfig/i18n/cs.json right? I will later fo through it and try my best to translate added labels

awawa-dev commented 3 years ago

Hi I can confirm that LUT processing for MJPEG is completely broken in v16 and in v15. That lack of blue color is the least punishment ..on other systems with different compiler optimization it can generate even noise on static images. I have back-ported fix for you for v15 version and there will be release of hotfix for v16 soon. In the optimistic version why the problem wasn't discovered earlier: the users took my advice not to use MJPEG when it's possible (but from other reasons) ;-) Or they have little expectations of HDR tone mapping in the other case....

Thank you very much for reporting that issue as it is critical one. For your v15 please replace your ImageResampler.cpp in libsrc\utils folder using new version from the attached archive. ImageResampler.zip

And for translation if you could take last 68 items from en version HyperHDR/assets/webconfig/i18n/en.json ("edt_conf_v4l2_hdrToneMapping_title" is first) and put it translated in HyperHDR/assets/webconfig/i18n/cs.json? But no hurry, hope next version will be after summer ;-)

setrin commented 3 years ago

Hi 🙂 That's awesome that you have been able to find solution and even back-port it for me 👍
I will try it a bit later today. I assume i need to replace the file in source project and recompile it, right?

Ok, i will do my best to get the proper translation for those ready by next release 🙂

awawa-dev commented 3 years ago

Yes, please replace ImageResampler.cpp in the v15 project that you already downloaded and recompile it & build DEB new package ("make -j $(nproc) package" should recompile project and build installers). Then remove old HyperHDR v15 with standard sudo apt remove hyperhdr and install new one. You can leave your HyperHDR settings.

setrin commented 3 years ago

Oh man, the colors are now spot on 😍 Screenshot 2021-05-20 at 18 34 45

Huge thanks again, you are the BEST! 🙂

awawa-dev commented 3 years ago

OK, closing as it's fixed.