Merge branch 'master' of https://github.com/Itseez/opencv
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/calib3d.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/calib3d.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
|
||||
@@ -2981,7 +2981,7 @@ The class provides the following features for all derived classes:
|
||||
|
||||
* so called "virtual constructor". That is, each Algorithm derivative is registered at program start and you can get the list of registered algorithms and create instance of a particular algorithm by its name (see ``Algorithm::create``). If you plan to add your own algorithms, it is good practice to add a unique prefix to your algorithms to distinguish them from other algorithms.
|
||||
|
||||
* setting/retrieving algorithm parameters by name. If you used video capturing functionality from OpenCV highgui module, you are probably familar with ``cvSetCaptureProperty()``, ``cvGetCaptureProperty()``, ``VideoCapture::set()`` and ``VideoCapture::get()``. ``Algorithm`` provides similar method where instead of integer id's you specify the parameter names as text strings. See ``Algorithm::set`` and ``Algorithm::get`` for details.
|
||||
* setting/retrieving algorithm parameters by name. If you used video capturing functionality from OpenCV videoio module, you are probably familar with ``cvSetCaptureProperty()``, ``cvGetCaptureProperty()``, ``VideoCapture::set()`` and ``VideoCapture::get()``. ``Algorithm`` provides similar method where instead of integer id's you specify the parameter names as text strings. See ``Algorithm::set`` and ``Algorithm::get`` for details.
|
||||
|
||||
* reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store all its parameters and then read them back. There is no need to re-implement it each time.
|
||||
|
||||
|
||||
@@ -361,6 +361,37 @@ The function ``line`` draws the line segment between ``pt1`` and ``pt2`` points
|
||||
Antialiased lines are drawn using Gaussian filtering.
|
||||
|
||||
|
||||
arrowedLine
|
||||
----------------
|
||||
Draws a arrow segment pointing from the first point to the second one.
|
||||
|
||||
.. ocv:function:: void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0, double tipLength=0.1)
|
||||
|
||||
:param img: Image.
|
||||
|
||||
:param pt1: The point the arrow starts from.
|
||||
|
||||
:param pt2: The point the arrow points to.
|
||||
|
||||
:param color: Line color.
|
||||
|
||||
:param thickness: Line thickness.
|
||||
|
||||
:param lineType: Type of the line:
|
||||
|
||||
* **8** (or omitted) - 8-connected line.
|
||||
|
||||
* **4** - 4-connected line.
|
||||
|
||||
* **CV_AA** - antialiased line.
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates.
|
||||
|
||||
:param tipLength: The length of the arrow tip in relation to the arrow length
|
||||
|
||||
The function ``arrowedLine`` draws an arrow between ``pt1`` and ``pt2`` points in the image. See also :ocv:func:`line`.
|
||||
|
||||
|
||||
LineIterator
|
||||
------------
|
||||
.. ocv:class:: LineIterator
|
||||
|
||||
@@ -14,7 +14,8 @@ OpenCV has a modular structure, which means that the package includes several sh
|
||||
* **calib3d** - basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction.
|
||||
* **features2d** - salient feature detectors, descriptors, and descriptor matchers.
|
||||
* **objdetect** - detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on).
|
||||
* **highgui** - an easy-to-use interface to video capturing, image and video codecs, as well as simple UI capabilities.
|
||||
* **highgui** - an easy-to-use interface to simple UI capabilities.
|
||||
* **videoio** - an easy-to-use interface to video capturing and video codecs.
|
||||
* **gpu** - GPU-accelerated algorithms from different OpenCV modules.
|
||||
* ... some other helper modules, such as FLANN and Google test wrappers, Python bindings, and others.
|
||||
|
||||
|
||||
@@ -510,6 +510,10 @@ CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG*
|
||||
CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws an arrow from pt1 to pt2 in the image
|
||||
CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
|
||||
|
||||
//! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image
|
||||
CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2,
|
||||
const Scalar& color, int thickness = 1,
|
||||
|
||||
@@ -360,7 +360,7 @@ struct CV_EXPORTS UMatData
|
||||
{
|
||||
enum { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
|
||||
DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
|
||||
USER_ALLOCATED=32 };
|
||||
USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64};
|
||||
UMatData(const MatAllocator* allocator);
|
||||
~UMatData();
|
||||
|
||||
@@ -370,11 +370,13 @@ struct CV_EXPORTS UMatData
|
||||
|
||||
bool hostCopyObsolete() const;
|
||||
bool deviceCopyObsolete() const;
|
||||
bool deviceMemMapped() const;
|
||||
bool copyOnMap() const;
|
||||
bool tempUMat() const;
|
||||
bool tempCopiedUMat() const;
|
||||
void markHostCopyObsolete(bool flag);
|
||||
void markDeviceCopyObsolete(bool flag);
|
||||
void markDeviceMemMapped(bool flag);
|
||||
|
||||
const MatAllocator* prevAllocator;
|
||||
const MatAllocator* currAllocator;
|
||||
|
||||
@@ -3350,10 +3350,19 @@ size_t UMat::total() const
|
||||
|
||||
inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; }
|
||||
inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; }
|
||||
inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; }
|
||||
inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; }
|
||||
inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; }
|
||||
inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; }
|
||||
|
||||
inline void UMatData::markDeviceMemMapped(bool flag)
|
||||
{
|
||||
if(flag)
|
||||
flags |= DEVICE_MEM_MAPPED;
|
||||
else
|
||||
flags &= ~DEVICE_MEM_MAPPED;
|
||||
}
|
||||
|
||||
inline void UMatData::markHostCopyObsolete(bool flag)
|
||||
{
|
||||
if(flag)
|
||||
|
||||
@@ -139,6 +139,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
|
||||
dst.release();
|
||||
startTimer();
|
||||
src.copyTo(dst, mask);
|
||||
cv::ocl::finish();
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
|
||||
@@ -2980,8 +2980,187 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
|
||||
namespace cv
|
||||
{
|
||||
|
||||
template<typename T> static void
|
||||
inRange_(const T* src1, size_t step1, const T* src2, size_t step2,
|
||||
template <typename T>
|
||||
struct InRange_SSE
|
||||
{
|
||||
int operator () (const T *, const T *, const T *, uchar *, int) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if CV_SSE2
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<uchar>
|
||||
{
|
||||
int operator () (const uchar * src1, const uchar * src2, const uchar * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_full = _mm_set1_epi8(-1), v_128 = _mm_set1_epi8(-128);
|
||||
|
||||
for ( ; x <= len - 16; x += 16 )
|
||||
{
|
||||
__m128i v_src = _mm_add_epi8(_mm_loadu_si128((const __m128i *)(src1 + x)), v_128);
|
||||
__m128i v_mask1 = _mm_cmpgt_epi8(_mm_add_epi8(_mm_loadu_si128((const __m128i *)(src2 + x)), v_128), v_src);
|
||||
__m128i v_mask2 = _mm_cmpgt_epi8(v_src, _mm_add_epi8(_mm_loadu_si128((const __m128i *)(src3 + x)), v_128));
|
||||
_mm_storeu_si128((__m128i *)(dst + x), _mm_andnot_si128(_mm_or_si128(v_mask1, v_mask2), v_full));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<schar>
|
||||
{
|
||||
int operator () (const schar * src1, const schar * src2, const schar * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_full = _mm_set1_epi8(-1);
|
||||
|
||||
for ( ; x <= len - 16; x += 16 )
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((const __m128i *)(src1 + x));
|
||||
__m128i v_mask1 = _mm_cmpgt_epi8(_mm_loadu_si128((const __m128i *)(src2 + x)), v_src);
|
||||
__m128i v_mask2 = _mm_cmpgt_epi8(v_src, _mm_loadu_si128((const __m128i *)(src3 + x)));
|
||||
_mm_storeu_si128((__m128i *)(dst + x), _mm_andnot_si128(_mm_or_si128(v_mask1, v_mask2), v_full));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<ushort>
|
||||
{
|
||||
int operator () (const ushort * src1, const ushort * src2, const ushort * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_zero = _mm_setzero_si128(), v_full = _mm_set1_epi16(-1), v_32768 = _mm_set1_epi16(-32768);
|
||||
|
||||
for ( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128i v_src = _mm_add_epi16(_mm_loadu_si128((const __m128i *)(src1 + x)), v_32768);
|
||||
__m128i v_mask1 = _mm_cmpgt_epi16(_mm_add_epi16(_mm_loadu_si128((const __m128i *)(src2 + x)), v_32768), v_src);
|
||||
__m128i v_mask2 = _mm_cmpgt_epi16(v_src, _mm_add_epi16(_mm_loadu_si128((const __m128i *)(src3 + x)), v_32768));
|
||||
__m128i v_res = _mm_andnot_si128(_mm_or_si128(v_mask1, v_mask2), v_full);
|
||||
_mm_storel_epi64((__m128i *)(dst + x), _mm_packus_epi16(_mm_srli_epi16(v_res, 8), v_zero));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<short>
|
||||
{
|
||||
int operator () (const short * src1, const short * src2, const short * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_zero = _mm_setzero_si128(), v_full = _mm_set1_epi16(-1);
|
||||
|
||||
for ( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((const __m128i *)(src1 + x));
|
||||
__m128i v_mask1 = _mm_cmpgt_epi16(_mm_loadu_si128((const __m128i *)(src2 + x)), v_src);
|
||||
__m128i v_mask2 = _mm_cmpgt_epi16(v_src, _mm_loadu_si128((const __m128i *)(src3 + x)));
|
||||
__m128i v_res = _mm_andnot_si128(_mm_or_si128(v_mask1, v_mask2), v_full);
|
||||
_mm_storel_epi64((__m128i *)(dst + x), _mm_packus_epi16(_mm_srli_epi16(v_res, 8), v_zero));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<int>
|
||||
{
|
||||
int operator () (const int * src1, const int * src2, const int * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_zero = _mm_setzero_si128(), v_full = _mm_set1_epi32(-1);
|
||||
|
||||
for ( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((const __m128i *)(src1 + x));
|
||||
__m128i v_res1 = _mm_or_si128(_mm_cmpgt_epi32(_mm_loadu_si128((const __m128i *)(src2 + x)), v_src),
|
||||
_mm_cmpgt_epi32(v_src, _mm_loadu_si128((const __m128i *)(src3 + x))));
|
||||
|
||||
v_src = _mm_loadu_si128((const __m128i *)(src1 + x + 4));
|
||||
__m128i v_res2 = _mm_or_si128(_mm_cmpgt_epi32(_mm_loadu_si128((const __m128i *)(src2 + x + 4)), v_src),
|
||||
_mm_cmpgt_epi32(v_src, _mm_loadu_si128((const __m128i *)(src3 + x + 4))));
|
||||
|
||||
__m128i v_res = _mm_packs_epi32(_mm_srli_epi32(_mm_andnot_si128(v_res1, v_full), 16),
|
||||
_mm_srli_epi32(_mm_andnot_si128(v_res2, v_full), 16));
|
||||
_mm_storel_epi64((__m128i *)(dst + x), _mm_packus_epi16(v_res, v_zero));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InRange_SSE<float>
|
||||
{
|
||||
int operator () (const float * src1, const float * src2, const float * src3,
|
||||
uchar * dst, int len) const
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128i v_zero = _mm_setzero_si128();
|
||||
|
||||
for ( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128 v_src = _mm_loadu_ps(src1 + x);
|
||||
__m128 v_res1 = _mm_and_ps(_mm_cmple_ps(_mm_loadu_ps(src2 + x), v_src),
|
||||
_mm_cmple_ps(v_src, _mm_loadu_ps(src3 + x)));
|
||||
|
||||
v_src = _mm_loadu_ps(src1 + x + 4);
|
||||
__m128 v_res2 = _mm_and_ps(_mm_cmple_ps(_mm_loadu_ps(src2 + x + 4), v_src),
|
||||
_mm_cmple_ps(v_src, _mm_loadu_ps(src3 + x + 4)));
|
||||
|
||||
__m128i v_res1i = _mm_cvtps_epi32(v_res1), v_res2i = _mm_cvtps_epi32(v_res2);
|
||||
__m128i v_res = _mm_packs_epi32(_mm_srli_epi32(v_res1i, 16), _mm_srli_epi32(v_res2i, 16));
|
||||
_mm_storel_epi64((__m128i *)(dst + x), _mm_packus_epi16(v_res, v_zero));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
static void inRange_(const T* src1, size_t step1, const T* src2, size_t step2,
|
||||
const T* src3, size_t step3, uchar* dst, size_t step,
|
||||
Size size)
|
||||
{
|
||||
@@ -2989,9 +3168,11 @@ inRange_(const T* src1, size_t step1, const T* src2, size_t step2,
|
||||
step2 /= sizeof(src2[0]);
|
||||
step3 /= sizeof(src3[0]);
|
||||
|
||||
InRange_SSE<T> vop;
|
||||
|
||||
for( ; size.height--; src1 += step1, src2 += step2, src3 += step3, dst += step )
|
||||
{
|
||||
int x = 0;
|
||||
int x = vop(src1, src2, src3, dst, size.width);
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; x <= size.width - 4; x += 4 )
|
||||
{
|
||||
|
||||
@@ -1729,22 +1729,18 @@ static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst)
|
||||
UMat src = _src.getUMat(), lut = _lut.getUMat();
|
||||
_dst.create(src.size(), CV_MAKETYPE(ddepth, dcn));
|
||||
UMat dst = _dst.getUMat();
|
||||
bool bAligned = (1 == lcn) && (0 == (src.offset % 4)) && (0 == ((dcn * src.cols) % 4));
|
||||
// dst.cols == src.cols by params of dst.create
|
||||
int kercn = lcn == 1 ? std::min(4, ocl::predictOptimalVectorWidth(_dst)) : dcn;
|
||||
|
||||
ocl::Kernel k("LUT", ocl::core::lut_oclsrc,
|
||||
format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s", bAligned ? 4 : dcn, lcn,
|
||||
ocl::typeToStr(src.depth()), ocl::memopTypeToStr(ddepth)
|
||||
));
|
||||
format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s", kercn, lcn,
|
||||
ocl::typeToStr(src.depth()), ocl::memopTypeToStr(ddepth)));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
int cols = bAligned ? dcn * dst.cols / 4 : dst.cols;
|
||||
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::ReadOnlyNoSize(lut),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst), dst.rows, cols);
|
||||
ocl::KernelArg::WriteOnly(dst, dcn, kercn));
|
||||
|
||||
size_t globalSize[2] = { cols, (dst.rows + 3) / 4 };
|
||||
size_t globalSize[2] = { dst.cols * dcn / kercn, (dst.rows + 3) / 4 };
|
||||
return k.run(2, globalSize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1584,6 +1584,24 @@ void line( InputOutputArray _img, Point pt1, Point pt2, const Scalar& color,
|
||||
ThickLine( img, pt1, pt2, buf, thickness, line_type, 3, shift );
|
||||
}
|
||||
|
||||
void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness, int line_type, int shift, double tipLength)
|
||||
{
|
||||
const double tipSize = norm(pt1-pt2)*tipLength; // Factor to normalize the size of the tip depending on the length of the arrow
|
||||
|
||||
line(img, pt1, pt2, color, thickness, line_type, shift);
|
||||
|
||||
const double angle = atan2( (double) pt1.y - pt2.y, (double) pt1.x - pt2.x );
|
||||
|
||||
Point p(cvRound(pt2.x + tipSize * cos(angle + CV_PI / 4)),
|
||||
cvRound(pt2.y + tipSize * sin(angle + CV_PI / 4)));
|
||||
line(img, p, pt2, color, thickness, line_type, shift);
|
||||
|
||||
p.x = cvRound(pt2.x + tipSize * cos(angle - CV_PI / 4));
|
||||
p.y = cvRound(pt2.y + tipSize * sin(angle - CV_PI / 4));
|
||||
line(img, p, pt2, color, thickness, line_type, shift);
|
||||
}
|
||||
|
||||
void rectangle( InputOutputArray _img, Point pt1, Point pt2,
|
||||
const Scalar& color, int thickness,
|
||||
int lineType, int shift )
|
||||
|
||||
@@ -2080,32 +2080,32 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
|
||||
{
|
||||
if ((flags & DFT_ROWS) == 0)
|
||||
{
|
||||
if (!real_transform)
|
||||
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
|
||||
{
|
||||
if (ippi_DFT_C_32F(src,dst, inv, ipp_norm_flag))
|
||||
if (ippi_DFT_C_32F(src, dst, inv, ipp_norm_flag))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
else if (inv || !(flags & DFT_COMPLEX_OUTPUT))
|
||||
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
|
||||
{
|
||||
if (ippi_DFT_R_32F(src,dst, inv, ipp_norm_flag))
|
||||
if (ippi_DFT_R_32F(src, dst, inv, ipp_norm_flag))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!real_transform)
|
||||
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
|
||||
{
|
||||
ippiDFT_C_Func ippiFunc = inv ? (ippiDFT_C_Func)ippiDFTInv_CToC_32fc_C1R : (ippiDFT_C_Func)ippiDFTFwd_CToC_32fc_C1R;
|
||||
if (Dft_C_IPPLoop(src,dst, IPPDFT_C_Functor(ippiFunc),ipp_norm_flag))
|
||||
if (Dft_C_IPPLoop(src, dst, IPPDFT_C_Functor(ippiFunc),ipp_norm_flag))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
else if (inv || !(flags & DFT_COMPLEX_OUTPUT))
|
||||
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
|
||||
{
|
||||
ippiDFT_R_Func ippiFunc = inv ? (ippiDFT_R_Func)ippiDFTInv_PackToR_32f_C1R : (ippiDFT_R_Func)ippiDFTFwd_RToPack_32f_C1R;
|
||||
if (Dft_R_IPPLoop(src,dst, IPPDFT_R_Functor(ippiFunc),ipp_norm_flag))
|
||||
if (Dft_R_IPPLoop(src, dst, IPPDFT_R_Functor(ippiFunc),ipp_norm_flag))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
|
||||
@@ -348,7 +348,18 @@ static void InvSqrt_32f(const float* src, float* dst, int len)
|
||||
|
||||
static void InvSqrt_64f(const double* src, double* dst, int len)
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
int i = 0;
|
||||
|
||||
#if CV_SSE2
|
||||
if (USE_SSE2)
|
||||
{
|
||||
__m128d v_1 = _mm_set1_pd(1.0);
|
||||
for ( ; i <= len - 2; i += 2)
|
||||
_mm_storeu_pd(dst + i, _mm_div_pd(v_1, _mm_sqrt_pd(_mm_loadu_pd(src + i))));
|
||||
}
|
||||
#endif
|
||||
|
||||
for( ; i < len; i++ )
|
||||
dst[i] = 1/std::sqrt(src[i]);
|
||||
}
|
||||
|
||||
@@ -2543,12 +2554,33 @@ void patchNaNs( InputOutputArray _a, double _val )
|
||||
NAryMatIterator it(arrays, (uchar**)ptrs);
|
||||
size_t len = it.size*a.channels();
|
||||
Cv32suf val;
|
||||
val.f = (float)_val;
|
||||
float fval = (float)_val;
|
||||
val.f = fval;
|
||||
|
||||
#if CV_SSE2
|
||||
__m128i v_mask1 = _mm_set1_epi32(0x7fffffff), v_mask2 = _mm_set1_epi32(0x7f800000);
|
||||
__m128i v_val = _mm_set1_epi32(val.i);
|
||||
#endif
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
int* tptr = ptrs[0];
|
||||
for( size_t j = 0; j < len; j++ )
|
||||
size_t j = 0;
|
||||
|
||||
#if CV_SSE2
|
||||
if (USE_SSE2)
|
||||
{
|
||||
for ( ; j < len; j += 4)
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((__m128i const *)(tptr + j));
|
||||
__m128i v_cmp_mask = _mm_cmplt_epi32(v_mask2, _mm_and_si128(v_src, v_mask1));
|
||||
__m128i v_res = _mm_or_si128(_mm_andnot_si128(v_cmp_mask, v_src), _mm_and_si128(v_cmp_mask, v_val));
|
||||
_mm_storeu_si128((__m128i *)(tptr + j), v_res);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for( ; j < len; j++ )
|
||||
if( (tptr[j] & 0x7fffffff) > 0x7f800000 )
|
||||
tptr[j] = val.i;
|
||||
}
|
||||
|
||||
@@ -2758,21 +2758,30 @@ namespace cv {
|
||||
|
||||
static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s )
|
||||
{
|
||||
int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
|
||||
sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn),
|
||||
int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), kercn = cn;
|
||||
if (cn == 1)
|
||||
{
|
||||
kercn = std::min(ocl::predictOptimalVectorWidth(_m), 4);
|
||||
if (kercn != 4)
|
||||
kercn = 1;
|
||||
}
|
||||
int sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn),
|
||||
rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
|
||||
|
||||
ocl::Kernel k("setIdentity", ocl::core::set_identity_oclsrc,
|
||||
format("-D T=%s -D T1=%s -D cn=%d -D ST=%s", ocl::memopTypeToStr(type),
|
||||
ocl::memopTypeToStr(depth), cn, ocl::memopTypeToStr(sctype)));
|
||||
format("-D T=%s -D T1=%s -D cn=%d -D ST=%s -D kercn=%d -D rowsPerWI=%d",
|
||||
ocl::memopTypeToStr(CV_MAKE_TYPE(depth, kercn)),
|
||||
ocl::memopTypeToStr(depth), cn,
|
||||
ocl::memopTypeToStr(sctype),
|
||||
kercn, rowsPerWI));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
UMat m = _m.getUMat();
|
||||
k.args(ocl::KernelArg::WriteOnly(m), ocl::KernelArg::Constant(Mat(1, 1, sctype, s)),
|
||||
rowsPerWI);
|
||||
k.args(ocl::KernelArg::WriteOnly(m, cn, kercn),
|
||||
ocl::KernelArg::Constant(Mat(1, 1, sctype, s)));
|
||||
|
||||
size_t globalsize[2] = { m.cols, (m.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { m.cols * cn / kercn, (m.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -3441,8 +3450,11 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
|
||||
const int min_opt_cols = 128, buf_cols = 32;
|
||||
int sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype),
|
||||
ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth;
|
||||
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0,
|
||||
useOptimized = 1 == dim && _src.cols() > min_opt_cols;
|
||||
const ocl::Device &defDev = ocl::Device::getDefault();
|
||||
bool doubleSupport = defDev.doubleFPConfig() > 0;
|
||||
|
||||
size_t wgs = defDev.maxWorkGroupSize();
|
||||
bool useOptimized = 1 == dim && _src.cols() > min_opt_cols && (wgs >= buf_cols);
|
||||
|
||||
if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F))
|
||||
return false;
|
||||
@@ -3455,78 +3467,80 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
|
||||
|
||||
const char * const ops[4] = { "OCL_CV_REDUCE_SUM", "OCL_CV_REDUCE_AVG",
|
||||
"OCL_CV_REDUCE_MAX", "OCL_CV_REDUCE_MIN" };
|
||||
char cvt[2][40];
|
||||
|
||||
int wdepth = std::max(ddepth, CV_32F);
|
||||
cv::String build_opt = format("-D %s -D dim=%d -D cn=%d -D ddepth=%d"
|
||||
" -D srcT=%s -D dstT=%s -D dstT0=%s -D convertToWT=%s"
|
||||
" -D convertToDT=%s -D convertToDT0=%s%s",
|
||||
ops[op], dim, cn, ddepth, ocl::typeToStr(useOptimized ? ddepth : sdepth),
|
||||
ocl::typeToStr(ddepth), ocl::typeToStr(ddepth0),
|
||||
ocl::convertTypeStr(ddepth, wdepth, 1, cvt[0]),
|
||||
ocl::convertTypeStr(sdepth, ddepth, 1, cvt[0]),
|
||||
ocl::convertTypeStr(wdepth, ddepth0, 1, cvt[1]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
|
||||
|
||||
if (useOptimized)
|
||||
{
|
||||
cv::String build_opt_pre = format("-D OP_REDUCE_PRE -D BUF_COLS=%d -D %s -D dim=1"
|
||||
" -D cn=%d -D ddepth=%d -D srcT=%s -D dstT=%s -D convertToDT=%s%s",
|
||||
buf_cols, ops[op], cn, ddepth, ocl::typeToStr(sdepth), ocl::typeToStr(ddepth),
|
||||
ocl::convertTypeStr(sdepth, ddepth, 1, cvt[0]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
|
||||
ocl::Kernel kpre("reduce_horz_pre", ocl::core::reduce2_oclsrc, build_opt_pre);
|
||||
if (kpre.empty())
|
||||
size_t tileHeight = (size_t)(wgs / buf_cols);
|
||||
if (defDev.isIntel())
|
||||
{
|
||||
static const size_t maxItemInGroupCount = 16;
|
||||
tileHeight = min(tileHeight, defDev.localMemSize() / buf_cols / CV_ELEM_SIZE(CV_MAKETYPE(wdepth, cn)) / maxItemInGroupCount);
|
||||
}
|
||||
char cvt[3][40];
|
||||
cv::String build_opt = format("-D OP_REDUCE_PRE -D BUF_COLS=%d -D TILE_HEIGHT=%d -D %s -D dim=1"
|
||||
" -D cn=%d -D ddepth=%d"
|
||||
" -D srcT=%s -D bufT=%s -D dstT=%s"
|
||||
" -D convertToWT=%s -D convertToBufT=%s -D convertToDT=%s%s",
|
||||
buf_cols, tileHeight, ops[op], cn, ddepth,
|
||||
ocl::typeToStr(sdepth),
|
||||
ocl::typeToStr(ddepth),
|
||||
ocl::typeToStr(ddepth0),
|
||||
ocl::convertTypeStr(ddepth, wdepth, 1, cvt[0]),
|
||||
ocl::convertTypeStr(sdepth, ddepth, 1, cvt[1]),
|
||||
ocl::convertTypeStr(wdepth, ddepth0, 1, cvt[2]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
|
||||
ocl::Kernel k("reduce_horz_opt", ocl::core::reduce2_oclsrc, build_opt);
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
ocl::Kernel kmain("reduce", ocl::core::reduce2_oclsrc, build_opt);
|
||||
if (kmain.empty())
|
||||
return false;
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
Size dsize(1, src.rows);
|
||||
_dst.create(dsize, dtype);
|
||||
UMat dst = _dst.getUMat();
|
||||
|
||||
UMat buf(src.rows, buf_cols, dst.type());
|
||||
|
||||
kpre.args(ocl::KernelArg::ReadOnly(src),
|
||||
ocl::KernelArg::WriteOnlyNoSize(buf));
|
||||
if (op0 == CV_REDUCE_AVG)
|
||||
k.args(ocl::KernelArg::ReadOnly(src),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst), 1.0f / src.cols);
|
||||
else
|
||||
k.args(ocl::KernelArg::ReadOnly(src),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst));
|
||||
|
||||
size_t localSize[2] = { buf_cols, tileHeight};
|
||||
size_t globalSize[2] = { buf_cols, src.rows };
|
||||
if (!kpre.run(2, globalSize, NULL, false))
|
||||
return k.run(2, globalSize, localSize, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
char cvt[2][40];
|
||||
cv::String build_opt = format("-D %s -D dim=%d -D cn=%d -D ddepth=%d"
|
||||
" -D srcT=%s -D dstT=%s -D dstT0=%s -D convertToWT=%s"
|
||||
" -D convertToDT=%s -D convertToDT0=%s%s",
|
||||
ops[op], dim, cn, ddepth, ocl::typeToStr(useOptimized ? ddepth : sdepth),
|
||||
ocl::typeToStr(ddepth), ocl::typeToStr(ddepth0),
|
||||
ocl::convertTypeStr(ddepth, wdepth, 1, cvt[0]),
|
||||
ocl::convertTypeStr(sdepth, ddepth, 1, cvt[0]),
|
||||
ocl::convertTypeStr(wdepth, ddepth0, 1, cvt[1]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
|
||||
|
||||
ocl::Kernel k("reduce", ocl::core::reduce2_oclsrc, build_opt);
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
Size dsize(dim == 0 ? src.cols : 1, dim == 0 ? 1 : src.rows);
|
||||
_dst.create(dsize, dtype);
|
||||
UMat dst = _dst.getUMat();
|
||||
|
||||
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnly(src),
|
||||
temparg = ocl::KernelArg::WriteOnlyNoSize(dst);
|
||||
|
||||
if (op0 == CV_REDUCE_AVG)
|
||||
kmain.args(ocl::KernelArg::ReadOnly(buf),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst), 1.0f / src.cols);
|
||||
k.args(srcarg, temparg, 1.0f / (dim == 0 ? src.rows : src.cols));
|
||||
else
|
||||
kmain.args(ocl::KernelArg::ReadOnly(buf),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst));
|
||||
k.args(srcarg, temparg);
|
||||
|
||||
globalSize[0] = src.rows;
|
||||
return kmain.run(1, globalSize, NULL, false);
|
||||
size_t globalsize = std::max(dsize.width, dsize.height);
|
||||
return k.run(1, &globalsize, NULL, false);
|
||||
}
|
||||
|
||||
ocl::Kernel k("reduce", ocl::core::reduce2_oclsrc, build_opt);
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
Size dsize(dim == 0 ? src.cols : 1, dim == 0 ? 1 : src.rows);
|
||||
_dst.create(dsize, dtype);
|
||||
UMat dst = _dst.getUMat();
|
||||
|
||||
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnly(src),
|
||||
temparg = ocl::KernelArg::WriteOnlyNoSize(dst);
|
||||
|
||||
if (op0 == CV_REDUCE_AVG)
|
||||
k.args(srcarg, temparg, 1.0f / (dim == 0 ? src.rows : src.cols));
|
||||
else
|
||||
k.args(srcarg, temparg);
|
||||
|
||||
size_t globalsize = std::max(dsize.width, dsize.height);
|
||||
return k.run(1, &globalsize, NULL, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3494,9 +3494,8 @@ public:
|
||||
OpenCLBufferPoolImpl()
|
||||
: currentReservedSize(0), maxReservedSize(0)
|
||||
{
|
||||
// Note: Buffer pool is disabled by default,
|
||||
// because we didn't receive significant performance improvement
|
||||
maxReservedSize = getConfigurationParameterForSize("OPENCV_OPENCL_BUFFERPOOL_LIMIT", 0);
|
||||
int poolSize = ocl::Device::getDefault().isIntel() ? 1 << 27 : 0;
|
||||
maxReservedSize = getConfigurationParameterForSize("OPENCV_OPENCL_BUFFERPOOL_LIMIT", poolSize);
|
||||
}
|
||||
virtual ~OpenCLBufferPoolImpl()
|
||||
{
|
||||
@@ -3739,6 +3738,7 @@ public:
|
||||
u->handle = clCreateBuffer(ctx_handle, CL_MEM_COPY_HOST_PTR|CL_MEM_READ_WRITE|createFlags,
|
||||
u->size, u->origdata, &retval);
|
||||
tempUMatFlags = UMatData::TEMP_COPIED_UMAT;
|
||||
|
||||
}
|
||||
if(!u->handle || retval != CL_SUCCESS)
|
||||
return false;
|
||||
@@ -3880,6 +3880,7 @@ public:
|
||||
if(u->data && retval == CL_SUCCESS)
|
||||
{
|
||||
u->markHostCopyObsolete(false);
|
||||
u->markDeviceMemMapped(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3908,6 +3909,7 @@ public:
|
||||
if(!u)
|
||||
return;
|
||||
|
||||
|
||||
CV_Assert(u->handle != 0);
|
||||
|
||||
UMatDataAutoLock autolock(u);
|
||||
@@ -3918,8 +3920,10 @@ public:
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
cl_int retval = 0;
|
||||
if( !u->copyOnMap() && u->data )
|
||||
if( !u->copyOnMap() && u->deviceMemMapped() )
|
||||
{
|
||||
CV_Assert(u->data != NULL);
|
||||
u->markDeviceMemMapped(false);
|
||||
CV_Assert( (retval = clEnqueueUnmapMemObject(q,
|
||||
(cl_mem)u->handle, u->data, 0, 0, 0)) == CL_SUCCESS );
|
||||
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
|
||||
|
||||
@@ -36,114 +36,118 @@
|
||||
|
||||
#if lcn == 1
|
||||
#if dcn == 4
|
||||
#define LUT_OP(num)\
|
||||
int idx = *(__global const int *)(srcptr + mad24(num, src_step, src_index));\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx & 0xff];\
|
||||
dst[1] = lut_l[(idx >> 8) & 0xff];\
|
||||
dst[2] = lut_l[(idx >> 16) & 0xff];\
|
||||
#define LUT_OP \
|
||||
int idx = *(__global const int *)(srcptr + src_index); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx & 0xff]; \
|
||||
dst[1] = lut_l[(idx >> 8) & 0xff]; \
|
||||
dst[2] = lut_l[(idx >> 16) & 0xff]; \
|
||||
dst[3] = lut_l[(idx >> 24) & 0xff];
|
||||
#elif dcn == 3
|
||||
#define LUT_OP(num)\
|
||||
uchar3 idx = vload3(0, srcptr + mad24(num, src_step, src_index));\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx.x];\
|
||||
dst[1] = lut_l[idx.y];\
|
||||
#define LUT_OP \
|
||||
uchar3 idx = vload3(0, srcptr + src_index); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx.x]; \
|
||||
dst[1] = lut_l[idx.y]; \
|
||||
dst[2] = lut_l[idx.z];
|
||||
#elif dcn == 2
|
||||
#define LUT_OP(num)\
|
||||
short idx = *(__global const short *)(srcptr + mad24(num, src_step, src_index));\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx & 0xff];\
|
||||
#define LUT_OP \
|
||||
short idx = *(__global const short *)(srcptr + src_index); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx & 0xff]; \
|
||||
dst[1] = lut_l[(idx >> 8) & 0xff];
|
||||
#elif dcn == 1
|
||||
#define LUT_OP(num)\
|
||||
uchar idx = (srcptr + mad24(num, src_step, src_index))[0];\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
#define LUT_OP \
|
||||
uchar idx = (srcptr + src_index)[0]; \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx];
|
||||
#else
|
||||
#define LUT_OP(num)\
|
||||
__global const srcT * src = (__global const srcT *)(srcptr + mad24(num, src_step, src_index));\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
for (int cn = 0; cn < dcn; ++cn)\
|
||||
#define LUT_OP \
|
||||
__global const srcT * src = (__global const srcT *)(srcptr + src_index); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
for (int cn = 0; cn < dcn; ++cn) \
|
||||
dst[cn] = lut_l[src[cn]];
|
||||
#endif
|
||||
#else
|
||||
#if dcn == 4
|
||||
#define LUT_OP(num)\
|
||||
__global const uchar4 *src_pixel = (__global const uchar4 *)(srcptr + mad24(num, src_step, src_index));\
|
||||
int4 idx = convert_int4(src_pixel[0]) * lcn + (int4)(0, 1, 2, 3);\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx.x];\
|
||||
dst[1] = lut_l[idx.y];\
|
||||
dst[2] = lut_l[idx.z];\
|
||||
#define LUT_OP \
|
||||
__global const uchar4 * src_pixel = (__global const uchar4 *)(srcptr + src_index); \
|
||||
int4 idx = mad24(convert_int4(src_pixel[0]), (int4)(lcn), (int4)(0, 1, 2, 3)); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx.x]; \
|
||||
dst[1] = lut_l[idx.y]; \
|
||||
dst[2] = lut_l[idx.z]; \
|
||||
dst[3] = lut_l[idx.w];
|
||||
#elif dcn == 3
|
||||
#define LUT_OP(num)\
|
||||
uchar3 src_pixel = vload3(0, srcptr + mad24(num, src_step, src_index));\
|
||||
int3 idx = convert_int3(src_pixel) * lcn + (int3)(0, 1, 2);\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx.x];\
|
||||
dst[1] = lut_l[idx.y];\
|
||||
#define LUT_OP \
|
||||
uchar3 src_pixel = vload3(0, srcptr + src_index); \
|
||||
int3 idx = mad24(convert_int3(src_pixel), (int3)(lcn), (int3)(0, 1, 2)); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx.x]; \
|
||||
dst[1] = lut_l[idx.y]; \
|
||||
dst[2] = lut_l[idx.z];
|
||||
#elif dcn == 2
|
||||
#define LUT_OP(num)\
|
||||
__global const uchar2 *src_pixel = (__global const uchar2 *)(srcptr + mad24(num, src_step, src_index));\
|
||||
int2 idx = convert_int2(src_pixel[0]) * lcn + (int2)(0, 1);\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
dst[0] = lut_l[idx.x];\
|
||||
#define LUT_OP \
|
||||
__global const uchar2 * src_pixel = (__global const uchar2 *)(srcptr + src_index); \
|
||||
int2 idx = mad24(convert_int2(src_pixel[0]), lcn, (int2)(0, 1)); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx.x]; \
|
||||
dst[1] = lut_l[idx.y];
|
||||
#elif dcn == 1 //error case (1 < lcn) ==> lcn == scn == dcn
|
||||
#define LUT_OP(num)\
|
||||
uchar idx = (srcptr + mad24(num, src_step, src_index))[0];\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
#define LUT_OP \
|
||||
uchar idx = (srcptr + src_index)[0]; \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
dst[0] = lut_l[idx];
|
||||
#else
|
||||
#define LUT_OP(num)\
|
||||
__global const srcT *src = (__global const srcT *)(srcptr + mad24(num, src_step, src_index));\
|
||||
dst = (__global dstT *)(dstptr + mad24(num, dst_step, dst_index));\
|
||||
for (int cn = 0; cn < dcn; ++cn)\
|
||||
#define LUT_OP \
|
||||
__global const srcT * src = (__global const srcT *)(srcptr + src_index); \
|
||||
dst = (__global dstT *)(dstptr + dst_index); \
|
||||
for (int cn = 0; cn < dcn; ++cn) \
|
||||
dst[cn] = lut_l[mad24(src[cn], lcn, cn)];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define LOCAL_LUT_INIT\
|
||||
{\
|
||||
__global const dstT * lut = (__global const dstT *)(lutptr + lut_offset);\
|
||||
int init = mad24((int)get_local_id(1), (int)get_local_size(0), (int)get_local_id(0));\
|
||||
int step = get_local_size(0) * get_local_size(1);\
|
||||
for (int i = init; i < 256 * lcn; i += step)\
|
||||
{\
|
||||
lut_l[i] = lut[i];\
|
||||
}\
|
||||
barrier(CLK_LOCAL_MEM_FENCE);\
|
||||
}
|
||||
|
||||
__kernel void LUT(__global const uchar * srcptr, int src_step, int src_offset,
|
||||
__global const uchar * lutptr, int lut_step, int lut_offset,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset, int rows, int cols)
|
||||
{
|
||||
__local dstT lut_l[256 * lcn];
|
||||
LOCAL_LUT_INIT;
|
||||
|
||||
int x = get_global_id(0);
|
||||
int y = 4 * get_global_id(1);
|
||||
int y = get_global_id(1) << 2;
|
||||
|
||||
__local dstT lut_l[256 * lcn];
|
||||
__global const dstT * lut = (__global const dstT *)(lutptr + lut_offset);
|
||||
|
||||
for (int i = mad24((int)get_local_id(1), (int)get_local_size(0), (int)get_local_id(0)),
|
||||
step = get_local_size(0) * get_local_size(1); i < 256 * lcn; i += step)
|
||||
lut_l[i] = lut[i];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
if (x < cols && y < rows)
|
||||
{
|
||||
int src_index = mad24(y, src_step, mad24(x, (int)sizeof(srcT) * dcn, src_offset));
|
||||
int dst_index = mad24(y, dst_step, mad24(x, (int)sizeof(dstT) * dcn, dst_offset));
|
||||
|
||||
__global dstT * dst;
|
||||
LUT_OP(0);
|
||||
|
||||
LUT_OP;
|
||||
|
||||
if (y < rows - 1)
|
||||
{
|
||||
LUT_OP(1);
|
||||
src_index += src_step;
|
||||
dst_index += dst_step;
|
||||
LUT_OP;
|
||||
|
||||
if (y < rows - 2)
|
||||
{
|
||||
LUT_OP(2);
|
||||
src_index += src_step;
|
||||
dst_index += dst_step;
|
||||
LUT_OP;
|
||||
|
||||
if (y < rows - 3)
|
||||
{
|
||||
LUT_OP(3);
|
||||
src_index += src_step;
|
||||
dst_index += dst_step;
|
||||
LUT_OP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,13 @@
|
||||
#if wdepth <= 4
|
||||
#define MIN_ABS(a) convertFromU(abs(a))
|
||||
#define MIN_ABS2(a, b) convertFromU(abs_diff(a, b))
|
||||
#define MIN(a, b) min(a, b)
|
||||
#define MAX(a, b) max(a, b)
|
||||
#else
|
||||
#define MIN_ABS(a) fabs(a)
|
||||
#define MIN_ABS2(a, b) fabs(a - b)
|
||||
#define MIN(a, b) fmin(a, b)
|
||||
#define MAX(a, b) fmax(a, b)
|
||||
#endif
|
||||
|
||||
#if kercn != 3
|
||||
@@ -60,44 +64,41 @@
|
||||
#define srcTSIZE (int)sizeof(srcT1)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MINLOC
|
||||
#define CALC_MINLOC(inc) minloc = id + inc
|
||||
#else
|
||||
#define CALC_MINLOC(inc)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MAXLOC
|
||||
#define CALC_MAXLOC(inc) maxloc = id + inc
|
||||
#else
|
||||
#define CALC_MAXLOC(inc)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MINVAL
|
||||
#ifdef NEED_MINLOC
|
||||
#define CALC_MIN(p, inc) \
|
||||
if (minval > temp.p) \
|
||||
{ \
|
||||
minval = temp.p; \
|
||||
CALC_MINLOC(inc); \
|
||||
minloc = id + inc; \
|
||||
}
|
||||
#else
|
||||
#define CALC_MIN(p, inc) \
|
||||
minval = MIN(minval, temp.p);
|
||||
#endif
|
||||
#else
|
||||
#define CALC_MIN(p, inc)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MAXVAL
|
||||
#ifdef NEED_MAXLOC
|
||||
#define CALC_MAX(p, inc) \
|
||||
if (maxval < temp.p) \
|
||||
{ \
|
||||
maxval = temp.p; \
|
||||
CALC_MAXLOC(inc); \
|
||||
maxloc = id + inc; \
|
||||
}
|
||||
#else
|
||||
#define CALC_MAX(p, inc) \
|
||||
maxval = MAX(maxval, temp.p);
|
||||
#endif
|
||||
#else
|
||||
#define CALC_MAX(p, inc)
|
||||
#endif
|
||||
|
||||
#ifdef OP_CALC2
|
||||
#define CALC_MAX2(p) \
|
||||
if (maxval2 < temp.p) \
|
||||
maxval2 = temp.p;
|
||||
maxval2 = MAX(maxval2, temp.p);
|
||||
#else
|
||||
#define CALC_MAX2(p)
|
||||
#endif
|
||||
@@ -208,25 +209,28 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
|
||||
|
||||
#if kercn == 1
|
||||
#ifdef NEED_MINVAL
|
||||
#if NEED_MINLOC
|
||||
if (minval > temp)
|
||||
{
|
||||
minval = temp;
|
||||
#ifdef NEED_MINLOC
|
||||
minloc = id;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
minval = MIN(minval, temp);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NEED_MAXVAL
|
||||
#ifdef NEED_MAXLOC
|
||||
if (maxval < temp)
|
||||
{
|
||||
maxval = temp;
|
||||
#ifdef NEED_MAXLOC
|
||||
maxloc = id;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
maxval = MAX(maxval, temp);
|
||||
#endif
|
||||
#ifdef OP_CALC2
|
||||
if (maxval2 < temp2)
|
||||
maxval2 = temp2;
|
||||
maxval2 = MAX(maxval2, temp2);
|
||||
#endif
|
||||
#endif
|
||||
#elif kercn >= 2
|
||||
@@ -282,32 +286,35 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
|
||||
{
|
||||
int lid3 = lid - WGS2_ALIGNED;
|
||||
#ifdef NEED_MINVAL
|
||||
#ifdef NEED_MINLOC
|
||||
if (localmem_min[lid3] >= minval)
|
||||
{
|
||||
#ifdef NEED_MINLOC
|
||||
if (localmem_min[lid3] == minval)
|
||||
localmem_minloc[lid3] = min(localmem_minloc[lid3], minloc);
|
||||
else
|
||||
localmem_minloc[lid3] = minloc,
|
||||
#endif
|
||||
localmem_min[lid3] = minval;
|
||||
localmem_min[lid3] = minval;
|
||||
}
|
||||
#else
|
||||
localmem_min[lid3] = MIN(localmem_min[lid3], minval);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NEED_MAXVAL
|
||||
#ifdef NEED_MAXLOC
|
||||
if (localmem_max[lid3] <= maxval)
|
||||
{
|
||||
#ifdef NEED_MAXLOC
|
||||
if (localmem_max[lid3] == maxval)
|
||||
localmem_maxloc[lid3] = min(localmem_maxloc[lid3], maxloc);
|
||||
else
|
||||
localmem_maxloc[lid3] = maxloc,
|
||||
#endif
|
||||
localmem_max[lid3] = maxval;
|
||||
localmem_max[lid3] = maxval;
|
||||
}
|
||||
#else
|
||||
localmem_max[lid3] = MAX(localmem_max[lid3], maxval);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef OP_CALC2
|
||||
if (localmem_max2[lid3] < maxval2)
|
||||
localmem_max2[lid3] = maxval2;
|
||||
localmem_max2[lid3] = MAX(localmem_max2[lid3], maxval2);
|
||||
#endif
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
@@ -319,32 +326,35 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
|
||||
int lid2 = lsize + lid;
|
||||
|
||||
#ifdef NEED_MINVAL
|
||||
#ifdef NEED_MAXLOC
|
||||
if (localmem_min[lid] >= localmem_min[lid2])
|
||||
{
|
||||
#ifdef NEED_MINLOC
|
||||
if (localmem_min[lid] == localmem_min[lid2])
|
||||
localmem_minloc[lid] = min(localmem_minloc[lid2], localmem_minloc[lid]);
|
||||
else
|
||||
localmem_minloc[lid] = localmem_minloc[lid2],
|
||||
#endif
|
||||
localmem_min[lid] = localmem_min[lid2];
|
||||
localmem_min[lid] = localmem_min[lid2];
|
||||
}
|
||||
#else
|
||||
localmem_min[lid] = MIN(localmem_min[lid], localmem_min[lid2]);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NEED_MAXVAL
|
||||
#ifdef NEED_MAXLOC
|
||||
if (localmem_max[lid] <= localmem_max[lid2])
|
||||
{
|
||||
#ifdef NEED_MAXLOC
|
||||
if (localmem_max[lid] == localmem_max[lid2])
|
||||
localmem_maxloc[lid] = min(localmem_maxloc[lid2], localmem_maxloc[lid]);
|
||||
else
|
||||
localmem_maxloc[lid] = localmem_maxloc[lid2],
|
||||
#endif
|
||||
localmem_max[lid] = localmem_max[lid2];
|
||||
localmem_max[lid] = localmem_max[lid2];
|
||||
}
|
||||
#else
|
||||
localmem_max[lid] = MAX(localmem_max[lid], localmem_max[lid2]);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef OP_CALC2
|
||||
if (localmem_max2[lid] < localmem_max2[lid2])
|
||||
localmem_max2[lid] = localmem_max2[lid2];
|
||||
localmem_max2[lid] = MAX(localmem_max2[lid], localmem_max2[lid2]);
|
||||
#endif
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
@@ -81,29 +81,34 @@
|
||||
#define PROCESS_ELEM(acc, value) acc += value
|
||||
#elif defined OCL_CV_REDUCE_MAX
|
||||
#define INIT_VALUE MIN_VAL
|
||||
#define PROCESS_ELEM(acc, value) acc = value > acc ? value : acc
|
||||
#define PROCESS_ELEM(acc, value) acc = max(value, acc)
|
||||
#elif defined OCL_CV_REDUCE_MIN
|
||||
#define INIT_VALUE MAX_VAL
|
||||
#define PROCESS_ELEM(acc, value) acc = value < acc ? value : acc
|
||||
#define PROCESS_ELEM(acc, value) acc = min(value, acc)
|
||||
#else
|
||||
#error "No operation is specified"
|
||||
#endif
|
||||
|
||||
#ifdef OP_REDUCE_PRE
|
||||
|
||||
__kernel void reduce_horz_pre(__global const uchar * srcptr, int src_step, int src_offset, int rows, int cols,
|
||||
__global uchar * bufptr, int buf_step, int buf_offset)
|
||||
__kernel void reduce_horz_opt(__global const uchar * srcptr, int src_step, int src_offset, int rows, int cols,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset
|
||||
#ifdef OCL_CV_REDUCE_AVG
|
||||
, float fscale
|
||||
#endif
|
||||
)
|
||||
{
|
||||
__local bufT lsmem[TILE_HEIGHT][BUF_COLS][cn];
|
||||
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
if (x < BUF_COLS)
|
||||
int liy = get_local_id(1);
|
||||
if ((x < BUF_COLS) && (y < rows))
|
||||
{
|
||||
int src_index = mad24(y, src_step, mad24(x, (int)sizeof(srcT) * cn, src_offset));
|
||||
int buf_index = mad24(y, buf_step, mad24(x, (int)sizeof(dstT) * cn, buf_offset));
|
||||
|
||||
__global const srcT * src = (__global const srcT *)(srcptr + src_index);
|
||||
__global dstT * buf = (__global dstT *)(bufptr + buf_index);
|
||||
dstT tmp[cn] = { INIT_VALUE };
|
||||
bufT tmp[cn] = { INIT_VALUE };
|
||||
|
||||
int src_step_mul = BUF_COLS * cn;
|
||||
for (int idx = x; idx < cols; idx += BUF_COLS, src += src_step_mul)
|
||||
@@ -111,14 +116,49 @@ __kernel void reduce_horz_pre(__global const uchar * srcptr, int src_step, int s
|
||||
#pragma unroll
|
||||
for (int c = 0; c < cn; ++c)
|
||||
{
|
||||
dstT value = convertToDT(src[c]);
|
||||
bufT value = convertToBufT(src[c]);
|
||||
PROCESS_ELEM(tmp[c], value);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unroll
|
||||
for (int c = 0; c < cn; ++c)
|
||||
buf[c] = tmp[c];
|
||||
lsmem[liy][x][c] = tmp[c];
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if ((x < BUF_COLS / 2) && (y < rows))
|
||||
{
|
||||
#pragma unroll
|
||||
for (int c = 0; c < cn; ++c)
|
||||
{
|
||||
PROCESS_ELEM(lsmem[liy][x][c], lsmem[liy][x + BUF_COLS / 2][c]);
|
||||
}
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if ((x == 0) && (y < rows))
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, dst_offset);
|
||||
|
||||
__global dstT * dst = (__global dstT *)(dstptr + dst_index);
|
||||
bufT tmp[cn] = { INIT_VALUE };
|
||||
|
||||
#pragma unroll
|
||||
for (int xin = 0; xin < BUF_COLS / 2; xin ++)
|
||||
{
|
||||
#pragma unroll
|
||||
for (int c = 0; c < cn; ++c)
|
||||
{
|
||||
PROCESS_ELEM(tmp[c], lsmem[liy][xin][c]);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unroll
|
||||
for (int c = 0; c < cn; ++c)
|
||||
#ifdef OCL_CV_REDUCE_AVG
|
||||
dst[c] = convertToDT(convertToWT(tmp[c]) * fscale);
|
||||
#else
|
||||
dst[c] = convertToDT(tmp[c]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,20 +43,18 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#if cn != 3
|
||||
#define loadpix(addr) *(__global const T *)(addr)
|
||||
#if kercn != 3
|
||||
#define storepix(val, addr) *(__global T *)(addr) = val
|
||||
#define TSIZE (int)sizeof(T)
|
||||
#define scalar scalar_
|
||||
#else
|
||||
#define loadpix(addr) vload3(0, (__global const T1 *)(addr))
|
||||
#define storepix(val, addr) vstore3(val, 0, (__global T1 *)(addr))
|
||||
#define TSIZE ((int)sizeof(T1)*3)
|
||||
#define scalar (T)(scalar_.x, scalar_.y, scalar_.z)
|
||||
#endif
|
||||
|
||||
__kernel void setIdentity(__global uchar * srcptr, int src_step, int src_offset, int rows, int cols,
|
||||
ST scalar_, int rowsPerWI)
|
||||
ST scalar_)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y0 = get_global_id(1) * rowsPerWI;
|
||||
@@ -65,7 +63,35 @@ __kernel void setIdentity(__global uchar * srcptr, int src_step, int src_offset,
|
||||
{
|
||||
int src_index = mad24(y0, src_step, mad24(x, TSIZE, src_offset));
|
||||
|
||||
for (int y = y0, y1 = min(rows, y0 + rowsPerWI); y < y1; ++y, src_index += src_step)
|
||||
storepix(x == y ? scalar : (T)(0), srcptr + src_index);
|
||||
#if kercn == cn
|
||||
#pragma unroll
|
||||
for (int y = y0, i = 0, y1 = min(rows, y0 + rowsPerWI); i < rowsPerWI; ++y, ++i, src_index += src_step)
|
||||
if (y < y1)
|
||||
storepix(x == y ? scalar : (T)(0), srcptr + src_index);
|
||||
#elif kercn == 4 && cn == 1
|
||||
if (y0 < rows)
|
||||
{
|
||||
storepix(x == y0 >> 2 ? (T)(scalar, 0, 0, 0) : (T)(0), srcptr + src_index);
|
||||
if (++y0 < rows)
|
||||
{
|
||||
src_index += src_step;
|
||||
storepix(x == y0 >> 2 ? (T)(0, scalar, 0, 0) : (T)(0), srcptr + src_index);
|
||||
|
||||
if (++y0 < rows)
|
||||
{
|
||||
src_index += src_step;
|
||||
storepix(x == y0 >> 2 ? (T)(0, 0, scalar, 0) : (T)(0), srcptr + src_index);
|
||||
|
||||
if (++y0 < rows)
|
||||
{
|
||||
src_index += src_step;
|
||||
storepix(x == y0 >> 2 ? (T)(0, 0, 0, scalar) : (T)(0), srcptr + src_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error "Incorrect combination of cn && kercn"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,8 +918,14 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0,
|
||||
isContinuous = _src.isContinuous();
|
||||
int groups = ocl::Device::getDefault().maxComputeUnits();
|
||||
size_t wgs = ocl::Device::getDefault().maxWorkGroupSize();
|
||||
const ocl::Device &defDev = ocl::Device::getDefault();
|
||||
int groups = defDev.maxComputeUnits();
|
||||
if (defDev.isIntel())
|
||||
{
|
||||
static const int subSliceEUCount = 10;
|
||||
groups = (groups / subSliceEUCount) * 2;
|
||||
}
|
||||
size_t wgs = defDev.maxWorkGroupSize();
|
||||
|
||||
int ddepth = std::max(CV_32S, depth), sqddepth = std::max(CV_32F, depth),
|
||||
dtype = CV_MAKE_TYPE(ddepth, cn),
|
||||
|
||||
@@ -6,7 +6,7 @@ set(the_description "CUDA-accelerated Video Encoding/Decoding")
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef)
|
||||
|
||||
ocv_add_module(cudacodec opencv_highgui OPTIONAL opencv_cudev)
|
||||
ocv_add_module(cudacodec OPTIONAL opencv_cudev)
|
||||
|
||||
ocv_module_include_directories()
|
||||
ocv_glob_module_sources()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set(test_deps opencv_cudev opencv_core opencv_imgproc opencv_highgui opencv_ts ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
set(test_deps opencv_cudev opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui opencv_ts ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
|
||||
ocv_check_dependencies(${test_deps})
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -595,7 +595,7 @@ struct HellingerDistance
|
||||
typedef typename Accumulator<T>::Type ResultType;
|
||||
|
||||
/**
|
||||
* Compute the histogram intersection distance
|
||||
* Compute the Hellinger distance
|
||||
*/
|
||||
template <typename Iterator1, typename Iterator2>
|
||||
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
|
||||
@@ -628,7 +628,8 @@ struct HellingerDistance
|
||||
template <typename U, typename V>
|
||||
inline ResultType accum_dist(const U& a, const V& b, int) const
|
||||
{
|
||||
return sqrt(static_cast<ResultType>(a)) - sqrt(static_cast<ResultType>(b));
|
||||
ResultType diff = sqrt(static_cast<ResultType>(a)) - sqrt(static_cast<ResultType>(b));
|
||||
return diff * diff;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -729,9 +730,11 @@ struct KL_Divergence
|
||||
inline ResultType accum_dist(const U& a, const V& b, int) const
|
||||
{
|
||||
ResultType result = ResultType();
|
||||
ResultType ratio = (ResultType)(a / b);
|
||||
if (ratio>0) {
|
||||
result = a * log(ratio);
|
||||
if( *b != 0 ) {
|
||||
ResultType ratio = (ResultType)(a / b);
|
||||
if (ratio>0) {
|
||||
result = a * log(ratio);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
set(the_description "High-level GUI and Media I/O")
|
||||
ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
|
||||
ocv_add_module(highgui opencv_imgproc opencv_imgcodecs opencv_videoio OPTIONAL opencv_androidcamera)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for highgui. See root CMakeLists.txt
|
||||
@@ -7,70 +7,20 @@ ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
|
||||
# Jose Luis Blanco, 2008
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
ocv_clear_vars(GRFMT_LIBS)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
|
||||
if(APPLE)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_JPEG)
|
||||
ocv_include_directories(${JPEG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_WEBP)
|
||||
add_definitions(-DHAVE_WEBP)
|
||||
ocv_include_directories(${WEBP_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_PNG)
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
ocv_include_directories(${PNG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_TIFF)
|
||||
ocv_include_directories(${TIFF_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_JASPER)
|
||||
ocv_include_directories(${JASPER_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENEXR)
|
||||
include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
|
||||
list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
file(GLOB grfmt_hdrs src/grfmt*.hpp)
|
||||
file(GLOB grfmt_srcs src/grfmt*.cpp)
|
||||
list(APPEND grfmt_hdrs src/bitstrm.hpp)
|
||||
list(APPEND grfmt_srcs src/bitstrm.cpp)
|
||||
list(APPEND grfmt_hdrs src/rgbe.hpp)
|
||||
list(APPEND grfmt_srcs src/rgbe.cpp)
|
||||
|
||||
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
||||
|
||||
set(highgui_hdrs
|
||||
src/precomp.hpp
|
||||
src/utils.hpp
|
||||
src/cap_ffmpeg_impl.hpp
|
||||
)
|
||||
|
||||
set(highgui_srcs
|
||||
src/cap.cpp
|
||||
src/cap_images.cpp
|
||||
src/cap_ffmpeg.cpp
|
||||
src/loadsave.cpp
|
||||
src/utils.cpp
|
||||
src/window.cpp
|
||||
)
|
||||
|
||||
@@ -122,128 +72,6 @@ elseif(HAVE_COCOA)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT ARM)
|
||||
list(APPEND highgui_srcs src/cap_cmu.cpp)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND HAVE_DSHOW)
|
||||
list(APPEND highgui_srcs src/cap_dshow.cpp)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND HAVE_MSMF)
|
||||
list(APPEND highgui_srcs src/cap_msmf.cpp)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND HAVE_VFW)
|
||||
list(APPEND highgui_srcs src/cap_vfw.cpp)
|
||||
endif()
|
||||
|
||||
if(HAVE_XINE)
|
||||
list(APPEND highgui_srcs src/cap_xine.cpp)
|
||||
endif(HAVE_XINE)
|
||||
|
||||
if(HAVE_DC1394_2)
|
||||
list(APPEND highgui_srcs src/cap_dc1394_v2.cpp)
|
||||
endif(HAVE_DC1394_2)
|
||||
|
||||
if(HAVE_DC1394)
|
||||
list(APPEND highgui_srcs src/cap_dc1394.cpp)
|
||||
endif(HAVE_DC1394)
|
||||
|
||||
if(HAVE_GSTREAMER)
|
||||
list(APPEND highgui_srcs src/cap_gstreamer.cpp)
|
||||
endif(HAVE_GSTREAMER)
|
||||
|
||||
if(HAVE_UNICAP)
|
||||
list(APPEND highgui_srcs src/cap_unicap.cpp)
|
||||
endif(HAVE_UNICAP)
|
||||
|
||||
if(HAVE_LIBV4L)
|
||||
list(APPEND highgui_srcs src/cap_libv4l.cpp)
|
||||
elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
|
||||
list(APPEND highgui_srcs src/cap_v4l.cpp)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENNI)
|
||||
list(APPEND highgui_srcs src/cap_openni.cpp)
|
||||
ocv_include_directories(${OPENNI_INCLUDE_DIR})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
|
||||
endif(HAVE_OPENNI)
|
||||
|
||||
if(HAVE_opencv_androidcamera)
|
||||
list(APPEND highgui_srcs src/cap_android.cpp)
|
||||
add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)#TODO: remove this line
|
||||
endif(HAVE_opencv_androidcamera)
|
||||
|
||||
if(HAVE_XIMEA)
|
||||
list(APPEND highgui_srcs src/cap_ximea.cpp)
|
||||
ocv_include_directories(${XIMEA_PATH})
|
||||
if(XIMEA_LIBRARY_DIR)
|
||||
link_directories("${XIMEA_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(X86_64)
|
||||
list(APPEND HIGHGUI_LIBRARIES m3apiX64)
|
||||
else()
|
||||
list(APPEND HIGHGUI_LIBRARIES m3api)
|
||||
endif()
|
||||
endif(HAVE_XIMEA)
|
||||
|
||||
if(HAVE_FFMPEG)
|
||||
if(UNIX AND BZIP2_LIBRARIES)
|
||||
list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
|
||||
endif()
|
||||
if(APPLE)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
|
||||
endif()
|
||||
endif(HAVE_FFMPEG)
|
||||
|
||||
if(HAVE_PVAPI)
|
||||
add_definitions(-DHAVE_PVAPI)
|
||||
add_definitions(${PVAPI_DEFINITIONS})
|
||||
ocv_include_directories(${PVAPI_INCLUDE_PATH})
|
||||
set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_GIGE_API)
|
||||
add_definitions(-DHAVE_GIGE_API)
|
||||
ocv_include_directories(${GIGEAPI_INCLUDE_PATH})
|
||||
set(highgui_srcs src/cap_giganetix.cpp ${highgui_srcs})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${GIGEAPI_LIBRARIES})
|
||||
list(APPEND highgui_srcs src/cap_giganetix.cpp)
|
||||
endif(HAVE_GIGE_API)
|
||||
|
||||
if(HAVE_AVFOUNDATION)
|
||||
list(APPEND highgui_srcs src/cap_avfoundation.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
|
||||
endif()
|
||||
|
||||
if(HAVE_QUICKTIME)
|
||||
list(APPEND highgui_srcs src/cap_qt.cpp)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
|
||||
elseif(HAVE_QTKIT)
|
||||
list(APPEND highgui_srcs src/cap_qtkit.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
|
||||
endif()
|
||||
|
||||
if(HAVE_INTELPERC)
|
||||
list(APPEND highgui_srcs src/cap_intelperc.cpp)
|
||||
ocv_include_directories(${INTELPERC_INCLUDE_DIR})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${INTELPERC_LIBRARIES})
|
||||
endif(HAVE_INTELPERC)
|
||||
|
||||
if(IOS)
|
||||
add_definitions(-DHAVE_IOS=1)
|
||||
list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
link_directories("${OpenCV_SOURCE_DIR}/3rdparty/lib") # for ffmpeg wrapper only
|
||||
include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include") # for directshow in VS2005 and multi-monitor support on MinGW
|
||||
include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include/ffmpeg_") # for tests
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
#these variables are set by CHECK_MODULE macro
|
||||
foreach(P ${HIGHGUI_INCLUDE_DIRS})
|
||||
@@ -257,10 +85,10 @@ endif()
|
||||
|
||||
source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
|
||||
source_group("Include" FILES ${highgui_ext_hdrs})
|
||||
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
|
||||
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs})
|
||||
ocv_module_include_directories()
|
||||
|
||||
ocv_create_module(${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
|
||||
ocv_create_module(${HIGHGUI_LIBRARIES})
|
||||
|
||||
if(APPLE)
|
||||
ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
|
||||
@@ -294,33 +122,5 @@ set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
ocv_add_precompiled_headers(${the_module})
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
||||
|
||||
if(WIN32 AND WITH_FFMPEG)
|
||||
#copy ffmpeg dll to the output folder
|
||||
if(MSVC64 OR MINGW64)
|
||||
set(FFMPEG_SUFFIX _64)
|
||||
endif()
|
||||
|
||||
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
|
||||
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
||||
set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
|
||||
|
||||
if(MSVC_IDE)
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual"))
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
else()
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
endif()
|
||||
|
||||
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
|
||||
endif()
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
|
||||
@@ -9,12 +9,9 @@ It provides easy interface to:
|
||||
|
||||
* Create and manipulate windows that can display images and "remember" their content (no need to handle repaint events from OS).
|
||||
* Add trackbars to the windows, handle simple mouse events as well as keyboard commands.
|
||||
* Read and write images to/from disk or memory.
|
||||
* Read video from camera or file and write video to a file.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
user_interface
|
||||
reading_and_writing_images_and_video
|
||||
qt_new_functions
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#define __OPENCV_HIGHGUI_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/videoio.hpp"
|
||||
|
||||
|
||||
///////////////////////// graphical user interface //////////////////////////
|
||||
@@ -201,392 +203,4 @@ CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change,
|
||||
bool initial_button_state = false);
|
||||
|
||||
} // cv
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// image codec ////////////////////////////////
|
||||
namespace cv
|
||||
{
|
||||
|
||||
enum { IMREAD_UNCHANGED = -1, // 8bit, color or not
|
||||
IMREAD_GRAYSCALE = 0, // 8bit, gray
|
||||
IMREAD_COLOR = 1, // ?, color
|
||||
IMREAD_ANYDEPTH = 2, // any depth, ?
|
||||
IMREAD_ANYCOLOR = 4 // ?, any color
|
||||
};
|
||||
|
||||
enum { IMWRITE_JPEG_QUALITY = 1,
|
||||
IMWRITE_JPEG_PROGRESSIVE = 2,
|
||||
IMWRITE_JPEG_OPTIMIZE = 3,
|
||||
IMWRITE_PNG_COMPRESSION = 16,
|
||||
IMWRITE_PNG_STRATEGY = 17,
|
||||
IMWRITE_PNG_BILEVEL = 18,
|
||||
IMWRITE_PXM_BINARY = 32,
|
||||
IMWRITE_WEBP_QUALITY = 64
|
||||
};
|
||||
|
||||
enum { IMWRITE_PNG_STRATEGY_DEFAULT = 0,
|
||||
IMWRITE_PNG_STRATEGY_FILTERED = 1,
|
||||
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2,
|
||||
IMWRITE_PNG_STRATEGY_RLE = 3,
|
||||
IMWRITE_PNG_STRATEGY_FIXED = 4
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
|
||||
|
||||
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
|
||||
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
|
||||
|
||||
CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst);
|
||||
|
||||
CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
|
||||
CV_OUT std::vector<uchar>& buf,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
|
||||
} // cv
|
||||
|
||||
|
||||
|
||||
////////////////////////////////// video io /////////////////////////////////
|
||||
|
||||
typedef struct CvCapture CvCapture;
|
||||
typedef struct CvVideoWriter CvVideoWriter;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
// Camera API
|
||||
enum { CAP_ANY = 0, // autodetect
|
||||
CAP_VFW = 200, // platform native
|
||||
CAP_V4L = 200,
|
||||
CAP_V4L2 = CAP_V4L,
|
||||
CAP_FIREWARE = 300, // IEEE 1394 drivers
|
||||
CAP_FIREWIRE = CAP_FIREWARE,
|
||||
CAP_IEEE1394 = CAP_FIREWARE,
|
||||
CAP_DC1394 = CAP_FIREWARE,
|
||||
CAP_CMU1394 = CAP_FIREWARE,
|
||||
CAP_QT = 500, // QuickTime
|
||||
CAP_UNICAP = 600, // Unicap drivers
|
||||
CAP_DSHOW = 700, // DirectShow (via videoInput)
|
||||
CAP_PVAPI = 800, // PvAPI, Prosilica GigE SDK
|
||||
CAP_OPENNI = 900, // OpenNI (for Kinect)
|
||||
CAP_OPENNI_ASUS = 910, // OpenNI (for Asus Xtion)
|
||||
CAP_ANDROID = 1000, // Android
|
||||
CAP_XIAPI = 1100, // XIMEA Camera API
|
||||
CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK
|
||||
CAP_MSMF = 1400, // Microsoft Media Foundation (via videoInput)
|
||||
CAP_INTELPERC = 1500 // Intel Perceptual Computing SDK
|
||||
};
|
||||
|
||||
// generic properties (based on DC1394 properties)
|
||||
enum { CAP_PROP_POS_MSEC =0,
|
||||
CAP_PROP_POS_FRAMES =1,
|
||||
CAP_PROP_POS_AVI_RATIO =2,
|
||||
CAP_PROP_FRAME_WIDTH =3,
|
||||
CAP_PROP_FRAME_HEIGHT =4,
|
||||
CAP_PROP_FPS =5,
|
||||
CAP_PROP_FOURCC =6,
|
||||
CAP_PROP_FRAME_COUNT =7,
|
||||
CAP_PROP_FORMAT =8,
|
||||
CAP_PROP_MODE =9,
|
||||
CAP_PROP_BRIGHTNESS =10,
|
||||
CAP_PROP_CONTRAST =11,
|
||||
CAP_PROP_SATURATION =12,
|
||||
CAP_PROP_HUE =13,
|
||||
CAP_PROP_GAIN =14,
|
||||
CAP_PROP_EXPOSURE =15,
|
||||
CAP_PROP_CONVERT_RGB =16,
|
||||
CAP_PROP_WHITE_BALANCE_BLUE_U =17,
|
||||
CAP_PROP_RECTIFICATION =18,
|
||||
CAP_PROP_MONOCROME =19,
|
||||
CAP_PROP_SHARPNESS =20,
|
||||
CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature
|
||||
CAP_PROP_GAMMA =22,
|
||||
CAP_PROP_TEMPERATURE =23,
|
||||
CAP_PROP_TRIGGER =24,
|
||||
CAP_PROP_TRIGGER_DELAY =25,
|
||||
CAP_PROP_WHITE_BALANCE_RED_V =26,
|
||||
CAP_PROP_ZOOM =27,
|
||||
CAP_PROP_FOCUS =28,
|
||||
CAP_PROP_GUID =29,
|
||||
CAP_PROP_ISO_SPEED =30,
|
||||
CAP_PROP_BACKLIGHT =32,
|
||||
CAP_PROP_PAN =33,
|
||||
CAP_PROP_TILT =34,
|
||||
CAP_PROP_ROLL =35,
|
||||
CAP_PROP_IRIS =36,
|
||||
CAP_PROP_SETTINGS =37
|
||||
};
|
||||
|
||||
|
||||
// DC1394 only
|
||||
// modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
|
||||
// every feature can have only one mode turned on at a time
|
||||
enum { CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically)
|
||||
CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user
|
||||
CAP_PROP_DC1394_MODE_AUTO = -2,
|
||||
CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1,
|
||||
CAP_PROP_DC1394_MAX = 31
|
||||
};
|
||||
|
||||
|
||||
// OpenNI map generators
|
||||
enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
|
||||
CAP_OPENNI_IMAGE_GENERATOR = 1 << 30,
|
||||
CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
// Properties of cameras available through OpenNI interfaces
|
||||
enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100,
|
||||
CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm
|
||||
CAP_PROP_OPENNI_BASELINE = 102, // in mm
|
||||
CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels
|
||||
CAP_PROP_OPENNI_REGISTRATION = 104, // flag that synchronizes the remapping depth map to image map
|
||||
// by changing depth generator's view point (if the flag is "on") or
|
||||
// sets this view point to its normal one (if the flag is "off").
|
||||
CAP_PROP_OPENNI_REGISTRATION_ON = CAP_PROP_OPENNI_REGISTRATION,
|
||||
CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105,
|
||||
CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106,
|
||||
CAP_PROP_OPENNI_CIRCLE_BUFFER = 107,
|
||||
CAP_PROP_OPENNI_MAX_TIME_DURATION = 108,
|
||||
CAP_PROP_OPENNI_GENERATOR_PRESENT = 109
|
||||
};
|
||||
|
||||
// OpenNI shortcats
|
||||
enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
|
||||
CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION
|
||||
};
|
||||
|
||||
// OpenNI data given from depth generator
|
||||
enum { CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1)
|
||||
CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3)
|
||||
CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1)
|
||||
CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1)
|
||||
CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1
|
||||
|
||||
// Data given from RGB image generator
|
||||
CAP_OPENNI_BGR_IMAGE = 5,
|
||||
CAP_OPENNI_GRAY_IMAGE = 6
|
||||
};
|
||||
|
||||
// Supported output modes of OpenNI image generator
|
||||
enum { CAP_OPENNI_VGA_30HZ = 0,
|
||||
CAP_OPENNI_SXGA_15HZ = 1,
|
||||
CAP_OPENNI_SXGA_30HZ = 2,
|
||||
CAP_OPENNI_QVGA_30HZ = 3,
|
||||
CAP_OPENNI_QVGA_60HZ = 4
|
||||
};
|
||||
|
||||
|
||||
// GStreamer
|
||||
enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 // default is 1
|
||||
};
|
||||
|
||||
|
||||
// PVAPI
|
||||
enum { CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast
|
||||
CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301 // FrameStartTriggerMode: Determines how a frame is initiated
|
||||
};
|
||||
|
||||
// PVAPI: FrameStartTriggerMode
|
||||
enum { CAP_PVAPI_FSTRIGMODE_FREERUN = 0, // Freerun
|
||||
CAP_PVAPI_FSTRIGMODE_SYNCIN1 = 1, // SyncIn1
|
||||
CAP_PVAPI_FSTRIGMODE_SYNCIN2 = 2, // SyncIn2
|
||||
CAP_PVAPI_FSTRIGMODE_FIXEDRATE = 3, // FixedRate
|
||||
CAP_PVAPI_FSTRIGMODE_SOFTWARE = 4 // Software
|
||||
};
|
||||
|
||||
// Properties of cameras available through XIMEA SDK interface
|
||||
enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
|
||||
CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.
|
||||
CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels).
|
||||
CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels).
|
||||
CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger.
|
||||
CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE.
|
||||
CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input
|
||||
CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode
|
||||
CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level
|
||||
CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output
|
||||
CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode
|
||||
CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED
|
||||
CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality
|
||||
CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition)
|
||||
CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance
|
||||
CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain
|
||||
CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%).
|
||||
CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure
|
||||
CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure
|
||||
CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %)
|
||||
CAP_PROP_XI_TIMEOUT = 420 // Image capture timeout in milliseconds
|
||||
};
|
||||
|
||||
|
||||
// Properties for Android cameras
|
||||
enum { CAP_PROP_ANDROID_AUTOGRAB = 1024,
|
||||
CAP_PROP_ANDROID_PREVIEW_SIZES_STRING = 1025, // readonly, tricky property, returns const char* indeed
|
||||
CAP_PROP_ANDROID_PREVIEW_FORMAT = 1026, // readonly, tricky property, returns const char* indeed
|
||||
CAP_PROP_ANDROID_FLASH_MODE = 8001,
|
||||
CAP_PROP_ANDROID_FOCUS_MODE = 8002,
|
||||
CAP_PROP_ANDROID_WHITE_BALANCE = 8003,
|
||||
CAP_PROP_ANDROID_ANTIBANDING = 8004,
|
||||
CAP_PROP_ANDROID_FOCAL_LENGTH = 8005,
|
||||
CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006,
|
||||
CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007,
|
||||
CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008
|
||||
};
|
||||
|
||||
|
||||
// Android camera output formats
|
||||
enum { CAP_ANDROID_COLOR_FRAME_BGR = 0, //BGR
|
||||
CAP_ANDROID_COLOR_FRAME = CAP_ANDROID_COLOR_FRAME_BGR,
|
||||
CAP_ANDROID_GREY_FRAME = 1, //Y
|
||||
CAP_ANDROID_COLOR_FRAME_RGB = 2,
|
||||
CAP_ANDROID_COLOR_FRAME_BGRA = 3,
|
||||
CAP_ANDROID_COLOR_FRAME_RGBA = 4
|
||||
};
|
||||
|
||||
|
||||
// Android camera flash modes
|
||||
enum { CAP_ANDROID_FLASH_MODE_AUTO = 0,
|
||||
CAP_ANDROID_FLASH_MODE_OFF = 1,
|
||||
CAP_ANDROID_FLASH_MODE_ON = 2,
|
||||
CAP_ANDROID_FLASH_MODE_RED_EYE = 3,
|
||||
CAP_ANDROID_FLASH_MODE_TORCH = 4
|
||||
};
|
||||
|
||||
|
||||
// Android camera focus modes
|
||||
enum { CAP_ANDROID_FOCUS_MODE_AUTO = 0,
|
||||
CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO = 1,
|
||||
CAP_ANDROID_FOCUS_MODE_EDOF = 2,
|
||||
CAP_ANDROID_FOCUS_MODE_FIXED = 3,
|
||||
CAP_ANDROID_FOCUS_MODE_INFINITY = 4,
|
||||
CAP_ANDROID_FOCUS_MODE_MACRO = 5
|
||||
};
|
||||
|
||||
|
||||
// Android camera white balance modes
|
||||
enum { CAP_ANDROID_WHITE_BALANCE_AUTO = 0,
|
||||
CAP_ANDROID_WHITE_BALANCE_CLOUDY_DAYLIGHT = 1,
|
||||
CAP_ANDROID_WHITE_BALANCE_DAYLIGHT = 2,
|
||||
CAP_ANDROID_WHITE_BALANCE_FLUORESCENT = 3,
|
||||
CAP_ANDROID_WHITE_BALANCE_INCANDESCENT = 4,
|
||||
CAP_ANDROID_WHITE_BALANCE_SHADE = 5,
|
||||
CAP_ANDROID_WHITE_BALANCE_TWILIGHT = 6,
|
||||
CAP_ANDROID_WHITE_BALANCE_WARM_FLUORESCENT = 7
|
||||
};
|
||||
|
||||
|
||||
// Android camera antibanding modes
|
||||
enum { CAP_ANDROID_ANTIBANDING_50HZ = 0,
|
||||
CAP_ANDROID_ANTIBANDING_60HZ = 1,
|
||||
CAP_ANDROID_ANTIBANDING_AUTO = 2,
|
||||
CAP_ANDROID_ANTIBANDING_OFF = 3
|
||||
};
|
||||
|
||||
|
||||
// Properties of cameras available through AVFOUNDATION interface
|
||||
enum { CAP_PROP_IOS_DEVICE_FOCUS = 9001,
|
||||
CAP_PROP_IOS_DEVICE_EXPOSURE = 9002,
|
||||
CAP_PROP_IOS_DEVICE_FLASH = 9003,
|
||||
CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004,
|
||||
CAP_PROP_IOS_DEVICE_TORCH = 9005
|
||||
};
|
||||
|
||||
|
||||
// Properties of cameras available through Smartek Giganetix Ethernet Vision interface
|
||||
/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */
|
||||
enum { CAP_PROP_GIGA_FRAME_OFFSET_X = 10001,
|
||||
CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002,
|
||||
CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003,
|
||||
CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004,
|
||||
CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005,
|
||||
CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006
|
||||
};
|
||||
|
||||
enum { CAP_PROP_INTELPERC_PROFILE_COUNT = 11001,
|
||||
CAP_PROP_INTELPERC_PROFILE_IDX = 11002,
|
||||
CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003,
|
||||
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004,
|
||||
CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005,
|
||||
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006,
|
||||
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007
|
||||
};
|
||||
|
||||
// Intel PerC streams
|
||||
enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29,
|
||||
CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28,
|
||||
CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth.
|
||||
CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates.
|
||||
CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam.
|
||||
CAP_INTELPERC_IMAGE = 3
|
||||
};
|
||||
|
||||
|
||||
class IVideoCapture;
|
||||
class CV_EXPORTS_W VideoCapture
|
||||
{
|
||||
public:
|
||||
CV_WRAP VideoCapture();
|
||||
CV_WRAP VideoCapture(const String& filename);
|
||||
CV_WRAP VideoCapture(int device);
|
||||
|
||||
virtual ~VideoCapture();
|
||||
CV_WRAP virtual bool open(const String& filename);
|
||||
CV_WRAP virtual bool open(int device);
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
CV_WRAP virtual void release();
|
||||
|
||||
CV_WRAP virtual bool grab();
|
||||
CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0);
|
||||
virtual VideoCapture& operator >> (CV_OUT Mat& image);
|
||||
virtual VideoCapture& operator >> (CV_OUT UMat& image);
|
||||
CV_WRAP virtual bool read(OutputArray image);
|
||||
|
||||
CV_WRAP virtual bool set(int propId, double value);
|
||||
CV_WRAP virtual double get(int propId);
|
||||
|
||||
protected:
|
||||
Ptr<CvCapture> cap;
|
||||
Ptr<IVideoCapture> icap;
|
||||
private:
|
||||
static Ptr<IVideoCapture> createCameraCapture(int index);
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W VideoWriter
|
||||
{
|
||||
public:
|
||||
CV_WRAP VideoWriter();
|
||||
CV_WRAP VideoWriter(const String& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor = true);
|
||||
|
||||
virtual ~VideoWriter();
|
||||
CV_WRAP virtual bool open(const String& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor = true);
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
CV_WRAP virtual void release();
|
||||
virtual VideoWriter& operator << (const Mat& image);
|
||||
CV_WRAP virtual void write(const Mat& image);
|
||||
|
||||
CV_WRAP static int fourcc(char c1, char c2, char c3, char c4);
|
||||
|
||||
protected:
|
||||
Ptr<CvVideoWriter> writer;
|
||||
};
|
||||
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const;
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const;
|
||||
|
||||
} // cv
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#define __OPENCV_HIGHGUI_H__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgcodecs/imgcodecs_c.h"
|
||||
#include "opencv2/videoio/videoio_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -194,67 +196,6 @@ typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, vo
|
||||
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
|
||||
void* param CV_DEFAULT(NULL));
|
||||
|
||||
enum
|
||||
{
|
||||
/* 8bit, color or not */
|
||||
CV_LOAD_IMAGE_UNCHANGED =-1,
|
||||
/* 8bit, gray */
|
||||
CV_LOAD_IMAGE_GRAYSCALE =0,
|
||||
/* ?, color */
|
||||
CV_LOAD_IMAGE_COLOR =1,
|
||||
/* any depth, ? */
|
||||
CV_LOAD_IMAGE_ANYDEPTH =2,
|
||||
/* ?, any color */
|
||||
CV_LOAD_IMAGE_ANYCOLOR =4
|
||||
};
|
||||
|
||||
/* load image from file
|
||||
iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
|
||||
overrides the other flags
|
||||
using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
|
||||
unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
|
||||
*/
|
||||
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
enum
|
||||
{
|
||||
CV_IMWRITE_JPEG_QUALITY =1,
|
||||
CV_IMWRITE_JPEG_PROGRESSIVE =2,
|
||||
CV_IMWRITE_JPEG_OPTIMIZE =3,
|
||||
CV_IMWRITE_PNG_COMPRESSION =16,
|
||||
CV_IMWRITE_PNG_STRATEGY =17,
|
||||
CV_IMWRITE_PNG_BILEVEL =18,
|
||||
CV_IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
CV_IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
CV_IMWRITE_PNG_STRATEGY_RLE =3,
|
||||
CV_IMWRITE_PNG_STRATEGY_FIXED =4,
|
||||
CV_IMWRITE_PXM_BINARY =32,
|
||||
CV_IMWRITE_WEBP_QUALITY =64
|
||||
};
|
||||
|
||||
/* save image to file */
|
||||
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
/* decode image stored in the buffer */
|
||||
CVAPI(IplImage*) cvDecodeImage( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvDecodeImageM( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */
|
||||
CVAPI(CvMat*) cvEncodeImage( const char* ext, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CVTIMG_FLIP =1,
|
||||
CV_CVTIMG_SWAP_RB =2
|
||||
};
|
||||
|
||||
/* utility function: convert one image to another with optional vertical flip */
|
||||
CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0));
|
||||
|
||||
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
|
||||
CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
|
||||
|
||||
@@ -268,363 +209,10 @@ CVAPI(void) cvUpdateWindow(const char* window_name);
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Working with Video Files and Cameras *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* "black box" capture structure */
|
||||
typedef struct CvCapture CvCapture;
|
||||
|
||||
/* start capturing frames from video file */
|
||||
CVAPI(CvCapture*) cvCreateFileCapture( const char* filename );
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANY =0, // autodetect
|
||||
|
||||
CV_CAP_MIL =100, // MIL proprietary drivers
|
||||
|
||||
CV_CAP_VFW =200, // platform native
|
||||
CV_CAP_V4L =200,
|
||||
CV_CAP_V4L2 =200,
|
||||
|
||||
CV_CAP_FIREWARE =300, // IEEE 1394 drivers
|
||||
CV_CAP_FIREWIRE =300,
|
||||
CV_CAP_IEEE1394 =300,
|
||||
CV_CAP_DC1394 =300,
|
||||
CV_CAP_CMU1394 =300,
|
||||
|
||||
CV_CAP_STEREO =400, // TYZX proprietary drivers
|
||||
CV_CAP_TYZX =400,
|
||||
CV_TYZX_LEFT =400,
|
||||
CV_TYZX_RIGHT =401,
|
||||
CV_TYZX_COLOR =402,
|
||||
CV_TYZX_Z =403,
|
||||
|
||||
CV_CAP_QT =500, // QuickTime
|
||||
|
||||
CV_CAP_UNICAP =600, // Unicap drivers
|
||||
|
||||
CV_CAP_DSHOW =700, // DirectShow (via videoInput)
|
||||
CV_CAP_MSMF =1400, // Microsoft Media Foundation (via videoInput)
|
||||
|
||||
CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK
|
||||
|
||||
CV_CAP_OPENNI =900, // OpenNI (for Kinect)
|
||||
CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion)
|
||||
|
||||
CV_CAP_ANDROID =1000, // Android
|
||||
CV_CAP_ANDROID_BACK =CV_CAP_ANDROID+99, // Android back camera
|
||||
CV_CAP_ANDROID_FRONT =CV_CAP_ANDROID+98, // Android front camera
|
||||
|
||||
CV_CAP_XIAPI =1100, // XIMEA Camera API
|
||||
|
||||
CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
|
||||
CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK
|
||||
|
||||
CV_CAP_INTELPERC = 1500 // Intel Perceptual Computing SDK
|
||||
};
|
||||
|
||||
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
|
||||
CVAPI(CvCapture*) cvCreateCameraCapture( int index );
|
||||
|
||||
/* grab a frame, return 1 on success, 0 on fail.
|
||||
this function is thought to be fast */
|
||||
CVAPI(int) cvGrabFrame( CvCapture* capture );
|
||||
|
||||
/* get the frame grabbed with cvGrabFrame(..)
|
||||
This function may apply some frame processing like
|
||||
frame decompression, flipping etc.
|
||||
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||
CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) );
|
||||
|
||||
/* Just a combination of cvGrabFrame and cvRetrieveFrame
|
||||
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||
CVAPI(IplImage*) cvQueryFrame( CvCapture* capture );
|
||||
|
||||
/* stop capturing/reading and free resources */
|
||||
CVAPI(void) cvReleaseCapture( CvCapture** capture );
|
||||
|
||||
enum
|
||||
{
|
||||
// modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
|
||||
// every feature can have only one mode turned on at a time
|
||||
CV_CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically)
|
||||
CV_CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user
|
||||
CV_CAP_PROP_DC1394_MODE_AUTO = -2,
|
||||
CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1,
|
||||
CV_CAP_PROP_POS_MSEC =0,
|
||||
CV_CAP_PROP_POS_FRAMES =1,
|
||||
CV_CAP_PROP_POS_AVI_RATIO =2,
|
||||
CV_CAP_PROP_FRAME_WIDTH =3,
|
||||
CV_CAP_PROP_FRAME_HEIGHT =4,
|
||||
CV_CAP_PROP_FPS =5,
|
||||
CV_CAP_PROP_FOURCC =6,
|
||||
CV_CAP_PROP_FRAME_COUNT =7,
|
||||
CV_CAP_PROP_FORMAT =8,
|
||||
CV_CAP_PROP_MODE =9,
|
||||
CV_CAP_PROP_BRIGHTNESS =10,
|
||||
CV_CAP_PROP_CONTRAST =11,
|
||||
CV_CAP_PROP_SATURATION =12,
|
||||
CV_CAP_PROP_HUE =13,
|
||||
CV_CAP_PROP_GAIN =14,
|
||||
CV_CAP_PROP_EXPOSURE =15,
|
||||
CV_CAP_PROP_CONVERT_RGB =16,
|
||||
CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17,
|
||||
CV_CAP_PROP_RECTIFICATION =18,
|
||||
CV_CAP_PROP_MONOCROME =19,
|
||||
CV_CAP_PROP_SHARPNESS =20,
|
||||
CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera,
|
||||
// user can adjust refernce level
|
||||
// using this feature
|
||||
CV_CAP_PROP_GAMMA =22,
|
||||
CV_CAP_PROP_TEMPERATURE =23,
|
||||
CV_CAP_PROP_TRIGGER =24,
|
||||
CV_CAP_PROP_TRIGGER_DELAY =25,
|
||||
CV_CAP_PROP_WHITE_BALANCE_RED_V =26,
|
||||
CV_CAP_PROP_ZOOM =27,
|
||||
CV_CAP_PROP_FOCUS =28,
|
||||
CV_CAP_PROP_GUID =29,
|
||||
CV_CAP_PROP_ISO_SPEED =30,
|
||||
CV_CAP_PROP_MAX_DC1394 =31,
|
||||
CV_CAP_PROP_BACKLIGHT =32,
|
||||
CV_CAP_PROP_PAN =33,
|
||||
CV_CAP_PROP_TILT =34,
|
||||
CV_CAP_PROP_ROLL =35,
|
||||
CV_CAP_PROP_IRIS =36,
|
||||
CV_CAP_PROP_SETTINGS =37,
|
||||
|
||||
CV_CAP_PROP_AUTOGRAB =1024, // property for highgui class CvCapture_Android only
|
||||
CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING=1025, // readonly, tricky property, returns cpnst char* indeed
|
||||
CV_CAP_PROP_PREVIEW_FORMAT=1026, // readonly, tricky property, returns cpnst char* indeed
|
||||
|
||||
// OpenNI map generators
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 30,
|
||||
CV_CAP_OPENNI_GENERATORS_MASK = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_OPENNI_IMAGE_GENERATOR,
|
||||
|
||||
// Properties of cameras available through OpenNI interfaces
|
||||
CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100,
|
||||
CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm
|
||||
CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm
|
||||
CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels
|
||||
CV_CAP_PROP_OPENNI_REGISTRATION = 104, // flag
|
||||
CV_CAP_PROP_OPENNI_REGISTRATION_ON = CV_CAP_PROP_OPENNI_REGISTRATION, // flag that synchronizes the remapping depth map to image map
|
||||
// by changing depth generator's view point (if the flag is "on") or
|
||||
// sets this view point to its normal one (if the flag is "off").
|
||||
CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105,
|
||||
CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106,
|
||||
CV_CAP_PROP_OPENNI_CIRCLE_BUFFER = 107,
|
||||
CV_CAP_PROP_OPENNI_MAX_TIME_DURATION = 108,
|
||||
|
||||
CV_CAP_PROP_OPENNI_GENERATOR_PRESENT = 109,
|
||||
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT,
|
||||
CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION,
|
||||
CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION,
|
||||
|
||||
// Properties of cameras available through GStreamer interface
|
||||
CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1
|
||||
|
||||
// PVAPI
|
||||
CV_CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast
|
||||
CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated
|
||||
|
||||
// Properties of cameras available through XIMEA SDK interface
|
||||
CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
|
||||
CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.
|
||||
CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels).
|
||||
CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels).
|
||||
CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger.
|
||||
CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE.
|
||||
CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input
|
||||
CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode
|
||||
CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level
|
||||
CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output
|
||||
CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode
|
||||
CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED
|
||||
CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality
|
||||
CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition)
|
||||
CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance
|
||||
CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain
|
||||
CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%).
|
||||
CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure
|
||||
CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure
|
||||
CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %)
|
||||
CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds
|
||||
|
||||
// Properties for Android cameras
|
||||
CV_CAP_PROP_ANDROID_FLASH_MODE = 8001,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_MODE = 8002,
|
||||
CV_CAP_PROP_ANDROID_WHITE_BALANCE = 8003,
|
||||
CV_CAP_PROP_ANDROID_ANTIBANDING = 8004,
|
||||
CV_CAP_PROP_ANDROID_FOCAL_LENGTH = 8005,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007,
|
||||
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008,
|
||||
CV_CAP_PROP_ANDROID_EXPOSE_LOCK = 8009,
|
||||
CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK = 8010,
|
||||
|
||||
// Properties of cameras available through AVFOUNDATION interface
|
||||
CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001,
|
||||
CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002,
|
||||
CV_CAP_PROP_IOS_DEVICE_FLASH = 9003,
|
||||
CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004,
|
||||
CV_CAP_PROP_IOS_DEVICE_TORCH = 9005,
|
||||
|
||||
// Properties of cameras available through Smartek Giganetix Ethernet Vision interface
|
||||
/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */
|
||||
CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001,
|
||||
CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002,
|
||||
CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003,
|
||||
CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004,
|
||||
CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005,
|
||||
CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006,
|
||||
|
||||
CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001,
|
||||
CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006,
|
||||
CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007,
|
||||
|
||||
// Intel PerC streams
|
||||
CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29,
|
||||
CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28,
|
||||
CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// Data given from depth generator.
|
||||
CV_CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1)
|
||||
CV_CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3)
|
||||
CV_CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1)
|
||||
CV_CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1)
|
||||
CV_CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1
|
||||
|
||||
// Data given from RGB image generator.
|
||||
CV_CAP_OPENNI_BGR_IMAGE = 5,
|
||||
CV_CAP_OPENNI_GRAY_IMAGE = 6
|
||||
};
|
||||
|
||||
// Supported output modes of OpenNI image generator
|
||||
enum
|
||||
{
|
||||
CV_CAP_OPENNI_VGA_30HZ = 0,
|
||||
CV_CAP_OPENNI_SXGA_15HZ = 1,
|
||||
CV_CAP_OPENNI_SXGA_30HZ = 2,
|
||||
CV_CAP_OPENNI_QVGA_30HZ = 3,
|
||||
CV_CAP_OPENNI_QVGA_60HZ = 4
|
||||
};
|
||||
|
||||
//supported by Android camera output formats
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_COLOR_FRAME_BGR = 0, //BGR
|
||||
CV_CAP_ANDROID_COLOR_FRAME = CV_CAP_ANDROID_COLOR_FRAME_BGR,
|
||||
CV_CAP_ANDROID_GREY_FRAME = 1, //Y
|
||||
CV_CAP_ANDROID_COLOR_FRAME_RGB = 2,
|
||||
CV_CAP_ANDROID_COLOR_FRAME_BGRA = 3,
|
||||
CV_CAP_ANDROID_COLOR_FRAME_RGBA = 4
|
||||
};
|
||||
|
||||
// supported Android camera flash modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_FLASH_MODE_AUTO = 0,
|
||||
CV_CAP_ANDROID_FLASH_MODE_OFF,
|
||||
CV_CAP_ANDROID_FLASH_MODE_ON,
|
||||
CV_CAP_ANDROID_FLASH_MODE_RED_EYE,
|
||||
CV_CAP_ANDROID_FLASH_MODE_TORCH
|
||||
};
|
||||
|
||||
// supported Android camera focus modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_FOCUS_MODE_AUTO = 0,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_PICTURE,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_EDOF,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_FIXED,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_INFINITY,
|
||||
CV_CAP_ANDROID_FOCUS_MODE_MACRO
|
||||
};
|
||||
|
||||
// supported Android camera white balance modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_AUTO = 0,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_CLOUDY_DAYLIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_DAYLIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_FLUORESCENT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_INCANDESCENT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_SHADE,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_TWILIGHT,
|
||||
CV_CAP_ANDROID_WHITE_BALANCE_WARM_FLUORESCENT
|
||||
};
|
||||
|
||||
// supported Android camera antibanding modes
|
||||
enum
|
||||
{
|
||||
CV_CAP_ANDROID_ANTIBANDING_50HZ = 0,
|
||||
CV_CAP_ANDROID_ANTIBANDING_60HZ,
|
||||
CV_CAP_ANDROID_ANTIBANDING_AUTO,
|
||||
CV_CAP_ANDROID_ANTIBANDING_OFF
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth.
|
||||
CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates.
|
||||
CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam.
|
||||
CV_CAP_INTELPERC_IMAGE = 3
|
||||
};
|
||||
|
||||
/* retrieve or set capture properties */
|
||||
CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
|
||||
CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
|
||||
|
||||
// Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP), which is unknown if created with CV_CAP_ANY
|
||||
CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
|
||||
|
||||
/* "black box" video file writer structure */
|
||||
typedef struct CvVideoWriter CvVideoWriter;
|
||||
|
||||
#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
|
||||
|
||||
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
|
||||
{
|
||||
return CV_FOURCC_MACRO(c1, c2, c3, c4);
|
||||
}
|
||||
|
||||
#define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */
|
||||
#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') /* Use default codec for specified filename (Linux only) */
|
||||
|
||||
/* initialize video file writer */
|
||||
CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
double fps, CvSize frame_size,
|
||||
int is_color CV_DEFAULT(1));
|
||||
|
||||
/* write frame to video file */
|
||||
CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
|
||||
|
||||
/* close video file writer */
|
||||
CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Obsolete functions/synonyms *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define cvCaptureFromFile cvCreateFileCapture
|
||||
#define cvCaptureFromCAM cvCreateCameraCapture
|
||||
#define cvCaptureFromAVI cvCaptureFromFile
|
||||
#define cvCreateAVIWriter cvCreateVideoWriter
|
||||
#define cvWriteToAVI cvWriteFrame
|
||||
#define cvAddSearchPath(path)
|
||||
#define cvvInitSystem cvInitSystem
|
||||
#define cvvNamedWindow cvNamedWindow
|
||||
@@ -632,12 +220,9 @@ CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
|
||||
#define cvvResizeWindow cvResizeWindow
|
||||
#define cvvDestroyWindow cvDestroyWindow
|
||||
#define cvvCreateTrackbar cvCreateTrackbar
|
||||
#define cvvLoadImage(name) cvLoadImage((name),1)
|
||||
#define cvvSaveImage cvSaveImage
|
||||
#define cvvAddSearchPath cvAddSearchPath
|
||||
#define cvvWaitKey(name) cvWaitKey(0)
|
||||
#define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
|
||||
#define cvvConvertImage cvConvertImage
|
||||
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
|
||||
#define set_preprocess_func cvSetPreprocessFuncWin32
|
||||
#define set_postprocess_func cvSetPostprocessFuncWin32
|
||||
|
||||
@@ -47,7 +47,10 @@
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/imgcodecs/imgcodecs_c.h"
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -92,90 +95,6 @@
|
||||
#define CV_WINDOW_MAGIC_VAL 0x00420042
|
||||
#define CV_TRACKBAR_MAGIC_VAL 0x00420043
|
||||
|
||||
/***************************** CvCapture structure ******************************/
|
||||
|
||||
struct CvCapture
|
||||
{
|
||||
virtual ~CvCapture() {}
|
||||
virtual double getProperty(int) { return 0; }
|
||||
virtual bool setProperty(int, double) { return 0; }
|
||||
virtual bool grabFrame() { return true; }
|
||||
virtual IplImage* retrieveFrame(int) { return 0; }
|
||||
virtual int getCaptureDomain() { return CV_CAP_ANY; } // Return the type of the capture object: CV_CAP_VFW, etc...
|
||||
};
|
||||
|
||||
/*************************** CvVideoWriter structure ****************************/
|
||||
|
||||
struct CvVideoWriter
|
||||
{
|
||||
virtual ~CvVideoWriter() {}
|
||||
virtual bool writeFrame(const IplImage*) { return false; }
|
||||
};
|
||||
|
||||
CvCapture * cvCreateCameraCapture_V4L( int index );
|
||||
CvCapture * cvCreateCameraCapture_DC1394( int index );
|
||||
CvCapture * cvCreateCameraCapture_DC1394_2( int index );
|
||||
CvCapture* cvCreateCameraCapture_MIL( int index );
|
||||
CvCapture* cvCreateCameraCapture_Giganetix( int index );
|
||||
CvCapture * cvCreateCameraCapture_CMU( int index );
|
||||
CV_IMPL CvCapture * cvCreateCameraCapture_TYZX( int index );
|
||||
CvCapture* cvCreateFileCapture_Win32( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_VFW( int index );
|
||||
CvCapture* cvCreateFileCapture_VFW( const char* filename );
|
||||
CvVideoWriter* cvCreateVideoWriter_Win32( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvVideoWriter* cvCreateVideoWriter_VFW( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvCapture* cvCreateCameraCapture_DShow( int index );
|
||||
CvCapture* cvCreateCameraCapture_MSMF( int index );
|
||||
CvCapture* cvCreateFileCapture_MSMF (const char* filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_MSMF( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvCapture* cvCreateCameraCapture_OpenNI( int index );
|
||||
CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||
|
||||
CVAPI(int) cvHaveImageReader(const char* filename);
|
||||
CVAPI(int) cvHaveImageWriter(const char* filename);
|
||||
|
||||
CvCapture* cvCreateFileCapture_Images(const char* filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_Images(const char* filename);
|
||||
|
||||
CvCapture* cvCreateFileCapture_XINE (const char* filename);
|
||||
|
||||
|
||||
|
||||
|
||||
#define CV_CAP_GSTREAMER_1394 0
|
||||
#define CV_CAP_GSTREAMER_V4L 1
|
||||
#define CV_CAP_GSTREAMER_V4L2 2
|
||||
#define CV_CAP_GSTREAMER_FILE 3
|
||||
|
||||
CvCapture* cvCreateCapture_GStreamer(int type, const char *filename);
|
||||
CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char* filename);
|
||||
|
||||
|
||||
CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
|
||||
CvCapture * cvCreateFileCapture_QT (const char * filename);
|
||||
CvCapture * cvCreateCameraCapture_QT (const int index);
|
||||
|
||||
CvVideoWriter* cvCreateVideoWriter_QT ( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
|
||||
CvCapture* cvCreateFileCapture_AVFoundation (const char * filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_AVFoundation( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
|
||||
|
||||
CvCapture * cvCreateCameraCapture_Unicap (const int index);
|
||||
CvCapture * cvCreateCameraCapture_PvAPI (const int index);
|
||||
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
|
||||
//Yannick Verdie 2010
|
||||
void cvSetModeWindow_W32(const char* name, double prop_value);
|
||||
void cvSetModeWindow_GTK(const char* name, double prop_value);
|
||||
@@ -196,20 +115,6 @@ double cvGetRatioWindow_GTK(const char* name);
|
||||
double cvGetOpenGlProp_W32(const char* name);
|
||||
double cvGetOpenGlProp_GTK(const char* name);
|
||||
|
||||
namespace cv
|
||||
{
|
||||
class IVideoCapture
|
||||
{
|
||||
public:
|
||||
virtual ~IVideoCapture() {}
|
||||
virtual double getProperty(int) { return 0; }
|
||||
virtual bool setProperty(int, double) { return 0; }
|
||||
virtual bool grabFrame() = 0;
|
||||
virtual bool retrieveFrame(int, cv::OutputArray) = 0;
|
||||
virtual int getCaptureDomain() { return CAP_ANY; } // Return the type of the capture object: CAP_VFW, etc...
|
||||
};
|
||||
};
|
||||
|
||||
//for QT
|
||||
#if defined (HAVE_QT)
|
||||
double cvGetModeWindow_QT(const char* name);
|
||||
|
||||
@@ -11,80 +11,11 @@
|
||||
|
||||
#include <iostream>
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
//#include "opencv2/imgproc.hpp"
|
||||
//#include "opencv2/imgcodecs.hpp"
|
||||
//#include "opencv2/highgui.hpp"
|
||||
//#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
#if defined(HAVE_DSHOW) || \
|
||||
defined(HAVE_TYZX) || \
|
||||
defined(HAVE_VFW) || \
|
||||
defined(HAVE_LIBV4L) || \
|
||||
(defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_DC1394_2) || \
|
||||
defined(HAVE_DC1394) || \
|
||||
defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_MIL) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_UNICAP) || \
|
||||
defined(HAVE_PVAPI) || \
|
||||
defined(HAVE_OPENNI) || \
|
||||
defined(HAVE_XIMEA) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_GIGE_API) || \
|
||||
defined(HAVE_INTELPERC) || \
|
||||
(0)
|
||||
//defined(HAVE_ANDROID_NATIVE_CAMERA) || - enable after #1193
|
||||
# define BUILD_WITH_CAMERA_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_CAMERA_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
/*defined(HAVE_OPENNI) || too specialized */ \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if /*defined(HAVE_XINE) || */\
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
|
||||
string fourccToString(int fourcc);
|
||||
|
||||
struct VideoFormat
|
||||
{
|
||||
VideoFormat() { fourcc = -1; }
|
||||
VideoFormat(const string& _ext, int _fourcc) : ext(_ext), fourcc(_fourcc) {}
|
||||
bool empty() const { return ext.empty(); }
|
||||
|
||||
string ext;
|
||||
int fourcc;
|
||||
};
|
||||
|
||||
extern const VideoFormat g_specific_fmt_list[];
|
||||
|
||||
}
|
||||
//#include "opencv2/core/private.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
131
modules/imgcodecs/CMakeLists.txt
Normal file
131
modules/imgcodecs/CMakeLists.txt
Normal file
@@ -0,0 +1,131 @@
|
||||
set(the_description "Image codecs")
|
||||
ocv_add_module(imgcodecs opencv_imgproc)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for imgcodecs. See root CMakeLists.txt
|
||||
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
|
||||
# Jose Luis Blanco, 2008
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
ocv_clear_vars(GRFMT_LIBS)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_JPEG)
|
||||
ocv_include_directories(${JPEG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_WEBP)
|
||||
add_definitions(-DHAVE_WEBP)
|
||||
ocv_include_directories(${WEBP_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_PNG)
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
ocv_include_directories(${PNG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_TIFF)
|
||||
ocv_include_directories(${TIFF_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_JASPER)
|
||||
ocv_include_directories(${JASPER_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENEXR)
|
||||
include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
|
||||
list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
file(GLOB grfmt_hdrs src/grfmt*.hpp)
|
||||
file(GLOB grfmt_srcs src/grfmt*.cpp)
|
||||
list(APPEND grfmt_hdrs src/bitstrm.hpp)
|
||||
list(APPEND grfmt_srcs src/bitstrm.cpp)
|
||||
list(APPEND grfmt_hdrs src/rgbe.hpp)
|
||||
list(APPEND grfmt_srcs src/rgbe.cpp)
|
||||
|
||||
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
||||
|
||||
set(imgcodecs_hdrs
|
||||
src/precomp.hpp
|
||||
src/utils.hpp
|
||||
)
|
||||
|
||||
set(imgcodecs_srcs
|
||||
src/loadsave.cpp
|
||||
src/utils.cpp
|
||||
)
|
||||
|
||||
file(GLOB imgcodecs_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
|
||||
if(IOS)
|
||||
add_definitions(-DHAVE_IOS=1)
|
||||
list(APPEND imgcodecs_srcs src/ios_conversions.mm)
|
||||
list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework CoreImage" "-framework QuartzCore" "-framework AssetsLibrary")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
#these variables are set by CHECK_MODULE macro
|
||||
foreach(P ${IMGCODECS_INCLUDE_DIRS})
|
||||
ocv_include_directories(${P})
|
||||
endforeach()
|
||||
|
||||
foreach(P ${IMGCODECS_LIBRARY_DIRS})
|
||||
link_directories(${P})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
source_group("Src" FILES ${imgcodecs_srcs} ${imgcodecs_hdrs})
|
||||
source_group("Include" FILES ${imgcodecs_ext_hdrs})
|
||||
ocv_set_module_sources(HEADERS ${imgcodecs_ext_hdrs} SOURCES ${imgcodecs_srcs} ${imgcodecs_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
|
||||
ocv_module_include_directories()
|
||||
|
||||
ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES})
|
||||
|
||||
if(APPLE)
|
||||
ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
|
||||
if(HAVE_OBJC_EXCEPTIONS)
|
||||
foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
|
||||
if("${source}" MATCHES "\\.mm$")
|
||||
get_source_file_property(flags "${source}" COMPILE_FLAGS)
|
||||
if(flags)
|
||||
set(flags "${_flags} -fobjc-exceptions")
|
||||
else()
|
||||
set(flags "-fobjc-exceptions")
|
||||
endif()
|
||||
|
||||
set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_definitions(-DIMGCODECS_EXPORTS)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
|
||||
endif()
|
||||
|
||||
#stop automatic dependencies propagation for this module
|
||||
set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
|
||||
ocv_add_precompiled_headers(${the_module})
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
10
modules/imgcodecs/doc/imgcodecs.rst
Normal file
10
modules/imgcodecs/doc/imgcodecs.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
*****************************************
|
||||
imgcodecs. Image file reading and writing
|
||||
*****************************************
|
||||
|
||||
This module of the OpenCV help you read and write images to/from disk or memory.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
reading_and_writing_images
|
||||
187
modules/imgcodecs/doc/reading_and_writing_images.rst
Normal file
187
modules/imgcodecs/doc/reading_and_writing_images.rst
Normal file
@@ -0,0 +1,187 @@
|
||||
Reading and Writing Images
|
||||
==========================
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
imdecode
|
||||
--------
|
||||
Reads an image from a buffer in memory.
|
||||
|
||||
.. ocv:function:: Mat imdecode( InputArray buf, int flags )
|
||||
|
||||
.. ocv:function:: Mat imdecode( InputArray buf, int flags, Mat* dst )
|
||||
|
||||
.. ocv:cfunction:: IplImage* cvDecodeImage( const CvMat* buf, int iscolor=CV_LOAD_IMAGE_COLOR)
|
||||
|
||||
.. ocv:cfunction:: CvMat* cvDecodeImageM( const CvMat* buf, int iscolor=CV_LOAD_IMAGE_COLOR)
|
||||
|
||||
.. ocv:pyfunction:: cv2.imdecode(buf, flags) -> retval
|
||||
|
||||
:param buf: Input array or vector of bytes.
|
||||
|
||||
:param flags: The same flags as in :ocv:func:`imread` .
|
||||
|
||||
:param dst: The optional output placeholder for the decoded matrix. It can save the image reallocations when the function is called repeatedly for images of the same size.
|
||||
|
||||
The function reads an image from the specified buffer in the memory.
|
||||
If the buffer is too short or contains invalid data, the empty matrix/image is returned.
|
||||
|
||||
See
|
||||
:ocv:func:`imread` for the list of supported formats and flags description.
|
||||
|
||||
.. note:: In the case of color images, the decoded images will have the channels stored in ``B G R`` order.
|
||||
|
||||
imencode
|
||||
--------
|
||||
Encodes an image into a memory buffer.
|
||||
|
||||
.. ocv:function:: bool imencode( const String& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>())
|
||||
|
||||
.. ocv:cfunction:: CvMat* cvEncodeImage( const char* ext, const CvArr* image, const int* params=0 )
|
||||
|
||||
.. ocv:pyfunction:: cv2.imencode(ext, img[, params]) -> retval, buf
|
||||
|
||||
:param ext: File extension that defines the output format.
|
||||
|
||||
:param img: Image to be written.
|
||||
|
||||
:param buf: Output buffer resized to fit the compressed image.
|
||||
|
||||
:param params: Format-specific parameters. See :ocv:func:`imwrite` .
|
||||
|
||||
The function compresses the image and stores it in the memory buffer that is resized to fit the result.
|
||||
See
|
||||
:ocv:func:`imwrite` for the list of supported formats and flags description.
|
||||
|
||||
.. note:: ``cvEncodeImage`` returns single-row matrix of type ``CV_8UC1`` that contains encoded image as array of bytes.
|
||||
|
||||
imread
|
||||
------
|
||||
Loads an image from a file.
|
||||
|
||||
.. ocv:function:: Mat imread( const String& filename, int flags=IMREAD_COLOR )
|
||||
|
||||
.. ocv:pyfunction:: cv2.imread(filename[, flags]) -> retval
|
||||
|
||||
.. ocv:cfunction:: IplImage* cvLoadImage( const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR )
|
||||
|
||||
.. ocv:cfunction:: CvMat* cvLoadImageM( const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR )
|
||||
|
||||
:param filename: Name of file to be loaded.
|
||||
|
||||
:param flags: Flags specifying the color type of a loaded image:
|
||||
|
||||
* CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
|
||||
|
||||
* CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
|
||||
|
||||
* CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
|
||||
|
||||
* **>0** Return a 3-channel color image.
|
||||
.. note:: In the current implementation the alpha channel, if any, is stripped from the output image. Use negative value if you need the alpha channel.
|
||||
|
||||
* **=0** Return a grayscale image.
|
||||
|
||||
* **<0** Return the loaded image as is (with alpha channel).
|
||||
|
||||
The function ``imread`` loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( ``Mat::data==NULL`` ). Currently, the following file formats are supported:
|
||||
|
||||
* Windows bitmaps - ``*.bmp, *.dib`` (always supported)
|
||||
|
||||
* JPEG files - ``*.jpeg, *.jpg, *.jpe`` (see the *Notes* section)
|
||||
|
||||
* JPEG 2000 files - ``*.jp2`` (see the *Notes* section)
|
||||
|
||||
* Portable Network Graphics - ``*.png`` (see the *Notes* section)
|
||||
|
||||
* WebP - ``*.webp`` (see the *Notes* section)
|
||||
|
||||
* Portable image format - ``*.pbm, *.pgm, *.ppm`` (always supported)
|
||||
|
||||
* Sun rasters - ``*.sr, *.ras`` (always supported)
|
||||
|
||||
* TIFF files - ``*.tiff, *.tif`` (see the *Notes* section)
|
||||
|
||||
.. note::
|
||||
|
||||
* The function determines the type of an image by the content, not by the file extension.
|
||||
|
||||
* On Microsoft Windows* OS and MacOSX*, the codecs shipped with an OpenCV image (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware that currently these native image loaders give images with different pixel values because of the color management embedded into MacOSX.
|
||||
|
||||
* On Linux*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, "libjpeg-dev", in Debian* and Ubuntu*) to get the codec support or turn on the ``OPENCV_BUILD_3RDPARTY_LIBS`` flag in CMake.
|
||||
|
||||
.. note:: In the case of color images, the decoded images will have the channels stored in ``B G R`` order.
|
||||
|
||||
imwrite
|
||||
-----------
|
||||
Saves an image to a specified file.
|
||||
|
||||
.. ocv:function:: bool imwrite( const String& filename, InputArray img, const vector<int>& params=vector<int>() )
|
||||
|
||||
.. ocv:pyfunction:: cv2.imwrite(filename, img[, params]) -> retval
|
||||
|
||||
.. ocv:cfunction:: int cvSaveImage( const char* filename, const CvArr* image, const int* params=0 )
|
||||
|
||||
:param filename: Name of the file.
|
||||
|
||||
:param image: Image to be saved.
|
||||
|
||||
:param params: Format-specific save parameters encoded as pairs ``paramId_1, paramValue_1, paramId_2, paramValue_2, ...`` . The following parameters are currently supported:
|
||||
|
||||
* For JPEG, it can be a quality ( ``CV_IMWRITE_JPEG_QUALITY`` ) from 0 to 100 (the higher is the better). Default value is 95.
|
||||
|
||||
* For WEBP, it can be a quality ( CV_IMWRITE_WEBP_QUALITY ) from 1 to 100 (the higher is the better).
|
||||
By default (without any parameter) and for quality above 100 the lossless compression is used.
|
||||
|
||||
* For PNG, it can be the compression level ( ``CV_IMWRITE_PNG_COMPRESSION`` ) from 0 to 9. A higher value means a smaller size and longer compression time. Default value is 3.
|
||||
|
||||
* For PPM, PGM, or PBM, it can be a binary format flag ( ``CV_IMWRITE_PXM_BINARY`` ), 0 or 1. Default value is 1.
|
||||
|
||||
The function ``imwrite`` saves the image to the specified file. The image format is chosen based on the ``filename`` extension (see
|
||||
:ocv:func:`imread` for the list of extensions). Only 8-bit (or 16-bit unsigned (``CV_16U``) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use
|
||||
:ocv:func:`Mat::convertTo` , and
|
||||
:ocv:func:`cvtColor` to convert it before saving. Or, use the universal :ocv:class:`FileStorage` I/O functions to save the image to XML or YAML format.
|
||||
|
||||
It is possible to store PNG images with an alpha channel using this function. To do this, create 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535. The sample below shows how to create such a BGRA image and store to PNG file. It also demonstrates how to set custom compression parameters ::
|
||||
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
void createAlphaMat(Mat &mat)
|
||||
{
|
||||
for (int i = 0; i < mat.rows; ++i) {
|
||||
for (int j = 0; j < mat.cols; ++j) {
|
||||
Vec4b& rgba = mat.at<Vec4b>(i, j);
|
||||
rgba[0] = UCHAR_MAX;
|
||||
rgba[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX);
|
||||
rgba[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX);
|
||||
rgba[3] = saturate_cast<uchar>(0.5 * (rgba[1] + rgba[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argv, char **argc)
|
||||
{
|
||||
// Create mat with alpha channel
|
||||
Mat mat(480, 640, CV_8UC4);
|
||||
createAlphaMat(mat);
|
||||
|
||||
vector<int> compression_params;
|
||||
compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
|
||||
compression_params.push_back(9);
|
||||
|
||||
try {
|
||||
imwrite("alpha.png", mat, compression_params);
|
||||
}
|
||||
catch (runtime_error& ex) {
|
||||
fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Saved PNG file with alpha data.\n");
|
||||
return 0;
|
||||
}
|
||||
91
modules/imgcodecs/include/opencv2/imgcodecs.hpp
Normal file
91
modules/imgcodecs/include/opencv2/imgcodecs.hpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_IMGCODECS_HPP__
|
||||
#define __OPENCV_IMGCODECS_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
//////////////////////////////// image codec ////////////////////////////////
|
||||
namespace cv
|
||||
{
|
||||
|
||||
enum { IMREAD_UNCHANGED = -1, // 8bit, color or not
|
||||
IMREAD_GRAYSCALE = 0, // 8bit, gray
|
||||
IMREAD_COLOR = 1, // ?, color
|
||||
IMREAD_ANYDEPTH = 2, // any depth, ?
|
||||
IMREAD_ANYCOLOR = 4 // ?, any color
|
||||
};
|
||||
|
||||
enum { IMWRITE_JPEG_QUALITY = 1,
|
||||
IMWRITE_JPEG_PROGRESSIVE = 2,
|
||||
IMWRITE_JPEG_OPTIMIZE = 3,
|
||||
IMWRITE_PNG_COMPRESSION = 16,
|
||||
IMWRITE_PNG_STRATEGY = 17,
|
||||
IMWRITE_PNG_BILEVEL = 18,
|
||||
IMWRITE_PXM_BINARY = 32,
|
||||
IMWRITE_WEBP_QUALITY = 64
|
||||
};
|
||||
|
||||
enum { IMWRITE_PNG_STRATEGY_DEFAULT = 0,
|
||||
IMWRITE_PNG_STRATEGY_FILTERED = 1,
|
||||
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2,
|
||||
IMWRITE_PNG_STRATEGY_RLE = 3,
|
||||
IMWRITE_PNG_STRATEGY_FIXED = 4
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
|
||||
|
||||
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
|
||||
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
|
||||
|
||||
CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst);
|
||||
|
||||
CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
|
||||
CV_OUT std::vector<uchar>& buf,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_IMGCODECS_HPP__
|
||||
48
modules/imgcodecs/include/opencv2/imgcodecs/imgcodecs.hpp
Normal file
48
modules/imgcodecs/include/opencv2/imgcodecs/imgcodecs.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
129
modules/imgcodecs/include/opencv2/imgcodecs/imgcodecs_c.h
Normal file
129
modules/imgcodecs/include/opencv2/imgcodecs/imgcodecs_c.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_IMGCODECS_H__
|
||||
#define __OPENCV_IMGCODECS_H__
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum
|
||||
{
|
||||
/* 8bit, color or not */
|
||||
CV_LOAD_IMAGE_UNCHANGED =-1,
|
||||
/* 8bit, gray */
|
||||
CV_LOAD_IMAGE_GRAYSCALE =0,
|
||||
/* ?, color */
|
||||
CV_LOAD_IMAGE_COLOR =1,
|
||||
/* any depth, ? */
|
||||
CV_LOAD_IMAGE_ANYDEPTH =2,
|
||||
/* ?, any color */
|
||||
CV_LOAD_IMAGE_ANYCOLOR =4
|
||||
};
|
||||
|
||||
/* load image from file
|
||||
iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
|
||||
overrides the other flags
|
||||
using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
|
||||
unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
|
||||
*/
|
||||
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
enum
|
||||
{
|
||||
CV_IMWRITE_JPEG_QUALITY =1,
|
||||
CV_IMWRITE_JPEG_PROGRESSIVE =2,
|
||||
CV_IMWRITE_JPEG_OPTIMIZE =3,
|
||||
CV_IMWRITE_PNG_COMPRESSION =16,
|
||||
CV_IMWRITE_PNG_STRATEGY =17,
|
||||
CV_IMWRITE_PNG_BILEVEL =18,
|
||||
CV_IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
CV_IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
CV_IMWRITE_PNG_STRATEGY_RLE =3,
|
||||
CV_IMWRITE_PNG_STRATEGY_FIXED =4,
|
||||
CV_IMWRITE_PXM_BINARY =32,
|
||||
CV_IMWRITE_WEBP_QUALITY =64
|
||||
};
|
||||
|
||||
/* save image to file */
|
||||
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
/* decode image stored in the buffer */
|
||||
CVAPI(IplImage*) cvDecodeImage( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
CVAPI(CvMat*) cvDecodeImageM( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
|
||||
|
||||
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */
|
||||
CVAPI(CvMat*) cvEncodeImage( const char* ext, const CvArr* image,
|
||||
const int* params CV_DEFAULT(0) );
|
||||
|
||||
enum
|
||||
{
|
||||
CV_CVTIMG_FLIP =1,
|
||||
CV_CVTIMG_SWAP_RB =2
|
||||
};
|
||||
|
||||
/* utility function: convert one image to another with optional vertical flip */
|
||||
CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0));
|
||||
|
||||
CVAPI(int) cvHaveImageReader(const char* filename);
|
||||
CVAPI(int) cvHaveImageWriter(const char* filename);
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Obsolete functions/synonyms *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define cvvLoadImage(name) cvLoadImage((name),1)
|
||||
#define cvvSaveImage cvSaveImage
|
||||
#define cvvConvertImage cvConvertImage
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __OPENCV_IMGCODECS_H__
|
||||
@@ -41,8 +41,11 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Accelerate/Accelerate.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#include "opencv2/core/core.hpp"
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
|
||||
UIImage* MatToUIImage(const cv::Mat& image);
|
||||
void UIImageToMat(const UIImage* image,
|
||||
3
modules/imgcodecs/perf/perf_main.cpp
Normal file
3
modules/imgcodecs/perf/perf_main.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
CV_PERF_TEST_MAIN(imgcodecs)
|
||||
19
modules/imgcodecs/perf/perf_precomp.hpp
Normal file
19
modules/imgcodecs/perf/perf_precomp.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_PERF_PRECOMP_HPP__
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -40,7 +40,11 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Accelerate/Accelerate.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#include "opencv2/core.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
UIImage* MatToUIImage(const cv::Mat& image) {
|
||||
@@ -454,7 +454,7 @@ bool imencode( const String& ext, InputArray _image,
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
* HighGUI loading & saving function implementation *
|
||||
* Imgcodecs loading & saving function implementation *
|
||||
\****************************************************************************************/
|
||||
|
||||
CV_IMPL int
|
||||
84
modules/imgcodecs/src/precomp.hpp
Normal file
84
modules/imgcodecs/src/precomp.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __IMGCODECS_H_
|
||||
#define __IMGCODECS_H_
|
||||
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/imgcodecs/imgcodecs_c.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined WIN32 || defined WINCE
|
||||
#if !defined _WIN32_WINNT
|
||||
#ifdef HAVE_MSMF
|
||||
#define _WIN32_WINNT 0x0600 // Windows Vista
|
||||
#else
|
||||
#define _WIN32_WINNT 0x0500 // Windows 2000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
#undef max
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
#include "opencv2/imgcodecs/imgcodecs_tegra.hpp"
|
||||
#endif
|
||||
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
#define __END__ __CV_END__
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#endif /* __IMGCODECS_H_ */
|
||||
@@ -41,7 +41,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
@@ -408,8 +407,8 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
TEST(Highgui_Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Highgui_Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
class CV_FillConvexPolyTest : public cvtest::BaseTest
|
||||
@@ -444,4 +443,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Drawing, fillconvexpoly_clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Drawing, fillconvexpoly_clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
@@ -41,7 +41,6 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
@@ -223,12 +222,12 @@ public:
|
||||
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
TEST(Highgui_Image, write_big) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Image, write_big) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
TEST(Highgui_Image, write_imageseq) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Image, write_imageseq) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
|
||||
|
||||
TEST(Highgui_Image, read_bmp_rle8) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Image, read_bmp_rle8) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
class CV_GrfmtPNGEncodeTest : public cvtest::BaseTest
|
||||
@@ -257,9 +256,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Image, encode_png) { CV_GrfmtPNGEncodeTest test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Image, encode_png) { CV_GrfmtPNGEncodeTest test; test.safe_run(); }
|
||||
|
||||
TEST(Highgui_ImreadVSCvtColor, regression)
|
||||
TEST(Imgcodecs_ImreadVSCvtColor, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
|
||||
@@ -375,11 +374,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Image, read_png_color_palette_with_alpha) { CV_GrfmtReadPNGColorPaletteWithAlphaTest test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Image, read_png_color_palette_with_alpha) { CV_GrfmtReadPNGColorPaletteWithAlphaTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
TEST(Highgui_Jpeg, encode_empty)
|
||||
TEST(Imgcodecs_Jpeg, encode_empty)
|
||||
{
|
||||
cv::Mat img;
|
||||
std::vector<uchar> jpegImg;
|
||||
@@ -387,7 +386,7 @@ TEST(Highgui_Jpeg, encode_empty)
|
||||
ASSERT_THROW(cv::imencode(".jpg", img, jpegImg), cv::Exception);
|
||||
}
|
||||
|
||||
TEST(Highgui_Jpeg, encode_decode_progressive_jpeg)
|
||||
TEST(Imgcodecs_Jpeg, encode_decode_progressive_jpeg)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
@@ -411,7 +410,7 @@ TEST(Highgui_Jpeg, encode_decode_progressive_jpeg)
|
||||
remove(output_progressive.c_str());
|
||||
}
|
||||
|
||||
TEST(Highgui_Jpeg, encode_decode_optimize_jpeg)
|
||||
TEST(Imgcodecs_Jpeg, encode_decode_optimize_jpeg)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
@@ -447,9 +446,9 @@ TEST(Highgui_Jpeg, encode_decode_optimize_jpeg)
|
||||
#ifdef ANDROID
|
||||
// Test disabled as it uses a lot of memory.
|
||||
// It is killed with SIGKILL by out of memory killer.
|
||||
TEST(Highgui_Tiff, DISABLED_decode_tile16384x16384)
|
||||
TEST(Imgcodecs_Tiff, DISABLED_decode_tile16384x16384)
|
||||
#else
|
||||
TEST(Highgui_Tiff, decode_tile16384x16384)
|
||||
TEST(Imgcodecs_Tiff, decode_tile16384x16384)
|
||||
#endif
|
||||
{
|
||||
// see issue #2161
|
||||
@@ -478,7 +477,7 @@ TEST(Highgui_Tiff, decode_tile16384x16384)
|
||||
remove(file4.c_str());
|
||||
}
|
||||
|
||||
TEST(Highgui_Tiff, write_read_16bit_big_little_endian)
|
||||
TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian)
|
||||
{
|
||||
// see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness"
|
||||
|
||||
@@ -561,7 +560,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Tiff, decode_tile_remainder)
|
||||
TEST(Imgcodecs_Tiff, decode_tile_remainder)
|
||||
{
|
||||
CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run();
|
||||
}
|
||||
@@ -570,7 +569,7 @@ TEST(Highgui_Tiff, decode_tile_remainder)
|
||||
|
||||
#ifdef HAVE_WEBP
|
||||
|
||||
TEST(Highgui_WebP, encode_decode_lossless_webp)
|
||||
TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
@@ -619,7 +618,7 @@ TEST(Highgui_WebP, encode_decode_lossless_webp)
|
||||
EXPECT_TRUE(cvtest::norm(img, img_webp, NORM_INF) == 0);
|
||||
}
|
||||
|
||||
TEST(Highgui_WebP, encode_decode_lossy_webp)
|
||||
TEST(Imgcodecs_WebP, encode_decode_lossy_webp)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
@@ -643,7 +642,7 @@ TEST(Highgui_WebP, encode_decode_lossy_webp)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Highgui_WebP, encode_decode_with_alpha_webp)
|
||||
TEST(Imgcodecs_WebP, encode_decode_with_alpha_webp)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
|
||||
@@ -669,7 +668,7 @@ TEST(Highgui_WebP, encode_decode_with_alpha_webp)
|
||||
|
||||
#endif
|
||||
|
||||
TEST(Highgui_Hdr, regression)
|
||||
TEST(Imgcodecs_Hdr, regression)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
|
||||
string name_rle = folder + "rle.hdr";
|
||||
3
modules/imgcodecs/test/test_main.cpp
Normal file
3
modules/imgcodecs/test/test_main.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
CV_TEST_MAIN("imgcodecs")
|
||||
20
modules/imgcodecs/test/test_precomp.hpp
Normal file
20
modules/imgcodecs/test/test_precomp.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
#endif
|
||||
@@ -181,6 +181,8 @@ Compares two histograms.
|
||||
|
||||
* **CV_COMP_HELLINGER** Synonym for ``CV_COMP_BHATTACHARYYA``
|
||||
|
||||
* **CV_COMP_KL_DIV** Kullback-Leibler divergence
|
||||
|
||||
The functions ``compareHist`` compare two dense or two sparse histograms using the specified method:
|
||||
|
||||
* Correlation (``method=CV_COMP_CORREL``)
|
||||
@@ -224,6 +226,12 @@ The functions ``compareHist`` compare two dense or two sparse histograms using t
|
||||
|
||||
d(H_1,H_2) = \sqrt{1 - \frac{1}{\sqrt{\bar{H_1} \bar{H_2} N^2}} \sum_I \sqrt{H_1(I) \cdot H_2(I)}}
|
||||
|
||||
* Kullback-Leibler divergence (``method=CV_COMP_KL_DIV``).
|
||||
|
||||
.. math::
|
||||
|
||||
d(H_1,H_2) = \sum _I H_1(I) \log \left(\frac{H_1(I)}{H_2(I)}\right)
|
||||
|
||||
The function returns
|
||||
:math:`d(H_1, H_2)` .
|
||||
|
||||
|
||||
@@ -204,7 +204,8 @@ enum { HISTCMP_CORREL = 0,
|
||||
HISTCMP_INTERSECT = 2,
|
||||
HISTCMP_BHATTACHARYYA = 3,
|
||||
HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA,
|
||||
HISTCMP_CHISQR_ALT = 4
|
||||
HISTCMP_CHISQR_ALT = 4,
|
||||
HISTCMP_KL_DIV = 5
|
||||
};
|
||||
|
||||
//! the color conversion code
|
||||
|
||||
@@ -509,7 +509,8 @@ enum
|
||||
CV_COMP_INTERSECT =2,
|
||||
CV_COMP_BHATTACHARYYA =3,
|
||||
CV_COMP_HELLINGER =CV_COMP_BHATTACHARYYA,
|
||||
CV_COMP_CHISQR_ALT =4
|
||||
CV_COMP_CHISQR_ALT =4,
|
||||
CV_COMP_KL_DIV =5
|
||||
};
|
||||
|
||||
/* Mask size for distance transform */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
|
||||
@@ -348,6 +348,10 @@ void cv::Canny( InputArray _src, OutputArray _dst,
|
||||
#define CANNY_PUSH(d) *(d) = uchar(2), *stack_top++ = (d)
|
||||
#define CANNY_POP(d) (d) = *--stack_top
|
||||
|
||||
#if CV_SSE2
|
||||
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
|
||||
#endif
|
||||
|
||||
// calculate magnitude and angle of gradient, perform non-maxima suppression.
|
||||
// fill the map with one of the following values:
|
||||
// 0 - the pixel might belong to an edge
|
||||
@@ -363,12 +367,52 @@ void cv::Canny( InputArray _src, OutputArray _dst,
|
||||
|
||||
if (!L2gradient)
|
||||
{
|
||||
for (int j = 0; j < src.cols*cn; j++)
|
||||
int j = 0, width = src.cols * cn;
|
||||
#if CV_SSE2
|
||||
if (haveSSE2)
|
||||
{
|
||||
__m128i v_zero = _mm_setzero_si128();
|
||||
for ( ; j <= width - 8; j += 8)
|
||||
{
|
||||
__m128i v_dx = _mm_loadu_si128((const __m128i *)(_dx + j));
|
||||
__m128i v_dy = _mm_loadu_si128((const __m128i *)(_dy + j));
|
||||
v_dx = _mm_max_epi16(v_dx, _mm_sub_epi16(v_zero, v_dx));
|
||||
v_dy = _mm_max_epi16(v_dy, _mm_sub_epi16(v_zero, v_dy));
|
||||
|
||||
__m128i v_norm = _mm_add_epi32(_mm_unpacklo_epi16(v_dx, v_zero), _mm_unpacklo_epi16(v_dy, v_zero));
|
||||
_mm_storeu_si128((__m128i *)(_norm + j), v_norm);
|
||||
|
||||
v_norm = _mm_add_epi32(_mm_unpackhi_epi16(v_dx, v_zero), _mm_unpackhi_epi16(v_dy, v_zero));
|
||||
_mm_storeu_si128((__m128i *)(_norm + j + 4), v_norm);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for ( ; j < width; ++j)
|
||||
_norm[j] = std::abs(int(_dx[j])) + std::abs(int(_dy[j]));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < src.cols*cn; j++)
|
||||
int j = 0, width = src.cols * cn;
|
||||
#if CV_SSE2
|
||||
if (haveSSE2)
|
||||
{
|
||||
for ( ; j <= width - 8; j += 8)
|
||||
{
|
||||
__m128i v_dx = _mm_loadu_si128((const __m128i *)(_dx + j));
|
||||
__m128i v_dy = _mm_loadu_si128((const __m128i *)(_dy + j));
|
||||
|
||||
__m128i v_dx_ml = _mm_mullo_epi16(v_dx, v_dx), v_dx_mh = _mm_mulhi_epi16(v_dx, v_dx);
|
||||
__m128i v_dy_ml = _mm_mullo_epi16(v_dy, v_dy), v_dy_mh = _mm_mulhi_epi16(v_dy, v_dy);
|
||||
|
||||
__m128i v_norm = _mm_add_epi32(_mm_unpacklo_epi16(v_dx_ml, v_dx_mh), _mm_unpacklo_epi16(v_dy_ml, v_dy_mh));
|
||||
_mm_storeu_si128((__m128i *)(_norm + j), v_norm);
|
||||
|
||||
v_norm = _mm_add_epi32(_mm_unpackhi_epi16(v_dx_ml, v_dx_mh), _mm_unpackhi_epi16(v_dy_ml, v_dy_mh));
|
||||
_mm_storeu_si128((__m128i *)(_norm + j + 4), v_norm);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for ( ; j < width; ++j)
|
||||
_norm[j] = int(_dx[j])*_dx[j] + int(_dy[j])*_dy[j];
|
||||
}
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) != 0 || !_src.isSubmatrix()) &&
|
||||
((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)))
|
||||
((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)) && !ocl::useOpenCL())
|
||||
{
|
||||
int iscale = saturate_cast<int>(scale), idelta = saturate_cast<int>(delta);
|
||||
bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1;
|
||||
|
||||
@@ -2325,6 +2325,21 @@ double cv::compareHist( InputArray _H1, InputArray _H2, int method )
|
||||
s2 += b;
|
||||
}
|
||||
}
|
||||
else if( method == CV_COMP_KL_DIV )
|
||||
{
|
||||
for( j = 0; j < len; j++ )
|
||||
{
|
||||
double p = h1[j];
|
||||
double q = h2[j];
|
||||
if( fabs(p) <= DBL_EPSILON ) {
|
||||
continue;
|
||||
}
|
||||
if( fabs(q) <= DBL_EPSILON ) {
|
||||
q = 1e-10;
|
||||
}
|
||||
result += p * std::log( p / q );
|
||||
}
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadArg, "Unknown comparison method" );
|
||||
}
|
||||
@@ -2360,7 +2375,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
|
||||
CV_Assert( H1.size(i) == H2.size(i) );
|
||||
|
||||
const SparseMat *PH1 = &H1, *PH2 = &H2;
|
||||
if( PH1->nzcount() > PH2->nzcount() && method != CV_COMP_CHISQR && method != CV_COMP_CHISQR_ALT)
|
||||
if( PH1->nzcount() > PH2->nzcount() && method != CV_COMP_CHISQR && method != CV_COMP_CHISQR_ALT && method != CV_COMP_KL_DIV )
|
||||
std::swap(PH1, PH2);
|
||||
|
||||
SparseMatConstIterator it = PH1->begin();
|
||||
@@ -2440,6 +2455,18 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
|
||||
s1 = fabs(s1) > FLT_EPSILON ? 1./std::sqrt(s1) : 1.;
|
||||
result = std::sqrt(std::max(1. - result*s1, 0.));
|
||||
}
|
||||
else if( method == CV_COMP_KL_DIV )
|
||||
{
|
||||
for( i = 0; i < N1; i++, ++it )
|
||||
{
|
||||
double v1 = it.value<float>();
|
||||
const SparseMat::Node* node = it.node();
|
||||
double v2 = PH2->value<float>(node->idx, (size_t*)&node->hashval);
|
||||
if( !v2 )
|
||||
v2 = 1e-10;
|
||||
result += v1 * std::log( v1 / v2 );
|
||||
}
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadArg, "Unknown comparison method" );
|
||||
|
||||
@@ -2785,7 +2812,7 @@ cvCompareHist( const CvHistogram* hist1,
|
||||
CvSparseMatIterator iterator;
|
||||
CvSparseNode *node1, *node2;
|
||||
|
||||
if( mat1->heap->active_count > mat2->heap->active_count && method != CV_COMP_CHISQR && method != CV_COMP_CHISQR_ALT)
|
||||
if( mat1->heap->active_count > mat2->heap->active_count && method != CV_COMP_CHISQR && method != CV_COMP_CHISQR_ALT && method != CV_COMP_KL_DIV )
|
||||
{
|
||||
CvSparseMat* t;
|
||||
CV_SWAP( mat1, mat2, t );
|
||||
@@ -2887,6 +2914,13 @@ cvCompareHist( const CvHistogram* hist1,
|
||||
result = 1. - result*s1;
|
||||
result = sqrt(MAX(result,0.));
|
||||
}
|
||||
else if( method == CV_COMP_KL_DIV )
|
||||
{
|
||||
cv::SparseMat sH1, sH2;
|
||||
((const CvSparseMat*)hist1->bins)->copyToSparseMat(sH1);
|
||||
((const CvSparseMat*)hist2->bins)->copyToSparseMat(sH2);
|
||||
result = cv::compareHist( sH1, sH2, CV_COMP_KL_DIV );
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadArg, "Unknown comparison method" );
|
||||
|
||||
|
||||
@@ -3582,7 +3582,9 @@ private:
|
||||
static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, InputArray _map2,
|
||||
int interpolation, int borderType, const Scalar& borderValue)
|
||||
{
|
||||
int cn = _src.channels(), type = _src.type(), depth = _src.depth();
|
||||
const ocl::Device & dev = ocl::Device::getDefault();
|
||||
int cn = _src.channels(), type = _src.type(), depth = _src.depth(),
|
||||
rowsPerWI = dev.isIntel() ? 4 : 1;
|
||||
|
||||
if (borderType == BORDER_TRANSPARENT || !(interpolation == INTER_LINEAR || interpolation == INTER_NEAREST)
|
||||
|| _map1.type() == CV_16SC1 || _map2.type() == CV_16SC1)
|
||||
@@ -3619,12 +3621,14 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input
|
||||
static const char * const interMap[] = { "INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LINEAR", "INTER_LANCZOS" };
|
||||
static const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP",
|
||||
"BORDER_REFLECT_101", "BORDER_TRANSPARENT" };
|
||||
String buildOptions = format("-D %s -D %s -D T=%s", interMap[interpolation], borderMap[borderType], ocl::typeToStr(type));
|
||||
String buildOptions = format("-D %s -D %s -D T=%s -D rowsPerWI=%d",
|
||||
interMap[interpolation], borderMap[borderType],
|
||||
ocl::typeToStr(type), rowsPerWI);
|
||||
|
||||
if (interpolation != INTER_NEAREST)
|
||||
{
|
||||
char cvt[3][40];
|
||||
int wdepth = std::max(CV_32F, dst.depth());
|
||||
int wdepth = std::max(CV_32F, depth);
|
||||
buildOptions = buildOptions
|
||||
+ format(" -D WT=%s -D convertToT=%s -D convertToWT=%s"
|
||||
" -D convertToWT2=%s -D WT2=%s",
|
||||
@@ -3636,10 +3640,9 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input
|
||||
}
|
||||
int scalarcn = cn == 3 ? 4 : cn;
|
||||
int sctype = CV_MAKETYPE(depth, scalarcn);
|
||||
buildOptions += format(" -D T=%s -D T1=%s"
|
||||
" -D cn=%d -D ST=%s",
|
||||
buildOptions += format(" -D T=%s -D T1=%s -D cn=%d -D ST=%s -D depth=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
cn, ocl::typeToStr(sctype));
|
||||
cn, ocl::typeToStr(sctype), depth);
|
||||
|
||||
ocl::Kernel k(kernelName.c_str(), ocl::imgproc::remap_oclsrc, buildOptions);
|
||||
|
||||
@@ -3653,7 +3656,7 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input
|
||||
else
|
||||
k.args(srcarg, dstarg, map1arg, ocl::KernelArg::ReadOnlyNoSize(map2), scalararg);
|
||||
|
||||
size_t globalThreads[2] = { dst.cols, dst.rows };
|
||||
size_t globalThreads[2] = { dst.cols, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalThreads, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,128 @@ static Moments contourMoments( const Mat& contour )
|
||||
* Spatial Raster Moments *
|
||||
\****************************************************************************************/
|
||||
|
||||
template<typename T, typename WT, typename MT>
|
||||
struct MomentsInTile_SSE
|
||||
{
|
||||
int operator() (const T *, int, WT &, WT &, WT &, MT &)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if CV_SSE2
|
||||
|
||||
template <>
|
||||
struct MomentsInTile_SSE<uchar, int, int>
|
||||
{
|
||||
MomentsInTile_SSE()
|
||||
{
|
||||
useSIMD = checkHardwareSupport(CV_CPU_SSE2);
|
||||
}
|
||||
|
||||
int operator() (const uchar * ptr, int len, int & x0, int & x1, int & x2, int & x3)
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if( useSIMD )
|
||||
{
|
||||
__m128i qx_init = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
__m128i dx = _mm_set1_epi16(8);
|
||||
__m128i z = _mm_setzero_si128(), qx0 = z, qx1 = z, qx2 = z, qx3 = z, qx = qx_init;
|
||||
|
||||
for( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128i p = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(ptr + x)), z);
|
||||
qx0 = _mm_add_epi32(qx0, _mm_sad_epu8(p, z));
|
||||
__m128i px = _mm_mullo_epi16(p, qx);
|
||||
__m128i sx = _mm_mullo_epi16(qx, qx);
|
||||
qx1 = _mm_add_epi32(qx1, _mm_madd_epi16(p, qx));
|
||||
qx2 = _mm_add_epi32(qx2, _mm_madd_epi16(p, sx));
|
||||
qx3 = _mm_add_epi32(qx3, _mm_madd_epi16(px, sx));
|
||||
|
||||
qx = _mm_add_epi16(qx, dx);
|
||||
}
|
||||
|
||||
int CV_DECL_ALIGNED(16) buf[4];
|
||||
_mm_store_si128((__m128i*)buf, qx0);
|
||||
x0 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx1);
|
||||
x1 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx2);
|
||||
x2 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx3);
|
||||
x3 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
bool useSIMD;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if CV_SSE4_1
|
||||
|
||||
template <>
|
||||
struct MomentsInTile_SSE<ushort, int, int64>
|
||||
{
|
||||
MomentsInTile_SSE()
|
||||
{
|
||||
useSIMD = checkHardwareSupport(CV_CPU_SSE4_1);
|
||||
}
|
||||
|
||||
int operator() (const ushort * ptr, int len, int & x0, int & x1, int & x2, int64 & x3)
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (useSIMD)
|
||||
{
|
||||
__m128i vx_init0 = _mm_setr_epi32(0, 1, 2, 3), vx_init1 = _mm_setr_epi32(4, 5, 6, 7),
|
||||
v_delta = _mm_set1_epi32(8), v_zero = _mm_setzero_si128(), v_x0 = v_zero,
|
||||
v_x1 = v_zero, v_x2 = v_zero, v_x3 = v_zero, v_ix0 = vx_init0, v_ix1 = vx_init1;
|
||||
|
||||
for( ; x <= len - 8; x += 8 )
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((const __m128i *)(ptr + x));
|
||||
__m128i v_src0 = _mm_unpacklo_epi16(v_src, v_zero), v_src1 = _mm_unpackhi_epi16(v_src, v_zero);
|
||||
|
||||
v_x0 = _mm_add_epi32(v_x0, _mm_add_epi32(v_src0, v_src1));
|
||||
__m128i v_x1_0 = _mm_mullo_epi32(v_src0, v_ix0), v_x1_1 = _mm_mullo_epi32(v_src1, v_ix1);
|
||||
v_x1 = _mm_add_epi32(v_x1, _mm_add_epi32(v_x1_0, v_x1_1));
|
||||
|
||||
__m128i v_2ix0 = _mm_mullo_epi32(v_ix0, v_ix0), v_2ix1 = _mm_mullo_epi32(v_ix1, v_ix1);
|
||||
v_x2 = _mm_add_epi32(v_x2, _mm_add_epi32(_mm_mullo_epi32(v_2ix0, v_src0), _mm_mullo_epi32(v_2ix1, v_src1)));
|
||||
|
||||
__m128i t = _mm_add_epi32(_mm_mullo_epi32(v_2ix0, v_x1_0), _mm_mullo_epi32(v_2ix1, v_x1_1));
|
||||
v_x3 = _mm_add_epi64(v_x3, _mm_add_epi64(_mm_unpacklo_epi32(t, v_zero), _mm_unpackhi_epi32(t, v_zero)));
|
||||
|
||||
v_ix0 = _mm_add_epi32(v_ix0, v_delta);
|
||||
v_ix1 = _mm_add_epi32(v_ix1, v_delta);
|
||||
}
|
||||
|
||||
int CV_DECL_ALIGNED(16) buf[4];
|
||||
int64 CV_DECL_ALIGNED(16) buf64[2];
|
||||
|
||||
_mm_store_si128((__m128i*)buf, v_x0);
|
||||
x0 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, v_x1);
|
||||
x1 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, v_x2);
|
||||
x2 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
|
||||
_mm_store_si128((__m128i*)buf64, v_x3);
|
||||
x3 = buf64[0] + buf64[1];
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
bool useSIMD;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<typename T, typename WT, typename MT>
|
||||
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 9
|
||||
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60196
|
||||
@@ -212,14 +334,16 @@ static void momentsInTile( const Mat& img, double* moments )
|
||||
Size size = img.size();
|
||||
int x, y;
|
||||
MT mom[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
MomentsInTile_SSE<T, WT, MT> vop;
|
||||
|
||||
for( y = 0; y < size.height; y++ )
|
||||
{
|
||||
const T* ptr = (const T*)(img.data + y*img.step);
|
||||
WT x0 = 0, x1 = 0, x2 = 0;
|
||||
MT x3 = 0;
|
||||
x = vop(ptr, size.width, x0, x1, x2, x3);
|
||||
|
||||
for( x = 0; x < size.width; x++ )
|
||||
for( ; x < size.width; x++ )
|
||||
{
|
||||
WT p = ptr[x];
|
||||
WT xp = x * p, xxp;
|
||||
@@ -249,85 +373,6 @@ static void momentsInTile( const Mat& img, double* moments )
|
||||
moments[x] = (double)mom[x];
|
||||
}
|
||||
|
||||
|
||||
#if CV_SSE2
|
||||
|
||||
template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* moments )
|
||||
{
|
||||
typedef uchar T;
|
||||
typedef int WT;
|
||||
typedef int MT;
|
||||
Size size = img.size();
|
||||
int y;
|
||||
MT mom[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
bool useSIMD = checkHardwareSupport(CV_CPU_SSE2);
|
||||
|
||||
for( y = 0; y < size.height; y++ )
|
||||
{
|
||||
const T* ptr = img.ptr<T>(y);
|
||||
int x0 = 0, x1 = 0, x2 = 0, x3 = 0, x = 0;
|
||||
|
||||
if( useSIMD )
|
||||
{
|
||||
__m128i qx_init = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
__m128i dx = _mm_set1_epi16(8);
|
||||
__m128i z = _mm_setzero_si128(), qx0 = z, qx1 = z, qx2 = z, qx3 = z, qx = qx_init;
|
||||
|
||||
for( ; x <= size.width - 8; x += 8 )
|
||||
{
|
||||
__m128i p = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(ptr + x)), z);
|
||||
qx0 = _mm_add_epi32(qx0, _mm_sad_epu8(p, z));
|
||||
__m128i px = _mm_mullo_epi16(p, qx);
|
||||
__m128i sx = _mm_mullo_epi16(qx, qx);
|
||||
qx1 = _mm_add_epi32(qx1, _mm_madd_epi16(p, qx));
|
||||
qx2 = _mm_add_epi32(qx2, _mm_madd_epi16(p, sx));
|
||||
qx3 = _mm_add_epi32(qx3, _mm_madd_epi16(px, sx));
|
||||
|
||||
qx = _mm_add_epi16(qx, dx);
|
||||
}
|
||||
int CV_DECL_ALIGNED(16) buf[4];
|
||||
_mm_store_si128((__m128i*)buf, qx0);
|
||||
x0 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx1);
|
||||
x1 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx2);
|
||||
x2 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
_mm_store_si128((__m128i*)buf, qx3);
|
||||
x3 = buf[0] + buf[1] + buf[2] + buf[3];
|
||||
}
|
||||
|
||||
for( ; x < size.width; x++ )
|
||||
{
|
||||
WT p = ptr[x];
|
||||
WT xp = x * p, xxp;
|
||||
|
||||
x0 += p;
|
||||
x1 += xp;
|
||||
xxp = xp * x;
|
||||
x2 += xxp;
|
||||
x3 += xxp * x;
|
||||
}
|
||||
|
||||
WT py = y * x0, sy = y*y;
|
||||
|
||||
mom[9] += ((MT)py) * sy; // m03
|
||||
mom[8] += ((MT)x1) * sy; // m12
|
||||
mom[7] += ((MT)x2) * y; // m21
|
||||
mom[6] += x3; // m30
|
||||
mom[5] += x0 * sy; // m02
|
||||
mom[4] += x1 * y; // m11
|
||||
mom[3] += x2; // m20
|
||||
mom[2] += py; // m01
|
||||
mom[1] += x1; // m10
|
||||
mom[0] += x0; // m00
|
||||
}
|
||||
|
||||
for(int x = 0; x < 10; x++ )
|
||||
moments[x] = (double)mom[x];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
typedef void (*MomentsInTileFunc)(const Mat& img, double* moments);
|
||||
|
||||
Moments::Moments()
|
||||
|
||||
@@ -1257,7 +1257,7 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
||||
}
|
||||
#undef IPP_MORPH_CASE
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 8
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 8
|
||||
return false; /// It disables false positive warning in GCC 4.8 and further
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -114,25 +114,23 @@ __kernel void corner(__global const float * Dx, int dx_step, int dx_offset, int
|
||||
int dst_startX = gX * (THREADS-ksX+1) + dst_x_off;
|
||||
int dst_startY = (gY << 1) + dst_y_off;
|
||||
|
||||
float dx_data[ksY+1],dy_data[ksY+1], data[3][ksY+1];
|
||||
float data[3][ksY+1];
|
||||
__local float temp[6][THREADS];
|
||||
|
||||
#ifdef BORDER_CONSTANT
|
||||
for (int i=0; i < ksY+1; i++)
|
||||
{
|
||||
bool dx_con = dx_startX+col >= 0 && dx_startX+col < dx_whole_cols && dx_startY+i >= 0 && dx_startY+i < dx_whole_rows;
|
||||
int indexDx = (dx_startY+i)*(dx_step>>2)+(dx_startX+col);
|
||||
int indexDx = mad24(dx_startY+i, dx_step>>2, dx_startX+col);
|
||||
float dx_s = dx_con ? Dx[indexDx] : 0.0f;
|
||||
dx_data[i] = dx_s;
|
||||
|
||||
bool dy_con = dy_startX+col >= 0 && dy_startX+col < dy_whole_cols && dy_startY+i >= 0 && dy_startY+i < dy_whole_rows;
|
||||
int indexDy = (dy_startY+i)*(dy_step>>2)+(dy_startX+col);
|
||||
int indexDy = mad24(dy_startY+i, dy_step>>2, dy_startX+col);
|
||||
float dy_s = dy_con ? Dy[indexDy] : 0.0f;
|
||||
dy_data[i] = dy_s;
|
||||
|
||||
data[0][i] = dx_data[i] * dx_data[i];
|
||||
data[1][i] = dx_data[i] * dy_data[i];
|
||||
data[2][i] = dy_data[i] * dy_data[i];
|
||||
data[0][i] = dx_s * dx_s;
|
||||
data[1][i] = dx_s * dy_s;
|
||||
data[2][i] = dy_s * dy_s;
|
||||
}
|
||||
#else
|
||||
int clamped_col = min(2*dst_cols, col);
|
||||
@@ -141,16 +139,16 @@ __kernel void corner(__global const float * Dx, int dx_step, int dx_offset, int
|
||||
int dx_selected_row = dx_startY+i, dx_selected_col = dx_startX+clamped_col;
|
||||
EXTRAPOLATE(dx_selected_row, dx_whole_rows)
|
||||
EXTRAPOLATE(dx_selected_col, dx_whole_cols)
|
||||
dx_data[i] = Dx[dx_selected_row * (dx_step>>2) + dx_selected_col];
|
||||
float dx_s = Dx[mad24(dx_selected_row, dx_step>>2, dx_selected_col)];
|
||||
|
||||
int dy_selected_row = dy_startY+i, dy_selected_col = dy_startX+clamped_col;
|
||||
EXTRAPOLATE(dy_selected_row, dy_whole_rows)
|
||||
EXTRAPOLATE(dy_selected_col, dy_whole_cols)
|
||||
dy_data[i] = Dy[dy_selected_row * (dy_step>>2) + dy_selected_col];
|
||||
float dy_s = Dy[mad24(dy_selected_row, dy_step>>2, dy_selected_col)];
|
||||
|
||||
data[0][i] = dx_data[i] * dx_data[i];
|
||||
data[1][i] = dx_data[i] * dy_data[i];
|
||||
data[2][i] = dy_data[i] * dy_data[i];
|
||||
data[0][i] = dx_s * dx_s;
|
||||
data[1][i] = dx_s * dy_s;
|
||||
data[2][i] = dy_s * dy_s;
|
||||
}
|
||||
#endif
|
||||
float sum0 = 0.0f, sum1 = 0.0f, sum2 = 0.0f;
|
||||
@@ -180,7 +178,7 @@ __kernel void corner(__global const float * Dx, int dx_step, int dx_offset, int
|
||||
col += anX;
|
||||
int posX = dst_startX - dst_x_off + col - anX;
|
||||
int posY = (gly << 1);
|
||||
int till = (ksX + 1)%2;
|
||||
int till = (ksX + 1) & 1;
|
||||
float tmp_sum[6] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
for (int k=0; k<6; k++)
|
||||
{
|
||||
@@ -210,7 +208,7 @@ __kernel void corner(__global const float * Dx, int dx_step, int dx_offset, int
|
||||
float a = tmp_sum[0] * 0.5f;
|
||||
float b = tmp_sum[2];
|
||||
float c = tmp_sum[4] * 0.5f;
|
||||
*(__global float *)(dst + dst_index) = (float)((a+c) - sqrt((a-c)*(a-c) + b*b));
|
||||
*(__global float *)(dst + dst_index) = (float)((a+c) - native_sqrt((a-c)*(a-c) + b*b));
|
||||
}
|
||||
if (posX < dst_cols && (posY + 1) < dst_rows)
|
||||
{
|
||||
@@ -218,7 +216,7 @@ __kernel void corner(__global const float * Dx, int dx_step, int dx_offset, int
|
||||
float a = tmp_sum[1] * 0.5f;
|
||||
float b = tmp_sum[3];
|
||||
float c = tmp_sum[5] * 0.5f;
|
||||
*(__global float *)(dst + dst_index) = (float)((a+c) - sqrt((a-c)*(a-c) + b*b));
|
||||
*(__global float *)(dst + dst_index) = (float)((a+c) - native_sqrt((a-c)*(a-c) + b*b));
|
||||
}
|
||||
#else
|
||||
#error "No such corners type"
|
||||
|
||||
@@ -79,12 +79,22 @@
|
||||
|
||||
#define SRC(_x,_y) convertToFT(loadpix(srcData + mad24(_y, src_step, PIXSIZE * _x)))
|
||||
|
||||
#if kercn == 4
|
||||
#define SRC4(_x,_y) convert_float4(vload4(0, srcData + mad24(_y, src_step, PIXSIZE * _x)))
|
||||
#endif
|
||||
|
||||
#ifdef INTEL_DEVICE
|
||||
#define MAD(x,y,z) fma((x),(y),(z))
|
||||
#else
|
||||
#define MAD(x,y,z) mad((x),(y),(z))
|
||||
#endif
|
||||
|
||||
#define noconvert
|
||||
|
||||
__kernel void pyrDown(__global const uchar * src, int src_step, int src_offset, int src_rows, int src_cols,
|
||||
__global uchar * dst, int dst_step, int dst_offset, int dst_rows, int dst_cols)
|
||||
{
|
||||
const int x = get_global_id(0);
|
||||
const int x = get_global_id(0)*kercn;
|
||||
const int y = get_group_id(1);
|
||||
|
||||
__local FT smem[LOCAL_SIZE + 4];
|
||||
@@ -97,98 +107,190 @@ __kernel void pyrDown(__global const uchar * src, int src_step, int src_offset,
|
||||
FT co3 = 0.0625f;
|
||||
|
||||
const int src_y = 2*y;
|
||||
int col;
|
||||
|
||||
if (src_y >= 2 && src_y < src_rows - 2 && x >= 2 && x < src_cols - 2)
|
||||
if (src_y >= 2 && src_y < src_rows - 2)
|
||||
{
|
||||
sum = co3 * SRC(x, src_y - 2);
|
||||
sum = sum + co2 * SRC(x, src_y - 1);
|
||||
sum = sum + co1 * SRC(x, src_y );
|
||||
sum = sum + co2 * SRC(x, src_y + 1);
|
||||
sum = sum + co3 * SRC(x, src_y + 2);
|
||||
#if kercn == 1
|
||||
col = EXTRAPOLATE(x, src_cols);
|
||||
|
||||
sum = co3* SRC(col, src_y - 2);
|
||||
sum = MAD(co2, SRC(col, src_y - 1), sum);
|
||||
sum = MAD(co1, SRC(col, src_y ), sum);
|
||||
sum = MAD(co2, SRC(col, src_y + 1), sum);
|
||||
sum = MAD(co3, SRC(col, src_y + 2), sum);
|
||||
|
||||
smem[2 + get_local_id(0)] = sum;
|
||||
#else
|
||||
if (x < src_cols-4)
|
||||
{
|
||||
float4 sum4;
|
||||
sum4 = co3* SRC4(x, src_y - 2);
|
||||
sum4 = MAD(co2, SRC4(x, src_y - 1), sum4);
|
||||
sum4 = MAD(co1, SRC4(x, src_y ), sum4);
|
||||
sum4 = MAD(co2, SRC4(x, src_y + 1), sum4);
|
||||
sum4 = MAD(co3, SRC4(x, src_y + 2), sum4);
|
||||
|
||||
vstore4(sum4, get_local_id(0), (__local float*) &smem[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
col = EXTRAPOLATE(x+i, src_cols);
|
||||
sum = co3* SRC(col, src_y - 2);
|
||||
sum = MAD(co2, SRC(col, src_y - 1), sum);
|
||||
sum = MAD(co1, SRC(col, src_y ), sum);
|
||||
sum = MAD(co2, SRC(col, src_y + 1), sum);
|
||||
sum = MAD(co3, SRC(col, src_y + 2), sum);
|
||||
|
||||
smem[2 + 4*get_local_id(0)+i] = sum;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (get_local_id(0) < 2)
|
||||
{
|
||||
const int left_x = x - 2;
|
||||
col = EXTRAPOLATE((int)(get_group_id(0)*LOCAL_SIZE + get_local_id(0) - 2), src_cols);
|
||||
|
||||
sum = co3 * SRC(left_x, src_y - 2);
|
||||
sum = sum + co2 * SRC(left_x, src_y - 1);
|
||||
sum = sum + co1 * SRC(left_x, src_y );
|
||||
sum = sum + co2 * SRC(left_x, src_y + 1);
|
||||
sum = sum + co3 * SRC(left_x, src_y + 2);
|
||||
sum = co3* SRC(col, src_y - 2);
|
||||
sum = MAD(co2, SRC(col, src_y - 1), sum);
|
||||
sum = MAD(co1, SRC(col, src_y ), sum);
|
||||
sum = MAD(co2, SRC(col, src_y + 1), sum);
|
||||
sum = MAD(co3, SRC(col, src_y + 2), sum);
|
||||
|
||||
smem[get_local_id(0)] = sum;
|
||||
}
|
||||
|
||||
if (get_local_id(0) > LOCAL_SIZE - 3)
|
||||
if (get_local_id(0) > 1 && get_local_id(0) < 4)
|
||||
{
|
||||
const int right_x = x + 2;
|
||||
col = EXTRAPOLATE((int)((get_group_id(0)+1)*LOCAL_SIZE + get_local_id(0) - 2), src_cols);
|
||||
|
||||
sum = co3 * SRC(right_x, src_y - 2);
|
||||
sum = sum + co2 * SRC(right_x, src_y - 1);
|
||||
sum = sum + co1 * SRC(right_x, src_y );
|
||||
sum = sum + co2 * SRC(right_x, src_y + 1);
|
||||
sum = sum + co3 * SRC(right_x, src_y + 2);
|
||||
sum = co3* SRC(col, src_y - 2);
|
||||
sum = MAD(co2, SRC(col, src_y - 1), sum);
|
||||
sum = MAD(co1, SRC(col, src_y ), sum);
|
||||
sum = MAD(co2, SRC(col, src_y + 1), sum);
|
||||
sum = MAD(co3, SRC(col, src_y + 2), sum);
|
||||
|
||||
smem[4 + get_local_id(0)] = sum;
|
||||
smem[LOCAL_SIZE + get_local_id(0)] = sum;
|
||||
}
|
||||
}
|
||||
else
|
||||
else // need extrapolate y
|
||||
{
|
||||
int col = EXTRAPOLATE(x, src_cols);
|
||||
#if kercn == 1
|
||||
col = EXTRAPOLATE(x, src_cols);
|
||||
|
||||
sum = co3 * SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y - 1, src_rows));
|
||||
sum = sum + co1 * SRC(col, EXTRAPOLATE(src_y , src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y + 1, src_rows));
|
||||
sum = sum + co3 * SRC(col, EXTRAPOLATE(src_y + 2, src_rows));
|
||||
sum = co3* SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y - 1, src_rows)), sum);
|
||||
sum = MAD(co1, SRC(col, EXTRAPOLATE(src_y , src_rows)), sum);
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y + 1, src_rows)), sum);
|
||||
sum = MAD(co3, SRC(col, EXTRAPOLATE(src_y + 2, src_rows)), sum);
|
||||
|
||||
smem[2 + get_local_id(0)] = sum;
|
||||
#else
|
||||
if (x < src_cols-4)
|
||||
{
|
||||
float4 sum4;
|
||||
sum4 = co3* SRC4(x, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum4 = MAD(co2, SRC4(x, EXTRAPOLATE(src_y - 1, src_rows)), sum4);
|
||||
sum4 = MAD(co1, SRC4(x, EXTRAPOLATE(src_y , src_rows)), sum4);
|
||||
sum4 = MAD(co2, SRC4(x, EXTRAPOLATE(src_y + 1, src_rows)), sum4);
|
||||
sum4 = MAD(co3, SRC4(x, EXTRAPOLATE(src_y + 2, src_rows)), sum4);
|
||||
|
||||
vstore4(sum4, get_local_id(0), (__local float*) &smem[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
col = EXTRAPOLATE(x+i, src_cols);
|
||||
sum = co3* SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y - 1, src_rows)), sum);
|
||||
sum = MAD(co1, SRC(col, EXTRAPOLATE(src_y , src_rows)), sum);
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y + 1, src_rows)), sum);
|
||||
sum = MAD(co3, SRC(col, EXTRAPOLATE(src_y + 2, src_rows)), sum);
|
||||
|
||||
smem[2 + 4*get_local_id(0)+i] = sum;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (get_local_id(0) < 2)
|
||||
{
|
||||
col = EXTRAPOLATE(x - 2, src_cols);
|
||||
col = EXTRAPOLATE((int)(get_group_id(0)*LOCAL_SIZE + get_local_id(0) - 2), src_cols);
|
||||
|
||||
sum = co3 * SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y - 1, src_rows));
|
||||
sum = sum + co1 * SRC(col, EXTRAPOLATE(src_y , src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y + 1, src_rows));
|
||||
sum = sum + co3 * SRC(col, EXTRAPOLATE(src_y + 2, src_rows));
|
||||
sum = co3* SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y - 1, src_rows)), sum);
|
||||
sum = MAD(co1, SRC(col, EXTRAPOLATE(src_y , src_rows)), sum);
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y + 1, src_rows)), sum);
|
||||
sum = MAD(co3, SRC(col, EXTRAPOLATE(src_y + 2, src_rows)), sum);
|
||||
|
||||
smem[get_local_id(0)] = sum;
|
||||
}
|
||||
|
||||
if (get_local_id(0) > LOCAL_SIZE - 3)
|
||||
if (get_local_id(0) > 1 && get_local_id(0) < 4)
|
||||
{
|
||||
col = EXTRAPOLATE(x + 2, src_cols);
|
||||
col = EXTRAPOLATE((int)((get_group_id(0)+1)*LOCAL_SIZE + get_local_id(0) - 2), src_cols);
|
||||
|
||||
sum = co3 * SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y - 1, src_rows));
|
||||
sum = sum + co1 * SRC(col, EXTRAPOLATE(src_y , src_rows));
|
||||
sum = sum + co2 * SRC(col, EXTRAPOLATE(src_y + 1, src_rows));
|
||||
sum = sum + co3 * SRC(col, EXTRAPOLATE(src_y + 2, src_rows));
|
||||
sum = co3* SRC(col, EXTRAPOLATE(src_y - 2, src_rows));
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y - 1, src_rows)), sum);
|
||||
sum = MAD(co1, SRC(col, EXTRAPOLATE(src_y , src_rows)), sum);
|
||||
sum = MAD(co2, SRC(col, EXTRAPOLATE(src_y + 1, src_rows)), sum);
|
||||
sum = MAD(co3, SRC(col, EXTRAPOLATE(src_y + 2, src_rows)), sum);
|
||||
|
||||
smem[4 + get_local_id(0)] = sum;
|
||||
smem[LOCAL_SIZE + get_local_id(0)] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
#if kercn == 1
|
||||
if (get_local_id(0) < LOCAL_SIZE / 2)
|
||||
{
|
||||
const int tid2 = get_local_id(0) * 2;
|
||||
|
||||
sum = co3 * smem[2 + tid2 - 2];
|
||||
sum = sum + co2 * smem[2 + tid2 - 1];
|
||||
sum = sum + co1 * smem[2 + tid2 ];
|
||||
sum = sum + co2 * smem[2 + tid2 + 1];
|
||||
sum = sum + co3 * smem[2 + tid2 + 2];
|
||||
sum = 0.f;
|
||||
#if cn == 1
|
||||
#if fdepth <= 5
|
||||
sum = sum + dot(vload4(0, (__local float*) (&smem)+tid2), (float4)(co3, co2, co1, co2));
|
||||
#else
|
||||
sum = sum + dot(vload4(0, (__local double*) (&smem)+tid2), (double4)(co3, co2, co1, co2));
|
||||
#endif
|
||||
#else
|
||||
sum = MAD(co3, smem[2 + tid2 - 2], sum);
|
||||
sum = MAD(co2, smem[2 + tid2 - 1], sum);
|
||||
sum = MAD(co1, smem[2 + tid2 ], sum);
|
||||
sum = MAD(co2, smem[2 + tid2 + 1], sum);
|
||||
#endif
|
||||
sum = MAD(co3, smem[2 + tid2 + 2], sum);
|
||||
|
||||
const int dst_x = (get_group_id(0) * get_local_size(0) + tid2) / 2;
|
||||
|
||||
if (dst_x < dst_cols)
|
||||
storepix(convertToT(sum), dstData + y * dst_step + dst_x * PIXSIZE);
|
||||
}
|
||||
#else
|
||||
int tid4 = get_local_id(0) * 4;
|
||||
|
||||
sum = co3* smem[2 + tid4 + 2];
|
||||
sum = MAD(co3, smem[2 + tid4 - 2], sum);
|
||||
sum = MAD(co2, smem[2 + tid4 - 1], sum);
|
||||
sum = MAD(co1, smem[2 + tid4 ], sum);
|
||||
sum = MAD(co2, smem[2 + tid4 + 1], sum);
|
||||
|
||||
int dst_x = (get_group_id(0) * LOCAL_SIZE + tid4) / 2;
|
||||
|
||||
if (dst_x < dst_cols)
|
||||
storepix(convertToT(sum), dstData + mad24(y, dst_step, dst_x * PIXSIZE));
|
||||
|
||||
tid4 += 2;
|
||||
dst_x += 1;
|
||||
|
||||
sum = co3* smem[2 + tid4 + 2];
|
||||
sum = MAD(co3, smem[2 + tid4 - 2], sum);
|
||||
sum = MAD(co2, smem[2 + tid4 - 1], sum);
|
||||
sum = MAD(co1, smem[2 + tid4 ], sum);
|
||||
sum = MAD(co2, smem[2 + tid4 + 1], sum);
|
||||
|
||||
if (dst_x < dst_cols)
|
||||
storepix(convertToT(sum), dstData + mad24(y, dst_step, dst_x * PIXSIZE));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -147,37 +147,43 @@ __kernel void remap_2_32FC1(__global const uchar * srcptr, int src_step, int src
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
T scalar = convertScalar(nVal);
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int map1_index = mad24(y, map1_step, x * (int)sizeof(float) + map1_offset);
|
||||
int map2_index = mad24(y, map2_step, x * (int)sizeof(float) + map2_offset);
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
T scalar = convertScalar(nVal);
|
||||
|
||||
__global const float * map1 = (__global const float *)(map1ptr + map1_index);
|
||||
__global const float * map2 = (__global const float *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
int map1_index = mad24(y, map1_step, mad24(x, (int)sizeof(float), map1_offset));
|
||||
int map2_index = mad24(y, map2_step, mad24(x, (int)sizeof(float), map2_offset));
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
|
||||
int gx = convert_int_sat_rte(map1[0]);
|
||||
int gy = convert_int_sat_rte(map2[0]);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map1_index += map1_step, map2_index += map2_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const float * map1 = (__global const float *)(map1ptr + map1_index);
|
||||
__global const float * map2 = (__global const float *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
int gx = convert_int_sat_rte(map1[0]);
|
||||
int gy = convert_int_sat_rte(map2[0]);
|
||||
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
#ifndef BORDER_CONSTANT
|
||||
int2 gxy = (int2)(gx, gy);
|
||||
int2 gxy = (int2)(gx, gy);
|
||||
#endif
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, gx * TSIZE + src_offset);
|
||||
storepix(loadpix((__global const T*)(srcptr + src_index)), dst);
|
||||
}
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, mad24(gx, TSIZE, src_offset));
|
||||
storepix(loadpix((__global const T*)(srcptr + src_index)), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,31 +193,36 @@ __kernel void remap_32FC2(__global const uchar * srcptr, int src_step, int src_o
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
T scalar = convertScalar(nVal);
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map_index = mad24(y, map_step, x * (int)sizeof(float2) + map_offset);
|
||||
T scalar = convertScalar(nVal);
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map_index = mad24(y, map_step, mad24(x, (int)sizeof(float2), map_offset));
|
||||
|
||||
__global const float2 * map = (__global const float2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map_index += map_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const float2 * map = (__global const float2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
int2 gxy = convert_int2_sat_rte(map[0]);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
int2 gxy = convert_int2_sat_rte(map[0]);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, gx * TSIZE + src_offset);
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, mad24(gx, TSIZE, src_offset));
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,32 +233,37 @@ __kernel void remap_16SC2(__global const uchar * srcptr, int src_step, int src_o
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
T scalar = convertScalar(nVal);
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map_index = mad24(y, map_step, x * (int)sizeof(short2) + map_offset);
|
||||
T scalar = convertScalar(nVal);
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map_index = mad24(y, map_step, mad24(x, (int)sizeof(short2), map_offset));
|
||||
|
||||
__global const short2 * map = (__global const short2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map_index += map_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const short2 * map = (__global const short2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
int2 gxy = convert_int2(map[0]);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
int2 gxy = convert_int2(map[0]);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, gx * TSIZE + src_offset);
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
}
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, mad24(gx, TSIZE, src_offset));
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,41 +274,54 @@ __kernel void remap_16SC2_16UC1(__global const uchar * srcptr, int src_step, int
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
T scalar = convertScalar(nVal);
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map1_index = mad24(y, map1_step, x * (int)sizeof(short2) + map1_offset);
|
||||
int map2_index = mad24(y, map2_step, x * (int)sizeof(ushort) + map2_offset);
|
||||
T scalar = convertScalar(nVal);
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map1_index = mad24(y, map1_step, mad24(x, (int)sizeof(short2), map1_offset));
|
||||
int map2_index = mad24(y, map2_step, mad24(x, (int)sizeof(ushort), map2_offset));
|
||||
|
||||
__global const short2 * map1 = (__global const short2 *)(map1ptr + map1_index);
|
||||
__global const ushort * map2 = (__global const ushort *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map1_index += map1_step, map2_index += map2_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const short2 * map1 = (__global const short2 *)(map1ptr + map1_index);
|
||||
__global const ushort * map2 = (__global const ushort *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
int map2Value = convert_int(map2[0]) & (INTER_TAB_SIZE2 - 1);
|
||||
int dx = (map2Value & (INTER_TAB_SIZE - 1)) < (INTER_TAB_SIZE >> 1) ? 1 : 0;
|
||||
int dy = (map2Value >> INTER_BITS) < (INTER_TAB_SIZE >> 1) ? 1 : 0;
|
||||
int2 gxy = convert_int2(map1[0]) + (int2)(dx, dy);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
int map2Value = convert_int(map2[0]) & (INTER_TAB_SIZE2 - 1);
|
||||
int dx = (map2Value & (INTER_TAB_SIZE - 1)) < (INTER_TAB_SIZE >> 1) ? 1 : 0;
|
||||
int dy = (map2Value >> INTER_BITS) < (INTER_TAB_SIZE >> 1) ? 1 : 0;
|
||||
int2 gxy = convert_int2(map1[0]) + (int2)(dx, dy);
|
||||
int gx = gxy.x, gy = gxy.y;
|
||||
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, gx * TSIZE + src_offset);
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
}
|
||||
if (NEED_EXTRAPOLATION(gx, gy))
|
||||
{
|
||||
T v;
|
||||
EXTRAPOLATE(gxy, v)
|
||||
storepix(v, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
int src_index = mad24(gy, src_step, mad24(gx, TSIZE, src_offset));
|
||||
storepix(loadpix((__global const T *)(srcptr + src_index)), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif INTER_LINEAR
|
||||
#elif defined INTER_LINEAR
|
||||
|
||||
__constant float coeffs[64] =
|
||||
{ 1.000000f, 0.000000f, 0.968750f, 0.031250f, 0.937500f, 0.062500f, 0.906250f, 0.093750f, 0.875000f, 0.125000f, 0.843750f, 0.156250f,
|
||||
0.812500f, 0.187500f, 0.781250f, 0.218750f, 0.750000f, 0.250000f, 0.718750f, 0.281250f, 0.687500f, 0.312500f, 0.656250f, 0.343750f,
|
||||
0.625000f, 0.375000f, 0.593750f, 0.406250f, 0.562500f, 0.437500f, 0.531250f, 0.468750f, 0.500000f, 0.500000f, 0.468750f, 0.531250f,
|
||||
0.437500f, 0.562500f, 0.406250f, 0.593750f, 0.375000f, 0.625000f, 0.343750f, 0.656250f, 0.312500f, 0.687500f, 0.281250f, 0.718750f,
|
||||
0.250000f, 0.750000f, 0.218750f, 0.781250f, 0.187500f, 0.812500f, 0.156250f, 0.843750f, 0.125000f, 0.875000f, 0.093750f, 0.906250f,
|
||||
0.062500f, 0.937500f, 0.031250f, 0.968750f };
|
||||
|
||||
__kernel void remap_16SC2_16UC1(__global const uchar * srcptr, int src_step, int src_offset, int src_rows, int src_cols,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset, int dst_rows, int dst_cols,
|
||||
@@ -301,54 +330,60 @@ __kernel void remap_16SC2_16UC1(__global const uchar * srcptr, int src_step, int
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map1_index = mad24(y, map1_step, x * (int)sizeof(short2) + map1_offset);
|
||||
int map2_index = mad24(y, map2_step, x * (int)sizeof(ushort) + map2_offset);
|
||||
|
||||
__global const short2 * map1 = (__global const short2 *)(map1ptr + map1_index);
|
||||
__global const ushort * map2 = (__global const ushort *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
int2 map_dataA = convert_int2(map1[0]);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
ushort map2Value = (ushort)(map2[0] & (INTER_TAB_SIZE2 - 1));
|
||||
WT2 u = (WT2)(map2Value & (INTER_TAB_SIZE - 1), map2Value >> INTER_BITS) / (WT2)(INTER_TAB_SIZE);
|
||||
|
||||
WT scalar = convertToWT(convertScalar(nVal));
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map1_index = mad24(y, map1_step, mad24(x, (int)sizeof(short2), map1_offset));
|
||||
int map2_index = mad24(y, map2_step, mad24(x, (int)sizeof(ushort), map2_offset));
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map1_index += map1_step, map2_index += map2_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const short2 * map1 = (__global const short2 *)(map1ptr + map1_index);
|
||||
__global const ushort * map2 = (__global const ushort *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
int2 map_dataA = convert_int2(map1[0]);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
ushort map2Value = (ushort)(map2[0] & (INTER_TAB_SIZE2 - 1));
|
||||
WT2 u = (WT2)(map2Value & (INTER_TAB_SIZE - 1), map2Value >> INTER_BITS) / (WT2)(INTER_TAB_SIZE);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,55 +394,106 @@ __kernel void remap_2_32FC1(__global const uchar * srcptr, int src_step, int src
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map1_index = mad24(y, map1_step, x * (int)sizeof(float) + map1_offset);
|
||||
int map2_index = mad24(y, map2_step, x * (int)sizeof(float) + map2_offset);
|
||||
|
||||
__global const float * map1 = (__global const float *)(map1ptr + map1_index);
|
||||
__global const float * map2 = (__global const float *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
float2 map_data = (float2)(map1[0], map2[0]);
|
||||
|
||||
int2 map_dataA = convert_int2_sat_rtn(map_data);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
float2 _u = map_data - convert_float2(map_dataA);
|
||||
WT2 u = convertToWT2(convert_int2_rte(convertToWT2(_u) * (WT2)INTER_TAB_SIZE)) / (WT2)INTER_TAB_SIZE;
|
||||
WT scalar = convertToWT(convertScalar(nVal));
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map1_index = mad24(y, map1_step, mad24(x, (int)sizeof(float), map1_offset));
|
||||
int map2_index = mad24(y, map2_step, mad24(x, (int)sizeof(float), map2_offset));
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map1_index += map1_step, map2_index += map2_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const float * map1 = (__global const float *)(map1ptr + map1_index);
|
||||
__global const float * map2 = (__global const float *)(map2ptr + map2_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
#if defined BORDER_CONSTANT
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
float xf = map1[0], yf = map2[0];
|
||||
int sx = convert_int_sat_rtn(xf), sy = convert_int_sat_rtn(yf);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
__constant float * coeffs_x = coeffs + ((convert_int_rte(xf * INTER_TAB_SIZE) & (INTER_TAB_SIZE - 1)) << 1);
|
||||
__constant float * coeffs_y = coeffs + ((convert_int_rte(yf * INTER_TAB_SIZE) & (INTER_TAB_SIZE - 1)) << 1);
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
WT sum = (WT)(0), xsum;
|
||||
int src_index = mad24(sy, src_step, mad24(sx, TSIZE, src_offset));
|
||||
|
||||
#pragma unroll
|
||||
for (int yp = 0; yp < 2; ++yp, src_index += src_step)
|
||||
{
|
||||
if (sy + yp >= 0 && sy + yp < src_rows)
|
||||
{
|
||||
xsum = (WT)(0);
|
||||
if (sx >= 0 && sx + 2 < src_cols)
|
||||
{
|
||||
#if depth == 0 && cn == 1
|
||||
uchar2 value = vload2(0, srcptr + src_index);
|
||||
xsum = dot(convert_float2(value), (float2)(coeffs_x[0], coeffs_x[1]));
|
||||
#else
|
||||
#pragma unroll
|
||||
for (int xp = 0; xp < 2; ++xp)
|
||||
xsum = fma(convertToWT(loadpix(srcptr + mad24(xp, TSIZE, src_index))), coeffs_x[xp], xsum);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma unroll
|
||||
for (int xp = 0; xp < 2; ++xp)
|
||||
xsum = fma(sx + xp >= 0 && sx + xp < src_cols ?
|
||||
convertToWT(loadpix(srcptr + mad24(xp, TSIZE, src_index))) : scalar, coeffs_x[xp], xsum);
|
||||
}
|
||||
sum = fma(xsum, coeffs_y[yp], sum);
|
||||
}
|
||||
else
|
||||
sum = fma(scalar, coeffs_y[yp], sum);
|
||||
}
|
||||
|
||||
storepix(convertToT(sum), dst);
|
||||
#else
|
||||
float2 map_data = (float2)(map1[0], map2[0]);
|
||||
|
||||
int2 map_dataA = convert_int2_sat_rtn(map_data);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
float2 _u = map_data - convert_float2(map_dataA);
|
||||
WT2 u = convertToWT2(convert_int2_rte(convertToWT2(_u) * (WT2)INTER_TAB_SIZE)) / (WT2)INTER_TAB_SIZE;
|
||||
WT scalar = convertToWT(convertScalar(nVal));
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,52 +503,58 @@ __kernel void remap_32FC2(__global const uchar * srcptr, int src_step, int src_o
|
||||
ST nVal)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
int y = get_global_id(1) * rowsPerWI;
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
if (x < dst_cols)
|
||||
{
|
||||
int dst_index = mad24(y, dst_step, x * TSIZE + dst_offset);
|
||||
int map_index = mad24(y, map_step, x * (int)sizeof(float2) + map_offset);
|
||||
|
||||
__global const float2 * map = (__global const float2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
float2 map_data = map[0];
|
||||
int2 map_dataA = convert_int2_sat_rtn(map_data);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
float2 _u = map_data - convert_float2(map_dataA);
|
||||
WT2 u = convertToWT2(convert_int2_rte(convertToWT2(_u) * (WT2)INTER_TAB_SIZE)) / (WT2)INTER_TAB_SIZE;
|
||||
WT scalar = convertToWT(convertScalar(nVal));
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
int dst_index = mad24(y, dst_step, mad24(x, TSIZE, dst_offset));
|
||||
int map_index = mad24(y, map_step, mad24(x, (int)sizeof(float2), map_offset));
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < rowsPerWI; ++i, ++y,
|
||||
map_index += map_step, dst_index += dst_step)
|
||||
if (y < dst_rows)
|
||||
{
|
||||
__global const float2 * map = (__global const float2 *)(mapptr + map_index);
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
float2 map_data = map[0];
|
||||
int2 map_dataA = convert_int2_sat_rtn(map_data);
|
||||
int2 map_dataB = (int2)(map_dataA.x + 1, map_dataA.y);
|
||||
int2 map_dataC = (int2)(map_dataA.x, map_dataA.y + 1);
|
||||
int2 map_dataD = (int2)(map_dataA.x + 1, map_dataA.y + 1);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
float2 _u = map_data - convert_float2(map_dataA);
|
||||
WT2 u = convertToWT2(convert_int2_rte(convertToWT2(_u) * (WT2)INTER_TAB_SIZE)) / (WT2)INTER_TAB_SIZE;
|
||||
WT a = scalar, b = scalar, c = scalar, d = scalar;
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
if (!NEED_EXTRAPOLATION(map_dataA.x, map_dataA.y))
|
||||
a = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataA.y, src_step, map_dataA.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataA, a);
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
if (!NEED_EXTRAPOLATION(map_dataB.x, map_dataB.y))
|
||||
b = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataB.y, src_step, map_dataB.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataB, b);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataC.x, map_dataC.y))
|
||||
c = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataC.y, src_step, map_dataC.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataC, c);
|
||||
|
||||
if (!NEED_EXTRAPOLATION(map_dataD.x, map_dataD.y))
|
||||
d = convertToWT(loadpix((__global const T *)(srcptr + mad24(map_dataD.y, src_step, map_dataD.x * TSIZE + src_offset))));
|
||||
else
|
||||
EXTRAPOLATE(map_dataD, d);
|
||||
|
||||
WT dst_data = a * (1 - u.x) * (1 - u.y) +
|
||||
b * (u.x) * (1 - u.y) +
|
||||
c * (1 - u.x) * (u.y) +
|
||||
d * (u.x) * (u.y);
|
||||
storepix(convertToT(dst_data), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -405,10 +405,10 @@ typedef void (*PyrFunc)(const Mat&, Mat&, int);
|
||||
|
||||
static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType)
|
||||
{
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type);
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
|
||||
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
|
||||
if (channels > 4 || (depth == CV_64F && !doubleSupport))
|
||||
if (cn > 4 || (depth == CV_64F && !doubleSupport))
|
||||
return false;
|
||||
|
||||
Size ssize = _src.size();
|
||||
@@ -423,17 +423,20 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in
|
||||
|
||||
int float_depth = depth == CV_64F ? CV_64F : CV_32F;
|
||||
const int local_size = 256;
|
||||
int kercn = 1;
|
||||
if (depth == CV_8U && float_depth == CV_32F && cn == 1 && ocl::Device::getDefault().isIntel())
|
||||
kercn = 4;
|
||||
const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP",
|
||||
"BORDER_REFLECT_101" };
|
||||
char cvt[2][50];
|
||||
String buildOptions = format(
|
||||
"-D T=%s -D FT=%s -D convertToT=%s -D convertToFT=%s%s "
|
||||
"-D T1=%s -D cn=%d -D %s -D LOCAL_SIZE=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(CV_MAKETYPE(float_depth, channels)),
|
||||
ocl::convertTypeStr(float_depth, depth, channels, cvt[0]),
|
||||
ocl::convertTypeStr(depth, float_depth, channels, cvt[1]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "",
|
||||
ocl::typeToStr(depth), channels, borderMap[borderType], local_size
|
||||
"-D T1=%s -D cn=%d -D kercn=%d -D fdepth=%d -D %s -D LOCAL_SIZE=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(CV_MAKETYPE(float_depth, cn)),
|
||||
ocl::convertTypeStr(float_depth, depth, cn, cvt[0]),
|
||||
ocl::convertTypeStr(depth, float_depth, cn, cvt[1]),
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "", ocl::typeToStr(depth),
|
||||
cn, kercn, float_depth, borderMap[borderType], local_size
|
||||
);
|
||||
ocl::Kernel k("pyrDown", ocl::imgproc::pyr_down_oclsrc, buildOptions);
|
||||
if (k.empty())
|
||||
@@ -441,8 +444,8 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in
|
||||
|
||||
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
size_t localThreads[2] = { local_size, 1 };
|
||||
size_t globalThreads[2] = { src.cols, dst.rows };
|
||||
size_t localThreads[2] = { local_size/kercn, 1 };
|
||||
size_t globalThreads[2] = { (src.cols + (kercn-1))/kercn, dst.rows };
|
||||
return k.run(2, globalThreads, localThreads, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair<MatType, MatType>, BorderTy
|
||||
Border map1Border = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
randomSubMat(map1, map1_roi, dstROISize, map1Border, map1Type, -mapMaxValue, mapMaxValue);
|
||||
|
||||
Border map2Border = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
Border map2Border = randomBorder(0, useRoi ? MAX_VALUE + 1 : 0);
|
||||
if (map2Type != noType)
|
||||
{
|
||||
int mapMinValue = -mapMaxValue;
|
||||
|
||||
@@ -948,7 +948,7 @@ int CV_ThreshHistTest::validate_test_results( int /*test_case_idx*/ )
|
||||
class CV_CompareHistTest : public CV_BaseHistTest
|
||||
{
|
||||
public:
|
||||
enum { MAX_METHOD = 5 };
|
||||
enum { MAX_METHOD = 6 };
|
||||
|
||||
CV_CompareHistTest();
|
||||
protected:
|
||||
@@ -1021,6 +1021,13 @@ int CV_CompareHistTest::validate_test_results( int /*test_case_idx*/ )
|
||||
sq0 += v0*v0;
|
||||
sq1 += v1*v1;
|
||||
result0[CV_COMP_BHATTACHARYYA] += sqrt(v0*v1);
|
||||
{
|
||||
if( fabs(v0) <= DBL_EPSILON )
|
||||
continue;
|
||||
if( fabs(v1) <= DBL_EPSILON )
|
||||
v1 = 1e-10;
|
||||
result0[CV_COMP_KL_DIV] += v0 * std::log( v0 / v1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1046,6 +1053,13 @@ int CV_CompareHistTest::validate_test_results( int /*test_case_idx*/ )
|
||||
s0 += v0;
|
||||
sq0 += v0*v0;
|
||||
result0[CV_COMP_BHATTACHARYYA] += sqrt(v0*v1);
|
||||
{
|
||||
if (v0 <= DBL_EPSILON)
|
||||
continue;
|
||||
if (!v1)
|
||||
v1 = 1e-10;
|
||||
result0[CV_COMP_KL_DIV] += v0 * std::log( v0 / v1 );
|
||||
}
|
||||
}
|
||||
|
||||
for( node = cvInitSparseMatIterator( sparse1, &iterator );
|
||||
@@ -1076,7 +1090,8 @@ int CV_CompareHistTest::validate_test_results( int /*test_case_idx*/ )
|
||||
i == CV_COMP_CHISQR_ALT ? "Alternative Chi-Square" :
|
||||
i == CV_COMP_CORREL ? "Correlation" :
|
||||
i == CV_COMP_INTERSECT ? "Intersection" :
|
||||
i == CV_COMP_BHATTACHARYYA ? "Bhattacharyya" : "Unknown";
|
||||
i == CV_COMP_BHATTACHARYYA ? "Bhattacharyya" :
|
||||
i == CV_COMP_KL_DIV ? "Kullback-Leibler" : "Unknown";
|
||||
|
||||
if( cvIsNaN(v) || cvIsInf(v) )
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/core/private.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ if(IOS OR NOT PYTHON_EXECUTABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDR
|
||||
endif()
|
||||
|
||||
set(the_description "The java bindings")
|
||||
ocv_add_module(java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo opencv_nonfree opencv_contrib)
|
||||
ocv_add_module(java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_imgcodecs opencv_videoio opencv_ml opencv_calib3d opencv_photo opencv_nonfree opencv_contrib)
|
||||
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp")
|
||||
|
||||
if(NOT ANDROID)
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.opencv.core.Scalar;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.core.DMatch;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -134,8 +134,8 @@ public class OpenCVTestCase extends TestCase {
|
||||
rgba0 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(0));
|
||||
rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(128));
|
||||
|
||||
rgbLena = Highgui.imread(OpenCVTestRunner.LENA_PATH);
|
||||
grayChess = Highgui.imread(OpenCVTestRunner.CHESS_PATH, 0);
|
||||
rgbLena = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
|
||||
grayChess = Imgcodecs.imread(OpenCVTestRunner.CHESS_PATH, 0);
|
||||
|
||||
v1 = new Mat(1, 3, CvType.CV_32F);
|
||||
v1.put(0, 0, 1.0, 3.0, 2.0);
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
@@ -57,7 +57,7 @@ public class UtilsTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testMatToBitmap() {
|
||||
Mat imgBGR = Highgui.imread( OpenCVTestRunner.LENA_PATH );
|
||||
Mat imgBGR = Imgcodecs.imread( OpenCVTestRunner.LENA_PATH );
|
||||
assertTrue(imgBGR != null && !imgBGR.empty() && imgBGR.channels() == 3);
|
||||
|
||||
Mat m16 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.opencv.features2d.DescriptorMatcher;
|
||||
import org.opencv.features2d.FeatureDetector;
|
||||
import org.opencv.features2d.Features2d;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Features2dTest extends OpenCVTestCase {
|
||||
writeFile(extractorCfgFile, extractorCfg);
|
||||
extractor.read(extractorCfgFile);
|
||||
|
||||
Mat imgTrain = Highgui.imread(OpenCVTestRunner.LENA_PATH, Highgui.CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat imgTrain = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat imgQuery = imgTrain.submat(new Range(0, imgTrain.rows() - 100), Range.all());
|
||||
|
||||
MatOfKeyPoint trainKeypoints = new MatOfKeyPoint();
|
||||
@@ -139,7 +139,7 @@ public class Features2dTest extends OpenCVTestCase {
|
||||
Mat outimg = new Mat();
|
||||
Features2d.drawMatches(imgQuery, queryKeypoints, imgTrain, trainKeypoints, matches, outimg);
|
||||
String outputPath = OpenCVTestRunner.getOutputFileName("PTODresult.png");
|
||||
Highgui.imwrite(outputPath, outimg);
|
||||
Imgcodecs.imwrite(outputPath, outimg);
|
||||
// OpenCVTestRunner.Log("Output image is saved to: " + outputPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.opencv.test.highgui;
|
||||
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfInt;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
@@ -15,29 +15,29 @@ public class HighguiTest extends OpenCVTestCase {
|
||||
public void testImencodeStringMatListOfByte() {
|
||||
MatOfByte buff = new MatOfByte();
|
||||
assertEquals(0, buff.total());
|
||||
assertTrue( Highgui.imencode(".jpg", gray127, buff) );
|
||||
assertTrue( Imgcodecs.imencode(".jpg", gray127, buff) );
|
||||
assertFalse(0 == buff.total());
|
||||
}
|
||||
|
||||
public void testImencodeStringMatListOfByteListOfInteger() {
|
||||
MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
|
||||
MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
|
||||
MatOfInt params40 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
|
||||
MatOfInt params90 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 90);
|
||||
/* or
|
||||
MatOfInt params = new MatOfInt();
|
||||
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
|
||||
params.fromArray(Imgcodecs.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( Imgcodecs.imencode(".jpg", rgbLena, buff40, params40) );
|
||||
assertTrue( Imgcodecs.imencode(".jpg", rgbLena, buff90, params90) );
|
||||
|
||||
assertTrue(buff40.total() > 0);
|
||||
assertTrue(buff40.total() < buff90.total());
|
||||
}
|
||||
|
||||
public void testImreadString() {
|
||||
dst = Highgui.imread(OpenCVTestRunner.LENA_PATH);
|
||||
dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
|
||||
assertTrue(!dst.empty());
|
||||
assertEquals(3, dst.channels());
|
||||
assertTrue(512 == dst.cols());
|
||||
@@ -45,7 +45,7 @@ public class HighguiTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testImreadStringInt() {
|
||||
dst = Highgui.imread(OpenCVTestRunner.LENA_PATH, 0);
|
||||
dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, 0);
|
||||
assertTrue(!dst.empty());
|
||||
assertEquals(1, dst.channels());
|
||||
assertTrue(512 == dst.cols());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user