Giter VIP home page Giter VIP logo

tschnz / live-video-magnification Goto Github PK

View Code? Open in Web Editor NEW
433.0 32.0 101.0 7.22 MB

An OpenCV/Qt based realtime application for Eulerian Video Magnification / Motion Magnification. Works with multiple videos and cameras at the same time and let's you export the magnified videos.

License: GNU General Public License v3.0

C++ 96.11% C 2.33% QMake 1.56%
motion-magnification video-magnification eulerian-video-magnification video webcam opencv amplification camera phase-based riesz

live-video-magnification's Introduction

Live Motion Magnification

An OpenCV/Qt based realtime application for Eulerian Video Magnification. Works with multiple videos and cameras at the same time and let's you export the magnified videos.

Examples

Color Magnified Video

Image shows the color magnified output for a video. In the pictures you can see the effects of the cardiac cycle on the skins color. The upper image shows the skin of the face during a diastole, the lower one during a ventricular systole of the cycle.

Motion Magnified Camerastream

(Un-)Wanted artifacts from a realtime motion magnified camerastream. The strong b/w areas around torso and head are resulting from a fast backwards movement and excessive amplification. The white points (the ones bigger than the noise) on the left side are awhirled dust particles, not visible in the original camera source.

Dependencies

  • Qt >= 5.0
  • OpenCV >= 2.0 (< 3.0 ? -> not tested yet)

License

This application is licensed under GPLv3, read the LICENSE.

Credits

Thanks to Nick D'Ademo whose qt-opencv-multithreaded application served as basis and to Joseph Pan whose algorithms in the QtEVM application were adapted for this project.

Also take a look at the MITs webpage for Eulerian Video Magnification. They provide demo videos on their page and the team did a fantastic job in researching and developing this field of science.

How do I use it?

Connect

  • Camera
    • Device Number: Type in the device number of your camera connected to your computer. Indexing starts with 0 which is usually your built-in webcam.
    • (Ubuntu/Linux) PointGrey Device on USB: Having a DC1394 Camera connected to your computer, OpenCV redirects the camera over the v4l-API to device number 0. If you wish to also connect to your built-in camera, enable this option to set built-in to 0, DC1394 to 1
    • Image Buffer: Select the length of an image buffer before processing those images. If dropping frames if buffer is full is disabled, your capture rate will be same the same as your processing rate.
  • Video
    • Choose a video. Compatibility is given if your computer supports the codec. Valid file endings are .avi .mp4 .m4v .mkv .mov .wmv
  • Resolution: This does not work for videos on Ubuntu/Linux yet (Windows not tested). For cameras check the supported modes from camera manufacturer and type in the resolution specified for a mode.
  • Frames per Second: Some cameras support multiple modes with different resolution/fps/etc. . Setting the framerate will change into a mode with a framerate near the one you typed in. For videos, some mp4-files have a bad header where OpenCV can't read out the framerate, which will normally be set to 30FPS. Anyway here you can set it manually.

Connect Dialog

Main Window

When succesfully connected to a camera or opened a window, you can draw a box in the video, to scale and only amplify this Region Of Interest in a video source. Setting the video back to normal can be done via menu that opens with a right click in the video. There is also the option to show the unmagnified image besides the processed one.

Right-click Menu in Frame Label

Magnify

Try experimenting with different option values. Furthermore tooltips are provided when hovering the cursor above a text label in the options tab. If you're using an older machine and processing is too slow, try enabling the Grayscale checkbox.

Low Level value High Level value
Color Magnification Slower and more accurate. Too low = no signal detection Faster magnification, inaccurate spatial resolution
Motion Magnification More noise, less movements by big objects Less noise, less movements by little objects

Color Magnification

Note that in the scene, absolutely NO MOVEMENTS are required to process the video correctly.

  • Amplification: The higher the value, the more colorful and noisy the output.
  • Frequency Range: The freq. range of periodically appearing color changes that shall be amplified.

Panel for Color Magnification Options

