cirquit / trdrop

trdrop - a raw video analysis program
MIT License
379 stars 33 forks source link

Slow exporting at high resolution #43

Open illusion0001 opened 5 years ago

illusion0001 commented 5 years ago

When exporting at high resolution it's very slow. Exporting at 960x540 resulted in 7~ fps but exporting the same video at 3840x2160 resulted in 1-2 fps. The older version before Qt running the same video at 4k resulted in 6~ fps. Tested on 1.0 Stable and 0.31-Overlay

PC Specs: Ryzen 5 1600, GTX 1060
cirquit commented 5 years ago

The difference in the performance between the command line program is that we base all of your calculations on the difference frame, e.g we need to "paint" it. It's currently a very non-optimized solution which fills a cv::Mat pixel per pixel.

There are many possibilities to speed this up. It would be awesome to reuse some algorithm from opencv similar to cv::absdiff and make it configurable to create the same difference frame as our manual one. This would move this calculation onto the GPU, instead of the current CPU only load.

cirquit commented 5 years ago

Ah, I missed the overlay option. That's also quite a bummer, as .bmp encoding is slower that the .jpg one in Qt. It may be the greater size (hence IO bottleneck) or simply the difference between the encoding algorithms.

It may be possible to use the OpenCV bmp encoding to benchmark it against the Qt one.

illusion0001 commented 3 years ago

Qimage PNG is notoriously slow. Example code is using jpg but can simply change extension or use nullptr

            {
                QString filepath = _create_image_file_path();
                int times = 1;
                QTime timer;
                timer.start();
                while(times--) {
                  image.save(filepath, "jpg", 100); // overrides format and compression, doesn't matter what option in ui is selected
                }
                int elapsed = timer.elapsed();
                std::cout << "Completed a single run with jpg format and 100 compression in " << elapsed << "ms.\n";
              }

Results (Preview disabled, overlay only, 1920x1080):

code: image.save(filepath, "png");
out:  Completed a single run with (default) compression in107ms.
code: image.save(filepath, "png", 0);
out:  Completed a single run with 0 compression in122ms.
code: image.save(filepath, "png", 50);
out:  Completed a single run with 50 compression in91ms.
code: image.save(filepath, "png", 100);
out:  Completed a single run with 100 compression in66ms.

Tiff

code: image.save(filepath, "tiff");
out:  Completed a single run with tiff format in10ms.