...
 
Commits (11)
    https://gitcode.net/greenplum/opencv/-/commit/ddcbd2cc268f6293bb636a41c1aa19dfb3c181ad Merge pull request #22798 from lamm45:distransform-large 2023-06-19T15:11:01+03:00 lamm45 96844552+lamm45@users.noreply.github.com Fix distransform to work with large images #22798 This attempts to fix the following bug which was caused by storing squares of large integers into 32-bit floating point variables: <a href="https://github.com/opencv/opencv/issues/22732" rel="nofollow noreferrer noopener" target="_blank">https://github.com/opencv/opencv/issues/22732</a> ### Pull Request Readiness Checklist See details at <a href="https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request" rel="nofollow noreferrer noopener" target="_blank">https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request</a> - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake https://gitcode.net/greenplum/opencv/-/commit/805946baaf43a0a862cb678b4c1841ab01ee697a pre: OpenCV 3.4.20 (version++) 2023-06-20T14:10:08+03:00 Alexander Smorkalov alexander.smorkalov@xperience.ai https://gitcode.net/greenplum/opencv/-/commit/c97c22b7cf2ef0f82cd4203a2e9a6eda94e9f7f1 Merge pull request #23831 from asmorkalov:update_version_3.4.20-pre 2023-06-20T16:25:55+03:00 Alexander Smorkalov 2536374+asmorkalov@users.noreply.github.com pre: OpenCV 3.4.20 (version++) https://gitcode.net/greenplum/opencv/-/commit/9eaa7bd566863f86776fbbc5635edfa3f399d812 Document parameters of multi-dimentional reshape. 2023-06-20T21:54:49+03:00 Alexander Smorkalov alexander.smorkalov@xperience.ai https://gitcode.net/greenplum/opencv/-/commit/65b957a5b306f4f75954419931363932f158312b Merge pull request #23832 from asmorkalov:as/reshape_docs 2023-06-21T09:04:17+03:00 Alexander Smorkalov 2536374+asmorkalov@users.noreply.github.com Document parameters of multi-dimentional reshape https://gitcode.net/greenplum/opencv/-/commit/fe93724d3feed581d34adc2ee342fd7b835a0a3a FFmpeg wrapper update to FFmpeg version 3.4.13. 2023-06-21T09:22:26+03:00 Alexander Smorkalov alexander.smorkalov@xperience.ai https://gitcode.net/greenplum/opencv/-/commit/b7947d861cc4882e05816295d2a23b7346836960 Merge pull request #23841 from asmorkalov:as/ffmpeg_update_3.4 2023-06-21T16:09:54+03:00 Alexander Smorkalov 2536374+asmorkalov@users.noreply.github.com FFmpeg/3.4: update FFmpeg wrapper 2023.6 https://gitcode.net/greenplum/opencv/-/commit/3b264d5877bbdbe8c45c9e55b7543217351da8b5 Add `pthread.h` Inclusion if `HAVE_PTHREADS_PF` is defined 2023-06-23T17:53:03+09:00 Paul Kim (김형준) 44695374+thekpaul@users.noreply.github.com Single-case tested with success on Windows 11 with MinGW-w64 Standalone GCC v13.1.0 while building OpenCV 4.7.0 https://gitcode.net/greenplum/opencv/-/commit/d4f81c6d24d6bd9397a037df2f2834e8c9efb63d Merge pull request #23855 from thekpaul:3.4_patched 2023-06-23T13:07:45+03:00 Alexander Smorkalov 2536374+asmorkalov@users.noreply.github.com Add `pthread.h` Inclusion if `HAVE_PTHREADS_PF` is defined https://gitcode.net/greenplum/opencv/-/commit/29388f80a58b953850f23bb8a0efea557e232b7d fix overflow 2023-06-23T21:22:21+08:00 fengyuentau yuantao.feng@opencv.org.cn https://gitcode.net/greenplum/opencv/-/commit/d9a5603fa36834f4e00b1d9cf32bd0ad02b82dc9 Merge pull request #23860 from fengyuentau:fix_overflow_sigmoid_v3.4 2023-06-23T19:47:42+03:00 Alexander Smorkalov 2536374+asmorkalov@users.noreply.github.com dnn: fix overflow in sigmoid layer for 3.4
# Binaries branch name: ffmpeg/3.4_20211220
# Binaries were created for OpenCV: a22dd28e0272ec0f1cfee8811d3f5f0392827c65
ocv_update(FFMPEG_BINARIES_COMMIT "5a7644ec3940c6eed41c6ebb5a0602a5615fdb3f")
ocv_update(FFMPEG_FILE_HASH_BIN32 "8ad9de6f1f2ca77786748d1f3a4e83ea")
ocv_update(FFMPEG_FILE_HASH_BIN64 "2c670f068252e7cd28d3883993dc1d6e")
# Binaries branch name: 3.4_20230620
# Binaries were created for OpenCV: c97c22b7cf2ef0f82cd4203a2e9a6eda94e9f7f1
ocv_update(FFMPEG_BINARIES_COMMIT "7c4bb90fd43a13732ae907981a88fb983a7e2197")
ocv_update(FFMPEG_FILE_HASH_BIN32 "d7db86de29b0460294489c5ed3180b56")
ocv_update(FFMPEG_FILE_HASH_BIN64 "9df93d8afff2eee368ad484098a12b18")
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
function(download_win_ffmpeg script_var)
......
......@@ -39,14 +39,14 @@ Open your Doxyfile using your favorite text editor and search for the key
`TAGFILES`. Change it as follows:
@code
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.19
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.20
@endcode
If you had other definitions already, you can append the line using a `\`:
@code
TAGFILES = ./docs/doxygen-tags/libstdc++.tag=https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen \
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.19
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.20
@endcode
Doxygen can now use the information from the tag file to link to the OpenCV
......
......@@ -1305,15 +1305,36 @@ public:
t(); // finally, transpose the Nx3 matrix.
// This involves copying all the elements
@endcode
3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels:
@code
Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3));
vector<int> new_shape {4, 3};
m = m.reshape(1, new_shape);
@endcode
or:
@code
Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3));
const int new_shape[] = {4, 3};
m = m.reshape(1, 2, new_shape);
@endcode
@param cn New number of channels. If the parameter is 0, the number of channels remains the same.
@param rows New number of rows. If the parameter is 0, the number of rows remains the same.
*/
Mat reshape(int cn, int rows=0) const;
/** @overload */
/** @overload
* @param cn New number of channels. If the parameter is 0, the number of channels remains the same.
* @param newndims New number of dimentions.
* @param newsz Array with new matrix size by all dimentions. If some sizes are zero,
* the original sizes in those dimensions are presumed.
*/
Mat reshape(int cn, int newndims, const int* newsz) const;
/** @overload */
/** @overload
* @param cn New number of channels. If the parameter is 0, the number of channels remains the same.
* @param newshape Vector with new matrix size by all dimentions. If some sizes are zero,
* the original sizes in those dimensions are presumed.
*/
Mat reshape(int cn, const std::vector<int>& newshape) const;
/** @brief Transposes a matrix.
......
......@@ -7,8 +7,8 @@
#define CV_VERSION_MAJOR 3
#define CV_VERSION_MINOR 4
#define CV_VERSION_REVISION 19
#define CV_VERSION_STATUS "-dev"
#define CV_VERSION_REVISION 20
#define CV_VERSION_STATUS "-pre"
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
......
......@@ -118,6 +118,8 @@
#include <ppltasks.h>
#elif defined HAVE_CONCURRENCY
#include <ppl.h>
#elif defined HAVE_PTHREADS_PF
#include <pthread.h>
#endif
......
......@@ -680,7 +680,14 @@ struct SigmoidFunctor : public BaseDefaultFunctor<SigmoidFunctor>
inline float calculate(float x) const
{
return 1.f / (1.f + exp(-x));
float y;
if (x >= 0)
y = 1.f / (1.f + exp(-x));
else {
y = exp(x);
y = y / (1 + y);
}
return y;
}
#ifdef HAVE_HALIDE
......
......@@ -448,7 +448,7 @@ static void getDistanceTransformMask( int maskType, float *metrics )
struct DTColumnInvoker : ParallelLoopBody
{
DTColumnInvoker( const Mat* _src, Mat* _dst, const int* _sat_tab, const float* _sqr_tab)
DTColumnInvoker( const Mat* _src, Mat* _dst, const int* _sat_tab, const int* _sqr_tab)
{
src = _src;
dst = _dst;
......@@ -481,7 +481,7 @@ struct DTColumnInvoker : ParallelLoopBody
{
dist = dist + 1 - sat_tab[dist - d[j]];
d[j] = dist;
dptr[0] = sqr_tab[dist];
dptr[0] = (float)sqr_tab[dist];
}
}
}
......@@ -489,12 +489,12 @@ struct DTColumnInvoker : ParallelLoopBody
const Mat* src;
Mat* dst;
const int* sat_tab;
const float* sqr_tab;
const int* sqr_tab;
};
struct DTRowInvoker : ParallelLoopBody
{
DTRowInvoker( Mat* _dst, const float* _sqr_tab, const float* _inv_tab )
DTRowInvoker( Mat* _dst, const int* _sqr_tab, const float* _inv_tab )
{
dst = _dst;
sqr_tab = _sqr_tab;
......@@ -529,7 +529,7 @@ struct DTRowInvoker : ParallelLoopBody
for(;;k--)
{
p = v[k];
float s = (fq + sqr_tab[q] - d[p] - sqr_tab[p])*inv_tab[q - p];
float s = (fq - d[p] + (sqr_tab[q]-sqr_tab[p]))*inv_tab[q - p];
if( s > z[k] )
{
k++;
......@@ -552,28 +552,28 @@ struct DTRowInvoker : ParallelLoopBody
}
Mat* dst;
const float* sqr_tab;
const int* sqr_tab;
const float* inv_tab;
};
static void
trueDistTrans( const Mat& src, Mat& dst )
{
const float inf = 1e15f;
const int inf = INT_MAX;
CV_Assert( src.size() == dst.size() );
CV_Assert( src.type() == CV_8UC1 && dst.type() == CV_32FC1 );
int i, m = src.rows, n = src.cols;
cv::AutoBuffer<uchar> _buf(std::max(m*2*sizeof(float) + (m*3+1)*sizeof(int), n*2*sizeof(float)));
cv::AutoBuffer<uchar> _buf(std::max(m*2*sizeof(int) + (m*3+1)*sizeof(int), n*2*sizeof(float)));
// stage 1: compute 1d distance transform of each column
float* sqr_tab = (float*)_buf.data();
int* sqr_tab = (int*)_buf.data();
int* sat_tab = cv::alignPtr((int*)(sqr_tab + m*2), sizeof(int));
int shift = m*2;
for( i = 0; i < m; i++ )
sqr_tab[i] = (float)(i*i);
sqr_tab[i] = i*i;
for( i = m; i < m*2; i++ )
sqr_tab[i] = inf;
for( i = 0; i < shift; i++ )
......@@ -584,13 +584,14 @@ trueDistTrans( const Mat& src, Mat& dst )
cv::parallel_for_(cv::Range(0, n), cv::DTColumnInvoker(&src, &dst, sat_tab, sqr_tab), src.total()/(double)(1<<16));
// stage 2: compute modified distance transform for each row
float* inv_tab = sqr_tab + n;
float* inv_tab = (float*)sqr_tab + n;
inv_tab[0] = sqr_tab[0] = 0.f;
inv_tab[0] = 0.f;
sqr_tab[0] = 0;
for( i = 1; i < n; i++ )
{
inv_tab[i] = (float)(0.5/i);
sqr_tab[i] = (float)(i*i);
sqr_tab[i] = i*i;
}
cv::parallel_for_(cv::Range(0, m), cv::DTRowInvoker(&dst, sqr_tab, inv_tab));
......@@ -752,7 +753,9 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
CV_IPP_CHECK()
{
#if IPP_DISABLE_PERF_TRUE_DIST_MT
if(cv::getNumThreads()<=1 || (src.total()<(int)(1<<14)))
// IPP uses floats, but 4097 cannot be squared into a float
if((cv::getNumThreads()<=1 || (src.total()<(int)(1<<14))) &&
src.rows < 4097 && src.cols < 4097)
#endif
{
IppStatus status;
......
......@@ -302,4 +302,46 @@ BIGDATA_TEST(Imgproc_DistanceTransform, large_image_12218)
EXPECT_EQ(nz, (size.height*size.width / 2));
}
TEST(Imgproc_DistanceTransform, wide_image_22732)
{
Mat src = Mat::zeros(1, 4099, CV_8U); // 4099 or larger used to be bad
Mat dist(src.rows, src.cols, CV_32F);
distanceTransform(src, dist, DIST_L2, DIST_MASK_PRECISE, CV_32F);
int nz = countNonZero(dist);
EXPECT_EQ(nz, 0);
}
TEST(Imgproc_DistanceTransform, large_square_22732)
{
Mat src = Mat::zeros(8000, 8005, CV_8U), dist;
distanceTransform(src, dist, DIST_L2, DIST_MASK_PRECISE, CV_32F);
int nz = countNonZero(dist);
EXPECT_EQ(dist.size(), src.size());
EXPECT_EQ(dist.type(), CV_32F);
EXPECT_EQ(nz, 0);
Point p0(src.cols-1, src.rows-1);
src.setTo(1);
src.at<uchar>(p0) = 0;
distanceTransform(src, dist, DIST_L2, DIST_MASK_PRECISE, CV_32F);
EXPECT_EQ(dist.size(), src.size());
EXPECT_EQ(dist.type(), CV_32F);
bool first = true;
int nerrs = 0;
for (int y = 0; y < dist.rows; y++)
for (int x = 0; x < dist.cols; x++) {
float d = dist.at<float>(y, x);
double dx = (double)(x - p0.x), dy = (double)(y - p0.y);
float d0 = (float)sqrt(dx*dx + dy*dy);
if (std::abs(d0 - d) > 1) {
if (first) {
printf("y=%d, x=%d. dist_ref=%.2f, dist=%.2f\n", y, x, d0, d);
first = false;
}
nerrs++;
}
}
EXPECT_EQ(0, nerrs) << "reference distance map is different from computed one at " << nerrs << " pixels\n";
}
}} // namespace
......@@ -9,7 +9,7 @@ def main():
os.chdir(SCRIPT_DIR)
package_name = 'opencv'
package_version = os.environ.get('OPENCV_VERSION', '3.4.19') # TODO
package_version = os.environ.get('OPENCV_VERSION', '3.4.20') # TODO
long_description = 'Open Source Computer Vision Library Python bindings' # TODO
......
......@@ -269,7 +269,7 @@ class Builder:
# Add extra data
apkxmldest = check_dir(os.path.join(apkdest, "res", "xml"), create=True)
apklibdest = check_dir(os.path.join(apkdest, "libs", abi.name), create=True)
for ver, d in self.extra_packs + [("3.4.19", os.path.join(self.libdest, "lib"))]:
for ver, d in self.extra_packs + [("3.4.20", os.path.join(self.libdest, "lib"))]:
r = ET.Element("library", attrib={"version": ver})
log.info("Adding libraries from %s", d)
......
......@@ -12,7 +12,7 @@ manually using adb tool:
adb install <path-to-OpenCV-sdk>/apk/OpenCV_<version>_Manager_<app_version>_<platform>.apk
Example: OpenCV_3.4.19-dev_Manager_3.49_armeabi-v7a.apk
Example: OpenCV_3.4.20-dev_Manager_3.49_armeabi-v7a.apk
Use the list of platforms below to determine proper OpenCV Manager package for your device:
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>3.4.19</version>
<version>3.4.20</version>
</parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-it</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>3.4.19</version>
<version>3.4.20</version>
</parent>
<groupId>org.opencv</groupId>
<artifactId>opencv</artifactId>
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>3.4.19</version>
<version>3.4.20</version>
<packaging>pom</packaging>
<name>OpenCV Parent POM</name>
<licenses>
......