From e87355463f27702f5c398b22b05021f8290e5329 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Sat, 26 Jan 2013 16:38:01 -0500 Subject: [PATCH 1/9] {highgui} Fix copy-paste error in conditional --- modules/highgui/src/grfmt_jpeg2000.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/grfmt_jpeg2000.cpp b/modules/highgui/src/grfmt_jpeg2000.cpp index f1908356e4..d9080e5d44 100644 --- a/modules/highgui/src/grfmt_jpeg2000.cpp +++ b/modules/highgui/src/grfmt_jpeg2000.cpp @@ -212,7 +212,7 @@ bool Jpeg2KDecoder::readData( Mat& img ) cmptlut[0] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_B ); cmptlut[1] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_G ); cmptlut[2] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_R ); - if( cmptlut[0] < 0 || cmptlut[1] < 0 || cmptlut[0] < 0 ) + if( cmptlut[0] < 0 || cmptlut[1] < 0 || cmptlut[2] < 0 ) result = false; ncmpts = 3; } From d83914d478cad099a80148978a8a659f921030d2 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 28 Jan 2013 14:01:22 +0400 Subject: [PATCH 2/9] Change Imgproc_ prefix to Photo_ in all accuracy tests of photo module --- modules/photo/test/test_denoising.cpp | 9 ++++----- modules/photo/test/test_inpaint.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/photo/test/test_denoising.cpp b/modules/photo/test/test_denoising.cpp index 7312bbbafa..24fd613841 100644 --- a/modules/photo/test/test_denoising.cpp +++ b/modules/photo/test/test_denoising.cpp @@ -56,7 +56,7 @@ using namespace std; #endif -TEST(Imgproc_DenoisingGrayscale, regression) +TEST(Photo_DenoisingGrayscale, regression) { string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; string original_path = folder + "lena_noised_gaussian_sigma=10.png"; @@ -76,7 +76,7 @@ TEST(Imgproc_DenoisingGrayscale, regression) ASSERT_EQ(0, norm(result != expected)); } -TEST(Imgproc_DenoisingColored, regression) +TEST(Photo_DenoisingColored, regression) { string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; string original_path = folder + "lena_noised_gaussian_sigma=10.png"; @@ -96,7 +96,7 @@ TEST(Imgproc_DenoisingColored, regression) ASSERT_EQ(0, norm(result != expected)); } -TEST(Imgproc_DenoisingGrayscaleMulti, regression) +TEST(Photo_DenoisingGrayscaleMulti, regression) { const int imgs_count = 3; string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; @@ -121,7 +121,7 @@ TEST(Imgproc_DenoisingGrayscaleMulti, regression) ASSERT_EQ(0, norm(result != expected)); } -TEST(Imgproc_DenoisingColoredMulti, regression) +TEST(Photo_DenoisingColoredMulti, regression) { const int imgs_count = 3; string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; @@ -145,4 +145,3 @@ TEST(Imgproc_DenoisingColoredMulti, regression) ASSERT_EQ(0, norm(result != expected)); } - diff --git a/modules/photo/test/test_inpaint.cpp b/modules/photo/test/test_inpaint.cpp index 8181c1ca56..26a997e29d 100644 --- a/modules/photo/test/test_inpaint.cpp +++ b/modules/photo/test/test_inpaint.cpp @@ -115,4 +115,4 @@ void CV_InpaintTest::run( int ) ts->set_failed_test_info(cvtest::TS::OK); } -TEST(Imgproc_Inpaint, regression) { CV_InpaintTest test; test.safe_run(); } +TEST(Photo_Inpaint, regression) { CV_InpaintTest test; test.safe_run(); } From 7e92826efcfbe115d3f61e5d98035edba8424d27 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 28 Jan 2013 14:02:05 +0400 Subject: [PATCH 3/9] Add test for issue #2646 --- modules/photo/test/test_denoising.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/photo/test/test_denoising.cpp b/modules/photo/test/test_denoising.cpp index 24fd613841..55e876c635 100644 --- a/modules/photo/test/test_denoising.cpp +++ b/modules/photo/test/test_denoising.cpp @@ -145,3 +145,14 @@ TEST(Photo_DenoisingColoredMulti, regression) ASSERT_EQ(0, norm(result != expected)); } + +TEST(Photo_White, issue_2646) +{ + cv::Mat img(50, 50, CV_8UC1, cv::Scalar::all(255)); + cv::Mat filtered; + cv::fastNlMeansDenoising(img, filtered); + + int nonWhitePixelsCount = (int)img.total() - cv::countNonZero(filtered == img); + + ASSERT_EQ(0, nonWhitePixelsCount); +} From 737444539831e1094463801c6d5f59ee464a01ad Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 28 Jan 2013 14:30:06 +0400 Subject: [PATCH 4/9] Fix integer overflow in NL-Means denoising on white input Issues #2646 --- modules/photo/src/fast_nlmeans_denoising_invoker.hpp | 2 +- modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp index 1dcb6b3ece..c4f13826d2 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp @@ -257,7 +257,7 @@ void FastNlMeansDenoisingInvoker::operator() (const BlockedRange& range) cons } for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++) - estimation[channel_num] = (estimation[channel_num] + weights_sum/2) / weights_sum; + estimation[channel_num] = ((unsigned)estimation[channel_num] + weights_sum/2) / weights_sum; dst_.at(i,j) = saturateCastFromArray(estimation); } diff --git a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp index 870760b48b..2ae5054e00 100644 --- a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp @@ -287,7 +287,7 @@ void FastNlMeansMultiDenoisingInvoker::operator() (const BlockedRange& range) } for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++) - estimation[channel_num] = (estimation[channel_num] + weights_sum / 2) / weights_sum; + estimation[channel_num] = ((unsigned)estimation[channel_num] + weights_sum / 2) / weights_sum; dst_.at(i,j) = saturateCastFromArray(estimation); From 255cd61a8cd6130072a110dd96a40e68ae065fbf Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 28 Jan 2013 15:49:31 +0400 Subject: [PATCH 5/9] Improve error reporting of JPEG image encoder OpenCV issue #2604 After this patch applied an attempt to encode empty images produces exception saying "Raw image encoder error: Empty JPEG image (DNL not supported)" --- modules/highgui/src/grfmt_base.cpp | 9 +++++++++ modules/highgui/src/grfmt_base.hpp | 4 ++++ modules/highgui/src/grfmt_jpeg.cpp | 12 +++++++++++- modules/highgui/src/loadsave.cpp | 4 ++++ modules/highgui/test/test_grfmt.cpp | 9 +++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/highgui/src/grfmt_base.cpp b/modules/highgui/src/grfmt_base.cpp index 405cf8b88f..bd9d98e2f4 100644 --- a/modules/highgui/src/grfmt_base.cpp +++ b/modules/highgui/src/grfmt_base.cpp @@ -123,6 +123,15 @@ ImageEncoder BaseImageEncoder::newEncoder() const return ImageEncoder(); } +void BaseImageEncoder::throwOnEror() const +{ + if(!m_last_error.empty()) + { + std::string msg = "Raw image encoder error: " + m_last_error; + CV_Error( CV_BadImageSize, msg.c_str() ); + } +} + } /* End of file. */ diff --git a/modules/highgui/src/grfmt_base.hpp b/modules/highgui/src/grfmt_base.hpp index 8c0130556d..49420f431a 100644 --- a/modules/highgui/src/grfmt_base.hpp +++ b/modules/highgui/src/grfmt_base.hpp @@ -100,12 +100,16 @@ public: virtual string getDescription() const; virtual ImageEncoder newEncoder() const; + virtual void throwOnEror() const; + protected: string m_description; string m_filename; vector* m_buf; bool m_buf_supported; + + string m_last_error; }; } diff --git a/modules/highgui/src/grfmt_jpeg.cpp b/modules/highgui/src/grfmt_jpeg.cpp index 521517639f..3dedf440de 100644 --- a/modules/highgui/src/grfmt_jpeg.cpp +++ b/modules/highgui/src/grfmt_jpeg.cpp @@ -537,8 +537,10 @@ ImageEncoder JpegEncoder::newEncoder() const return new JpegEncoder; } -bool JpegEncoder::write( const Mat& img, const vector& params ) +bool JpegEncoder::write( const Mat& img, const vector& params ) { + m_last_error.clear(); + struct fileWrapper { FILE* f; @@ -633,6 +635,14 @@ bool JpegEncoder::write( const Mat& img, const vector& params ) } _exit_: + + if(!result) + { + char jmsg_buf[JMSG_LENGTH_MAX]; + jerr.pub.format_message((j_common_ptr)&cinfo, jmsg_buf); + m_last_error = jmsg_buf; + } + jpeg_destroy_compress( &cinfo ); return result; diff --git a/modules/highgui/src/loadsave.cpp b/modules/highgui/src/loadsave.cpp index 667c2d16e7..6658b1335e 100644 --- a/modules/highgui/src/loadsave.cpp +++ b/modules/highgui/src/loadsave.cpp @@ -426,6 +426,7 @@ bool imencode( const string& ext, InputArray _image, if( encoder->setDestination(buf) ) { code = encoder->write(image, params); + encoder->throwOnEror(); CV_Assert( code ); } else @@ -433,8 +434,11 @@ bool imencode( const string& ext, InputArray _image, string filename = tempfile(); code = encoder->setDestination(filename); CV_Assert( code ); + code = encoder->write(image, params); + encoder->throwOnEror(); CV_Assert( code ); + FILE* f = fopen( filename.c_str(), "rb" ); CV_Assert(f != 0); fseek( f, 0, SEEK_END ); diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index 5159a25a48..7226ebf7cb 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -282,3 +282,12 @@ TEST(Highgui_ImreadVSCvtColor, regression) } #endif +#ifdef HAVE_JPEG +TEST(Highgui_Jpeg, encode_empty) +{ + cv::Mat img; + std::vector jpegImg; + + ASSERT_THROW(cv::imencode(".jpg", img, jpegImg), cv::Exception); +} +#endif From f9bff103dd69baf62a7e3ad9fed846f2b71b838d Mon Sep 17 00:00:00 2001 From: Daniil Osokin Date: Mon, 28 Jan 2013 15:14:32 +0400 Subject: [PATCH 6/9] Removed obsolete steps from Windows installation tutorial (bug #2550) --- .../windows_install/windows_install.rst | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/doc/tutorials/introduction/windows_install/windows_install.rst b/doc/tutorials/introduction/windows_install/windows_install.rst index 62acf0e22c..d1ae8fa1f6 100644 --- a/doc/tutorials/introduction/windows_install/windows_install.rst +++ b/doc/tutorials/introduction/windows_install/windows_install.rst @@ -20,11 +20,7 @@ Installation by Using the Pre-built Libraries .. If you downloaded the source files present here see :ref:`CppTutWindowsMakeOwn`. -#. Make sure you have admin rights. Start the setup and follow the wizard. - -#. While adding the OpenCV library to the system path is a good decision for a better control, we will do it manually for the sake of this tutorial. Make sure you do not set this option. - -#. Most of the time it is a good idea to install the source files too, as this will allow for you to debug into the OpenCV library, if it is necessary. Follow the default settings of the wizard and finish the installation. +#. Make sure you have admin rights. Unpack the self-extracting archive. #. You can check the installation at the chosen path as you can see below. @@ -294,15 +290,7 @@ Building the library :alt: The Install Project :align: center - This will create an *install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions. - - .. note:: - - To create an installer you need to install `NSIS `_. Then just build the *Package* project to build the installer into the :file:`Build/_CPack_Packages/{win32}/NSIS` folder. You can then use this to distribute OpenCV with your build settings on other systems. - - .. image:: images/WindowsOpenCVInstaller.png - :alt: The Installer directory - :align: center + This will create an *Install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions. To test your build just go into the :file:`Build/bin/Debug` or :file:`Build/bin/Release` directory and start a couple of applications like the *contours.exe*. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us via our :opencv_group:`user group <>`. If everything is okay the *contours.exe* output should resemble the following image (if built with Qt support): @@ -320,15 +308,15 @@ Building the library Set the OpenCV enviroment variable and add it to the systems path ================================================================= -First we set an enviroment variable to make easier our work. This will hold the install directory of our OpenCV library that we use in our projects. Start up a command window and enter: +First we set an enviroment variable to make easier our work. This will hold the build directory of our OpenCV library that we use in our projects. Start up a command window and enter: :: - setx -m OPENCV_DIR D:\OpenCV\Build\Install + setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10 -Here the directory is where you have your OpenCV binaries (*installed* or *built*). Inside this you should have folders like *bin* and *include*. The -m should be added if you wish to make the settings computer wise, instead of user wise. +Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have folders like *bin* and *include*. The -m should be added if you wish to make the settings computer wise, instead of user wise. -If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path.This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu): +If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path. This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu): :: @@ -342,6 +330,6 @@ If you built static libraries then you are done. Otherwise, you need to add the :alt: Add the entry. :align: center -Save it to the registry and you are done. If you ever change the location of your install directories or want to try out your applicaton with a different build all you will need to do is to update the OPENCV_DIR variable via the *setx* command inside a command window. +Save it to the registry and you are done. If you ever change the location of your build directories or want to try out your applicaton with a different build all you will need to do is to update the OPENCV_DIR variable via the *setx* command inside a command window. Now you can continue reading the tutorials with the :ref:`Windows_Visual_Studio_How_To` section. There you will find out how to use the OpenCV library in your own projects with the help of the Microsoft Visual Studio IDE. From 4c9c27b244973a6681d6eefa5ef0520277d622c5 Mon Sep 17 00:00:00 2001 From: Daniil Osokin Date: Mon, 28 Jan 2013 18:29:01 +0400 Subject: [PATCH 7/9] Fixed formula of YCrCb to RGB conversion (bug #2725) --- modules/imgproc/doc/miscellaneous_transformations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index 6d91d8956c..4ebf6d5ee5 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -183,7 +183,7 @@ The function can do the following transformations: .. math:: - G \leftarrow Y - 0.344 \cdot (Cr - delta) - 0.714 \cdot (Cb - delta) + G \leftarrow Y - 0.714 \cdot (Cr - delta) - 0.344 \cdot (Cb - delta) .. math:: From e33f3e8345f04acdfe08b745f167cf17b319516c Mon Sep 17 00:00:00 2001 From: Daniil Osokin Date: Mon, 28 Jan 2013 18:41:59 +0400 Subject: [PATCH 8/9] Fixed cheatsheet for loop (bug #2701) --- doc/opencv_cheatsheet.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/opencv_cheatsheet.tex b/doc/opencv_cheatsheet.tex index f00ea045b4..e76bd016e9 100644 --- a/doc/opencv_cheatsheet.tex +++ b/doc/opencv_cheatsheet.tex @@ -215,7 +215,7 @@ \> \texttt{for(int y = 1; y < image.rows-1; y++) \{}\\ \> \> \texttt{Vec3b* prevRow = image.ptr(y-1);}\\ \> \> \texttt{Vec3b* nextRow = image.ptr(y+1);}\\ -\> \> \texttt{for(int x = 0; y < image.cols; x++)}\\ +\> \> \texttt{for(int x = 0; x < image.cols; x++)}\\ \> \> \> \texttt{for(int c = 0; c < 3; c++)}\\ \> \> \> \texttt{ dyImage.at(y,x)[c] =}\\ \> \> \> \texttt{ saturate\_cast(}\\ From ca98710640c62bcd1a66bde07d45198212d7d9ed Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 28 Jan 2013 19:44:58 +0400 Subject: [PATCH 9/9] Resolve warning in OpenCV Library project in Eclipse (Bug #2714) Warning in auto generated code was suppressed by project settings. --- modules/java/android_lib/.settings/org.eclipse.jdt.core.prefs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 modules/java/android_lib/.settings/org.eclipse.jdt.core.prefs diff --git a/modules/java/android_lib/.settings/org.eclipse.jdt.core.prefs b/modules/java/android_lib/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..ea89babcdb --- /dev/null +++ b/modules/java/android_lib/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore