Commit a0a46b0d authored by Bernat Gabor's avatar Bernat Gabor

Added a video input tutorial with PSNR and SSIM.

parent caec96a1
...@@ -355,6 +355,7 @@ extlinks = {'cvt_color': ('http://opencv.willowgarage.com/documentation/cpp/imgp ...@@ -355,6 +355,7 @@ extlinks = {'cvt_color': ('http://opencv.willowgarage.com/documentation/cpp/imgp
'imgprocfilter':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None), 'imgprocfilter':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None),
'svms':('http://opencv.itseez.com/modules/ml/doc/support_vector_machines.html#%s', None), 'svms':('http://opencv.itseez.com/modules/ml/doc/support_vector_machines.html#%s', None),
'xmlymlpers':('http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html#%s', None), 'xmlymlpers':('http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html#%s', None),
'huivideo' : ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None),
'filtering':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None), 'filtering':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None),
'point_polygon_test' : ('http://opencv.willowgarage.com/documentation/cpp/imgproc_structural_analysis_and_shape_descriptors.html#cv-pointpolygontest%s', None) 'point_polygon_test' : ('http://opencv.willowgarage.com/documentation/cpp/imgproc_structural_analysis_and_shape_descriptors.html#cv-pointpolygontest%s', None)
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
This section contains valuable tutorials about how to read/save your image/video files and how to use the built-in graphical user interface of the library. This section contains valuable tutorials about how to read/save your image/video files and how to use the built-in graphical user interface of the library.
.. include:: ../../definitions/tocDefinitions.rst
+ +
.. tabularcolumns:: m{100pt} m{300pt} .. tabularcolumns:: m{100pt} m{300pt}
...@@ -15,6 +16,8 @@ This section contains valuable tutorials about how to read/save your image/video ...@@ -15,6 +16,8 @@ This section contains valuable tutorials about how to read/save your image/video
*Compatibility:* > OpenCV 2.0 *Compatibility:* > OpenCV 2.0
*Author:* |Author_AnaH|
We will learn how to add a Trackbar to our applications We will learn how to add a Trackbar to our applications
=============== ====================================================== =============== ======================================================
...@@ -23,6 +26,25 @@ This section contains valuable tutorials about how to read/save your image/video ...@@ -23,6 +26,25 @@ This section contains valuable tutorials about how to read/save your image/video
:height: 90pt :height: 90pt
:width: 90pt :width: 90pt
+
.. tabularcolumns:: m{100pt} m{300pt}
.. cssclass:: toctableopencv
=============== ======================================================
|hVideoInput| *Title:* :ref:`videoInputPSNRMSSIM`
*Compatibility:* > OpenCV 2.0
*Author:* |Author_BernatG|
You will learn how to read video streams, and how to calculate similarity values such as PSNR or SSIM.
=============== ======================================================
.. |hVideoInput| image:: images/video-input-psnr-ssim.png
:height: 90pt
:width: 90pt
.. raw:: latex .. raw:: latex
\pagebreak \pagebreak
...@@ -31,3 +53,4 @@ This section contains valuable tutorials about how to read/save your image/video ...@@ -31,3 +53,4 @@ This section contains valuable tutorials about how to read/save your image/video
:hidden: :hidden:
../trackbar/trackbar ../trackbar/trackbar
../video-input-psnr-ssim/video-input-psnr-ssim
// Video Image PSNR and SSIM
#include <iostream> // for standard I/O #include <iostream> // for standard I/O
#include <string> // for strings #include <string> // for strings
#include <iomanip> // for controlling float print precision #include <iomanip> // for controlling float print precision
...@@ -38,7 +37,7 @@ int main(int argc, char *argv[], char *window_name) ...@@ -38,7 +37,7 @@ int main(int argc, char *argv[], char *window_name)
const string sourceReference = argv[1],sourceCompareWith = argv[2]; const string sourceReference = argv[1],sourceCompareWith = argv[2];
int psnrTriggerValue, delay; int psnrTriggerValue, delay;
conv << argv[3] << argv[4]; // put in the strings conv << argv[3] << endl << argv[4]; // put in the strings
conv >> psnrTriggerValue >> delay;// take out the numbers conv >> psnrTriggerValue >> delay;// take out the numbers
char c; char c;
...@@ -79,7 +78,7 @@ int main(int argc, char *argv[], char *window_name) ...@@ -79,7 +78,7 @@ int main(int argc, char *argv[], char *window_name)
cvMoveWindow(WIN_RF, 400 , 0); //750, 2 (bernat =0) cvMoveWindow(WIN_RF, 400 , 0); //750, 2 (bernat =0)
cvMoveWindow(WIN_UT, refS.width, 0); //1500, 2 cvMoveWindow(WIN_UT, refS.width, 0); //1500, 2
cout << "Frame resolution: Width=" << refS.width << " Height=" << refS.height cout << "Reference frame resolution: Width=" << refS.width << " Height=" << refS.height
<< " of nr#: " << captRefrnc.get(CV_CAP_PROP_FRAME_COUNT) << endl; << " of nr#: " << captRefrnc.get(CV_CAP_PROP_FRAME_COUNT) << endl;
cout << "PSNR trigger value " << cout << "PSNR trigger value " <<
...@@ -101,21 +100,21 @@ int main(int argc, char *argv[], char *window_name) ...@@ -101,21 +100,21 @@ int main(int argc, char *argv[], char *window_name)
} }
++frameNum; ++frameNum;
cout <<"Frame:" << frameNum; cout <<"Frame:" << frameNum <<"# ";
///////////////////////////////// PSNR //////////////////////////////////////////////////// ///////////////////////////////// PSNR ////////////////////////////////////////////////////
psnrV = getPSNR(frameReference,frameUnderTest); //get PSNR psnrV = getPSNR(frameReference,frameUnderTest); //get PSNR
cout << setiosflags(ios::fixed) << setprecision(3) << psnrV << "dB"; cout << setiosflags(ios::fixed) << setprecision(3) << psnrV << "dB";
//////////////////////////////////// MSSIM ///////////////////////////////////////////////// //////////////////////////////////// MSSIM /////////////////////////////////////////////////
if (psnrV < psnrTriggerValue) if (psnrV < psnrTriggerValue && psnrV)
{ {
mssimV = getMSSIM(frameReference,frameUnderTest); mssimV = getMSSIM(frameReference,frameUnderTest);
cout << " MSSIM: " cout << " MSSIM: "
<< "R" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[2] * 100 << " R " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[2] * 100 << "%"
<< "G" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[1] * 100 << " G " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[1] * 100 << "%"
<< "B" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[0] * 100; << " B " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[0] * 100 << "%";
} }
cout << endl; cout << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment