diff --git a/modules/gpu/src/cuda/integral_image.cu b/modules/gpu/src/cuda/integral_image.cu index ec3b166572..0405f66704 100644 --- a/modules/gpu/src/cuda/integral_image.cu +++ b/modules/gpu/src/cuda/integral_image.cu @@ -50,10 +50,10 @@ namespace cv { namespace gpu { namespace device __device__ uchar4 int_to_uchar4(unsigned int in) { uchar4 bytes; - bytes.x = (in && 0x000000ff) >> 0; - bytes.y = (in && 0x0000ff00) >> 8; - bytes.z = (in && 0x00ff0000) >> 16; - bytes.w = (in && 0xff000000) >> 24; + bytes.x = (in & 0x000000ff) >> 0; + bytes.y = (in & 0x0000ff00) >> 8; + bytes.z = (in & 0x00ff0000) >> 16; + bytes.w = (in & 0xff000000) >> 24; return bytes; } diff --git a/modules/gpu/src/imgproc.cpp b/modules/gpu/src/imgproc.cpp index a4d1798fae..6dd0c71bbb 100644 --- a/modules/gpu/src/imgproc.cpp +++ b/modules/gpu/src/imgproc.cpp @@ -548,12 +548,16 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S cudaStream_t stream = StreamAccessor::getStream(s); DeviceInfo info; + cv::Size whole; + cv::Point offset; - if (info.supports(WARP_SHUFFLE_FUNCTIONS)) + src.locateROI(whole, offset); + + if (info.supports(WARP_SHUFFLE_FUNCTIONS) ) { GpuMat srcAlligned; - if (src.cols % 16 == 0 && src.rows % 8 == 0) + if (src.cols % 16 == 0 && src.rows % 8 == 0 && offset.x % 16 == 0 && offset.y % 8 == 0) srcAlligned = src; else { @@ -575,19 +579,18 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S srcAlligned = buffer; } - sum.create(srcAlligned.rows + 1, srcAlligned.cols + 1, CV_32SC1); + sum.create(srcAlligned.rows + 1, srcAlligned.cols + 4, CV_32SC1); if (s) s.enqueueMemSet(sum, Scalar::all(0)); else sum.setTo(Scalar::all(0)); - GpuMat inner = sum(Rect(1, 1, srcAlligned.cols, srcAlligned.rows)); + GpuMat inner = sum(Rect(4, 1, srcAlligned.cols, srcAlligned.rows)); cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream); - if (srcAlligned.data != src.data) - sum = sum(Rect(0, 0, src.cols + 1, src.rows + 1)); + sum = sum(Rect(3, 0, src.cols + 1, src.rows + 1)); } else { diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 0dc95d17e0..25cdbeac33 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -156,24 +156,44 @@ template<> struct ColorChannel ///////////////////////////// Top-level template function //////////////////////////////// -template void CvtColorLoop(const Mat& srcmat, Mat& dstmat, const Cvt& cvt) +template +class CvtColorLoop_Invoker : + public ParallelLoopBody { typedef typename Cvt::channel_type _Tp; - Size sz = srcmat.size(); - const uchar* src = srcmat.data; - uchar* dst = dstmat.data; - size_t srcstep = srcmat.step, dststep = dstmat.step; - - if( srcmat.isContinuous() && dstmat.isContinuous() ) +public: + + CvtColorLoop_Invoker(const Mat& _src, Mat& _dst, const Cvt& _cvt) : + ParallelLoopBody(), src(_src), dst(_dst), cvt(_cvt) { - sz.width *= sz.height; - sz.height = 1; } + + virtual void operator()(const Range& range) const + { + int i = range.start; + const uchar* yS = src.data + src.step * i; + uchar* yD = dst.data + dst.step * i; - for( ; sz.height--; src += srcstep, dst += dststep ) - cvt((const _Tp*)src, (_Tp*)dst, sz.width); -} + for ( ; i < range.end; ++i, yS += src.step, yD += dst.step ) + cvt((const _Tp*)yS, (_Tp*)yD, src.cols); + } + +private: + const Mat src; + Mat dst; + const Cvt cvt; + + CvtColorLoop_Invoker(const CvtColorLoop_Invoker&); + const CvtColorLoop_Invoker& operator= (const CvtColorLoop_Invoker&); +}; +template +void CvtColorLoop(const Mat& src, Mat& dst, const Cvt& cvt) +{ + Range range(0, src.rows); + CvtColorLoop_Invoker invoker(src, dst, cvt); + parallel_for_(range, invoker); +} ////////////////// Various 3/4-channel to 3/4-channel RGB transformations ///////////////// diff --git a/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java b/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java index d45272b010..ba6e89c999 100644 --- a/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java +++ b/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java @@ -1,6 +1,7 @@ package org.opencv.test.highgui; import org.opencv.core.MatOfByte; +import org.opencv.core.MatOfInt; import org.opencv.highgui.Highgui; import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestRunner; @@ -19,7 +20,20 @@ public class HighguiTest extends OpenCVTestCase { } public void testImencodeStringMatListOfByteListOfInteger() { - fail("Not yet implemented"); + MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40); + MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90); + /* or + MatOfInt params = new MatOfInt(); + params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40); + */ + MatOfByte buff40 = new MatOfByte(); + MatOfByte buff90 = new MatOfByte(); + + assertTrue( Highgui.imencode(".jpg", rgbLena, buff40, params40) ); + assertTrue( Highgui.imencode(".jpg", rgbLena, buff90, params90) ); + + assertTrue(buff40.total() > 0); + assertTrue(buff40.total() < buff90.total()); } public void testImreadString() { diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp index 770df13d0f..02d7a6f620 100644 --- a/modules/photo/src/denoising.cpp +++ b/modules/photo/src/denoising.cpp @@ -52,6 +52,11 @@ void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst, float h, _dst.create(src.size(), src.type()); Mat dst = _dst.getMat(); +#ifdef HAVE_TEGRA_OPTIMIZATION + if(tegra::fastNlMeansDenoising(src, dst, h, templateWindowSize, searchWindowSize)) + return; +#endif + switch (src.type()) { case CV_8U: parallel_for(cv::BlockedRange(0, src.rows), diff --git a/modules/photo/src/precomp.hpp b/modules/photo/src/precomp.hpp index 4c912faffc..3185a18b86 100644 --- a/modules/photo/src/precomp.hpp +++ b/modules/photo/src/precomp.hpp @@ -43,10 +43,14 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H +#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" #endif #include "opencv2/photo/photo.hpp" +#ifdef HAVE_TEGRA_OPTIMIZATION +#include "opencv2/photo/photo_tegra.hpp" +#endif + #endif diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index e9bb3eb6e8..bbbc9698ce 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -764,7 +764,7 @@ vector leaveBiggestComponent(vector &features, vector