Motion Magnification

  • Amplification: The higher the value, the more movements and noise are amplified.
  • Cutoff Wavelength: Reduces fast movements and noise.
  • Frequency Range: Reducing the handler values leads to magnifying slow movements more than fast movements and vice versa.
  • Chrom Attenuation: The higher the value, the more the chromaticity channels are getting amplified too, e.g. the more colorful the movements are.

Panel for Motion Magnification Options

Save

For saving videos or recording from camera you have to specify the file extension by your own. .avi is well supported. If you should encounter problems, please try a differenct saving codec in the toolbar under File->Set Saving Codec.

MainWindow with saving codec menu

How does it work?

The image below provides you the class structure and the dataflow (blue = images, red = options) throughout the application.

Class structure

Algorithm

The algorithms are using a combination of spatial filters (e.g. image pyramids) and temporal filters to determine motions of different spatial wavelength in videos. These can be amplified separately before collapsing the image pyramid and adding the motion image back to the original.

Idea of the Video Magnification Algorithm

Color Magnification

For further informations look at the comments in the .h/.cpp files in /main/magnification/*

Color Magnification UML

Motion Magnification

For further informations look at the comments in the .h/.cpp files in /main/magnification/*

Laplace Magnification UML

live-video-magnification's People

Contributors

tschnz avatar zefrenchy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

live-video-magnification's Issues

Check motion magnification

Hi all,

First, thank you for the work done since I am deeply interested in the potential of this algorithm and mainly in motion magnification.
I managed to compile the code but I am still strugling to be sure it works OK.

Would you have an example video and dedicated settings to check it works fine on my computer?

Thanks,
Nicolas

Unable to compile

Hi I have installed all the dependencies and added all directories and linkers in Visual Studio 2019 but I am still not able to compile this. I also tried using QT Studio but its all not working I keep on receiving errors.

I am getting error:

Error LNK1181 cannot open input file 'C:\Qt\Tools\QtDesignStudio\qt5_design_studio_reduced_version\lib\Qt5Widgets.lib' rvm C:\Users\taten\3D Objects\BBMA\Live-Video-Magnification-master\Live-Video-Magnification-master\src\LINK 1**_

I have tried serching for the libraries but i did not find them.

There are just .prl files and no .lib files in Qt\Tools\QtDesignStudio\qt5_design_studio_reduced_version\lib\

Question about buffer management

First of all, thank you for this very well built and documented implementation. I'm in the process of creating something similar in python and was hoping you could clarify some doubts.

I am running color magnification using my webcam (30fps), with an image buffer size of 999.
As expected, the capture thread processes the frames at 30 fps, while the processing thread processes them at a much lower rate, thus leading to the image buffer getting full.

When the buffer is full, it would be expected that the processing thread is processing the frame captured 999 frames ago, and thus a big delay should be noticeable on the processed image in the gui, but that does not happen.
Although we can see that the processed video frame rate is low (due to the low processing rate), the frame delay is much lower than the expected 999 frames delay. Although this is desirable, I'm not sure what in the code causes it to happen.

From my understanding, in lines 102 and 108 of ProcessingThread.cpp, the oldest frame present on the sharedImageBuffer is added to the ProcessingBuffer, which should lead to a delay proportional to the number of (unprocessed) frames in the buffer.
What causes this behaviour?

Thank you

CMakeFiles?

I want to compile it in Ubuntu.
Do you have any CMakeFile for it?
Thanks

Solved. Unable to use in Windows 10 64 bit

Hello Dear
I am a paranormal Researcher and using your code in Debian I have captured a lot. My next step is to use your GUI in Windows 10 64 bit along with Kinect V2 without any virtual environment. I am unable to compile your code for Windows 10 64 bit using opencv 2, Qt 5 for windows under Visual Studio 2017. Each time I try to build from rvm.pro I get one error which seems to be logical as it points to a path in your code related to your own machine i.e
Error LNK1181 cannot open input file 'D:\Programme\OpenCV\source\opencv\install\x64\vc15\lib\opencv_core412.lib' Coz I dont have this path existing in my machine.
If you kindly help me and release some pre-compiled binaries and executable for windows 10 64 bit, I shall be grateful. Being not a code Guru I need your help in this. Regards

Riesz magnification for baby sleeping does not work

I tested your SW for the video baby sleeping from MIT, but do not see any magnification.
Here is my setting parameters:
pyramid level = 4
amplification = 50
Cutoff wave length 5
Freq low 0.04, high: 0.4

Moreover, I am interested in understanding why do you use lowpass and highpass filter within riesz pyramid (by building and reconstruction)?

What do you think?
Thanks

Errors

I tried to compile the source code on my machine . Qt 5.5.1 . OpenCV 3.1 and it shows basics errors
In file included from ../src/main/magnification/TemporalFilter.cpp:25:0:
../src/main/magnification/TemporalFilter.h:85:29: error: 'vector' does not name a type
void iirWaveletFilter(const vector &src, vector &dst, vector &lowpassHi, vector &lowpassLo, double cutoffLo, double cutoffHi);
^
../src/main/magnification/TemporalFilter.h:85:29: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive]
../src/main/magnification/TemporalFilter.h:85:35: error: expected ',' or '...' before '<' token
void iirWaveletFilter(const vector &src, vector &dst, vector &lowpassHi, vector &lowpassLo, double cutoffLo, double cutoffHi);
^
../src/main/magnification/TemporalFilter.cpp:50:29: error: 'vector' does not name a type
void iirWaveletFilter(const vector &src, vector &dst, vector &lowpassHi, vector &lowpassLo,
^
../src/main/magnification/TemporalFilter.cpp:50:29: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive]
../src/main/magnification/TemporalFilter.cpp:50:35: error: expected ',' or '...' before '<' token
void iirWaveletFilter(const vector &src, vector &dst, vector &lowpassHi, vector &lowpassLo,
^
../src/main/magnification/TemporalFilter.cpp: In function 'void iirWaveletFilter(int)':
../src/main/magnification/TemporalFilter.cpp:54:8: error: 'cutoffLo' was not declared in this scope
if(cutoffLo == 0)
^
../src/main/magnification/TemporalFilter.cpp:64:23: error: 'cutoffHi' was not declared in this scope
Mat tmp1 = (1-cutoffHi)_lowpassHi[dims] + cutoffHi_src[dims];
^
../src/main/magnification/TemporalFilter.cpp:64:33: error: 'lowpassHi' was not declared in this scope
Mat tmp1 = (1-cutoffHi)_lowpassHi[dims] + cutoffHi_src[dims];
^
../src/main/magnification/TemporalFilter.cpp:64:60: error: 'src' was not declared in this scope
Mat tmp1 = (1-cutoffHi)_lowpassHi[dims] + cutoffHi_src[dims];
^
../src/main/magnification/TemporalFilter.cpp:65:23: error: 'cutoffLo' was not declared in this scope
Mat tmp2 = (1-cutoffLo)_lowpassLo[dims] + cutoffLo_src[dims];
^
../src/main/magnification/TemporalFilter.cpp:65:33: error: 'lowpassLo' was not declared in this scope
Mat tmp2 = (1-cutoffLo)_lowpassLo[dims] + cutoffLo_src[dims];
^
../src/main/magnification/TemporalFilter.cpp:69:9: error: 'dst' was not declared in this scope
dst[dims] = lowpassHi[dims] - lowpassLo[dims];

in the temporalfilter.cpp file

Idea filter frequency

Hi,
I have 2 questions about the idea filter frequency

double fl = 2 * cutoffLo * width / framerate;
double fh = 2 * cutoffHi * width / framerate;

why do you use 2 time frequency?
fl and fh are calculated by width instead of width and height, why?

Thanks a lot.

compiling this repository

Hi!
I am trying to compile this code but I don't know how to!
could you please help me?
there is not enough information for compiling on README.md

I also would very appreciate it if you send me an email.

How do you actually use this?

Hi, there are no installation and usage instructions, just dependencies.
I installed both QT and opencv. I have no idea how to connect them both together, and what file to use from your project in which of the above mentioned programs.

Please provide a little more information, so that someone who is not so proficient in these programs can launch your program. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.