Commit 0734d9b8 authored by Andrey Kamaev's avatar Andrey Kamaev

Merge branch '2.4'

parents 9de36c55 2b4ffd11
...@@ -215,7 +215,7 @@ ...@@ -215,7 +215,7 @@
\> \texttt{for(int y = 1; y < image.rows-1; y++) \{}\\ \> \texttt{for(int y = 1; y < image.rows-1; y++) \{}\\
\> \> \texttt{Vec3b* prevRow = image.ptr<Vec3b>(y-1);}\\ \> \> \texttt{Vec3b* prevRow = image.ptr<Vec3b>(y-1);}\\
\> \> \texttt{Vec3b* nextRow = image.ptr<Vec3b>(y+1);}\\ \> \> \texttt{Vec3b* nextRow = image.ptr<Vec3b>(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{for(int c = 0; c < 3; c++)}\\
\> \> \> \texttt{ dyImage.at<Vec3b>(y,x)[c] =}\\ \> \> \> \texttt{ dyImage.at<Vec3b>(y,x)[c] =}\\
\> \> \> \texttt{ saturate\_cast<uchar>(}\\ \> \> \> \texttt{ saturate\_cast<uchar>(}\\
......
...@@ -20,11 +20,7 @@ Installation by Using the Pre-built Libraries ...@@ -20,11 +20,7 @@ Installation by Using the Pre-built Libraries
.. If you downloaded the source files present here see :ref:`CppTutWindowsMakeOwn`. .. If you downloaded the source files present here see :ref:`CppTutWindowsMakeOwn`.
#. Make sure you have admin rights. Start the setup and follow the wizard. #. Make sure you have admin rights. Unpack the self-extracting archive.
#. 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.
#. You can check the installation at the chosen path as you can see below. #. You can check the installation at the chosen path as you can see below.
...@@ -294,15 +290,7 @@ Building the library ...@@ -294,15 +290,7 @@ Building the library
:alt: The Install Project :alt: The Install Project
:align: center :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. 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 <http://nsis.sourceforge.net/Download>`_. 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
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 <>`. 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): 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 ...@@ -320,15 +308,15 @@ Building the library
Set the OpenCV enviroment variable and add it to the systems path 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 ...@@ -342,6 +330,6 @@ If you built static libraries then you are done. Otherwise, you need to add the
:alt: Add the entry. :alt: Add the entry.
:align: center :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. 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.
...@@ -123,6 +123,15 @@ ImageEncoder BaseImageEncoder::newEncoder() const ...@@ -123,6 +123,15 @@ ImageEncoder BaseImageEncoder::newEncoder() const
return ImageEncoder(); 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. */ /* End of file. */
...@@ -100,12 +100,16 @@ public: ...@@ -100,12 +100,16 @@ public:
virtual string getDescription() const; virtual string getDescription() const;
virtual ImageEncoder newEncoder() const; virtual ImageEncoder newEncoder() const;
virtual void throwOnEror() const;
protected: protected:
string m_description; string m_description;
string m_filename; string m_filename;
vector<uchar>* m_buf; vector<uchar>* m_buf;
bool m_buf_supported; bool m_buf_supported;
string m_last_error;
}; };
} }
......
...@@ -537,8 +537,10 @@ ImageEncoder JpegEncoder::newEncoder() const ...@@ -537,8 +537,10 @@ ImageEncoder JpegEncoder::newEncoder() const
return new JpegEncoder; return new JpegEncoder;
} }
bool JpegEncoder::write( const Mat& img, const vector<int>& params ) bool JpegEncoder::write( const Mat& img, const vector<int>& params )
{ {
m_last_error.clear();
struct fileWrapper struct fileWrapper
{ {
FILE* f; FILE* f;
...@@ -633,6 +635,14 @@ bool JpegEncoder::write( const Mat& img, const vector<int>& params ) ...@@ -633,6 +635,14 @@ bool JpegEncoder::write( const Mat& img, const vector<int>& params )
} }
_exit_: _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 ); jpeg_destroy_compress( &cinfo );
return result; return result;
......
...@@ -212,7 +212,7 @@ bool Jpeg2KDecoder::readData( Mat& img ) ...@@ -212,7 +212,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
cmptlut[0] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_B ); cmptlut[0] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_B );
cmptlut[1] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_G ); cmptlut[1] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_G );
cmptlut[2] = jas_image_getcmptbytype( image, JAS_IMAGE_CT_RGB_R ); 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; result = false;
ncmpts = 3; ncmpts = 3;
} }
......
...@@ -420,6 +420,7 @@ bool imencode( const string& ext, InputArray _image, ...@@ -420,6 +420,7 @@ bool imencode( const string& ext, InputArray _image,
if( encoder->setDestination(buf) ) if( encoder->setDestination(buf) )
{ {
code = encoder->write(image, params); code = encoder->write(image, params);
encoder->throwOnEror();
CV_Assert( code ); CV_Assert( code );
} }
else else
...@@ -427,8 +428,11 @@ bool imencode( const string& ext, InputArray _image, ...@@ -427,8 +428,11 @@ bool imencode( const string& ext, InputArray _image,
string filename = tempfile(); string filename = tempfile();
code = encoder->setDestination(filename); code = encoder->setDestination(filename);
CV_Assert( code ); CV_Assert( code );
code = encoder->write(image, params); code = encoder->write(image, params);
encoder->throwOnEror();
CV_Assert( code ); CV_Assert( code );
FILE* f = fopen( filename.c_str(), "rb" ); FILE* f = fopen( filename.c_str(), "rb" );
CV_Assert(f != 0); CV_Assert(f != 0);
fseek( f, 0, SEEK_END ); fseek( f, 0, SEEK_END );
......
...@@ -282,3 +282,12 @@ TEST(Highgui_ImreadVSCvtColor, regression) ...@@ -282,3 +282,12 @@ TEST(Highgui_ImreadVSCvtColor, regression)
} }
#endif #endif
#ifdef HAVE_JPEG
TEST(Highgui_Jpeg, encode_empty)
{
cv::Mat img;
std::vector<uchar> jpegImg;
ASSERT_THROW(cv::imencode(".jpg", img, jpegImg), cv::Exception);
}
#endif
...@@ -183,7 +183,7 @@ The function can do the following transformations: ...@@ -183,7 +183,7 @@ The function can do the following transformations:
.. math:: .. 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:: .. math::
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
...@@ -257,7 +257,7 @@ void FastNlMeansDenoisingInvoker<T>::operator() (const BlockedRange& range) cons ...@@ -257,7 +257,7 @@ void FastNlMeansDenoisingInvoker<T>::operator() (const BlockedRange& range) cons
} }
for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++) 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<T>(i,j) = saturateCastFromArray<T>(estimation); dst_.at<T>(i,j) = saturateCastFromArray<T>(estimation);
} }
......
...@@ -287,7 +287,7 @@ void FastNlMeansMultiDenoisingInvoker<T>::operator() (const BlockedRange& range) ...@@ -287,7 +287,7 @@ void FastNlMeansMultiDenoisingInvoker<T>::operator() (const BlockedRange& range)
} }
for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++) 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<T>(i,j) = saturateCastFromArray<T>(estimation); dst_.at<T>(i,j) = saturateCastFromArray<T>(estimation);
......
...@@ -56,7 +56,7 @@ using namespace std; ...@@ -56,7 +56,7 @@ using namespace std;
#endif #endif
TEST(Imgproc_DenoisingGrayscale, regression) TEST(Photo_DenoisingGrayscale, regression)
{ {
string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/";
string original_path = folder + "lena_noised_gaussian_sigma=10.png"; string original_path = folder + "lena_noised_gaussian_sigma=10.png";
...@@ -76,7 +76,7 @@ TEST(Imgproc_DenoisingGrayscale, regression) ...@@ -76,7 +76,7 @@ TEST(Imgproc_DenoisingGrayscale, regression)
ASSERT_EQ(0, norm(result != expected)); 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 folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/";
string original_path = folder + "lena_noised_gaussian_sigma=10.png"; string original_path = folder + "lena_noised_gaussian_sigma=10.png";
...@@ -96,7 +96,7 @@ TEST(Imgproc_DenoisingColored, regression) ...@@ -96,7 +96,7 @@ TEST(Imgproc_DenoisingColored, regression)
ASSERT_EQ(0, norm(result != expected)); ASSERT_EQ(0, norm(result != expected));
} }
TEST(Imgproc_DenoisingGrayscaleMulti, regression) TEST(Photo_DenoisingGrayscaleMulti, regression)
{ {
const int imgs_count = 3; const int imgs_count = 3;
string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/";
...@@ -121,7 +121,7 @@ TEST(Imgproc_DenoisingGrayscaleMulti, regression) ...@@ -121,7 +121,7 @@ TEST(Imgproc_DenoisingGrayscaleMulti, regression)
ASSERT_EQ(0, norm(result != expected)); ASSERT_EQ(0, norm(result != expected));
} }
TEST(Imgproc_DenoisingColoredMulti, regression) TEST(Photo_DenoisingColoredMulti, regression)
{ {
const int imgs_count = 3; const int imgs_count = 3;
string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/";
...@@ -146,3 +146,13 @@ TEST(Imgproc_DenoisingColoredMulti, regression) ...@@ -146,3 +146,13 @@ TEST(Imgproc_DenoisingColoredMulti, regression)
ASSERT_EQ(0, norm(result != expected)); 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);
}
...@@ -115,4 +115,4 @@ void CV_InpaintTest::run( int ) ...@@ -115,4 +115,4 @@ void CV_InpaintTest::run( int )
ts->set_failed_test_info(cvtest::TS::OK); 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(); }
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