mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge branch 'master' of https://github.com/Itseez/opencv into gdal_lan
Conflicts: modules/imgcodecs/include/opencv2/imgcodecs.hpp
This commit is contained in:
@@ -154,7 +154,7 @@ struct CvCBQuad
|
||||
//static CvMat* debug_img = 0;
|
||||
|
||||
static int icvGenerateQuads( CvCBQuad **quads, CvCBCorner **corners,
|
||||
CvMemStorage *storage, CvMat *image, int flags );
|
||||
CvMemStorage *storage, CvMat *image, int flags, int *max_quad_buf_size);
|
||||
|
||||
/*static int
|
||||
icvGenerateQuadsEx( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
@@ -174,7 +174,7 @@ static int icvCleanFoundConnectedQuads( int quad_count,
|
||||
|
||||
static int icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
|
||||
int *all_count, CvCBQuad **all_quads, CvCBCorner **corners,
|
||||
CvSize pattern_size, CvMemStorage* storage );
|
||||
CvSize pattern_size, int max_quad_buf_size, CvMemStorage* storage );
|
||||
|
||||
static void icvOrderQuad(CvCBQuad *quad, CvCBCorner *corner, int common);
|
||||
|
||||
@@ -185,7 +185,7 @@ static int icvTrimRow(CvCBQuad **quads, int count, int row, int dir);
|
||||
#endif
|
||||
|
||||
static int icvAddOuterQuad(CvCBQuad *quad, CvCBQuad **quads, int quad_count,
|
||||
CvCBQuad **all_quads, int all_count, CvCBCorner **corners);
|
||||
CvCBQuad **all_quads, int all_count, CvCBCorner **corners, int max_quad_buf_size);
|
||||
|
||||
static void icvRemoveQuadFromGroup(CvCBQuad **quads, int count, CvCBQuad *q0);
|
||||
|
||||
@@ -314,6 +314,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
// making it difficult to detect smaller squares.
|
||||
for( k = 0; k < 6; k++ )
|
||||
{
|
||||
int max_quad_buf_size = 0;
|
||||
for( dilations = min_dilations; dilations <= max_dilations; dilations++ )
|
||||
{
|
||||
if (found)
|
||||
@@ -369,7 +370,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
cvRectangle( thresh_img, cvPoint(0,0), cvPoint(thresh_img->cols-1,
|
||||
thresh_img->rows-1), CV_RGB(255,255,255), 3, 8);
|
||||
|
||||
quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags );
|
||||
quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags, &max_quad_buf_size);
|
||||
|
||||
PRINTF("Quad count: %d/%d\n", quad_count, expected_corners_num);
|
||||
}
|
||||
@@ -409,8 +410,8 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
// allocate extra for adding in icvOrderFoundQuads
|
||||
cvFree(&quad_group);
|
||||
cvFree(&corner_group);
|
||||
quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * (quad_count+quad_count / 2));
|
||||
corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * (quad_count+quad_count / 2)*4 );
|
||||
quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * max_quad_buf_size);
|
||||
corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * max_quad_buf_size * 4 );
|
||||
|
||||
for( group_idx = 0; ; group_idx++ )
|
||||
{
|
||||
@@ -425,7 +426,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
// maybe delete or add some
|
||||
PRINTF("Starting ordering of inner quads\n");
|
||||
count = icvOrderFoundConnectedQuads(count, quad_group, &quad_count, &quads, &corners,
|
||||
pattern_size, storage );
|
||||
pattern_size, max_quad_buf_size, storage );
|
||||
PRINTF("Orig count: %d After ordering: %d\n", icount, count);
|
||||
|
||||
|
||||
@@ -624,7 +625,7 @@ icvCheckBoardMonotony( CvPoint2D32f* corners, CvSize pattern_size )
|
||||
static int
|
||||
icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
|
||||
int *all_count, CvCBQuad **all_quads, CvCBCorner **corners,
|
||||
CvSize pattern_size, CvMemStorage* storage )
|
||||
CvSize pattern_size, int max_quad_buf_size, CvMemStorage* storage )
|
||||
{
|
||||
cv::Ptr<CvMemStorage> temp_storage(cvCreateChildMemStorage( storage ));
|
||||
CvSeq* stack = cvCreateSeq( 0, sizeof(*stack), sizeof(void*), temp_storage );
|
||||
@@ -804,15 +805,18 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
|
||||
if (found > 0)
|
||||
{
|
||||
PRINTF("Found %d inner quads not connected to outer quads, repairing\n", found);
|
||||
for (int i=0; i<quad_count; i++)
|
||||
for (int i=0; i<quad_count && *all_count < max_quad_buf_size; i++)
|
||||
{
|
||||
if (quads[i]->count < 4 && quads[i]->ordered)
|
||||
{
|
||||
int added = icvAddOuterQuad(quads[i],quads,quad_count,all_quads,*all_count,corners);
|
||||
int added = icvAddOuterQuad(quads[i],quads,quad_count,all_quads,*all_count,corners, max_quad_buf_size);
|
||||
*all_count += added;
|
||||
quad_count += added;
|
||||
}
|
||||
}
|
||||
|
||||
if (*all_count >= max_quad_buf_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -855,11 +859,11 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
|
||||
|
||||
static int
|
||||
icvAddOuterQuad( CvCBQuad *quad, CvCBQuad **quads, int quad_count,
|
||||
CvCBQuad **all_quads, int all_count, CvCBCorner **corners )
|
||||
CvCBQuad **all_quads, int all_count, CvCBCorner **corners, int max_quad_buf_size )
|
||||
|
||||
{
|
||||
int added = 0;
|
||||
for (int i=0; i<4; i++) // find no-neighbor corners
|
||||
for (int i=0; i<4 && all_count < max_quad_buf_size; i++) // find no-neighbor corners
|
||||
{
|
||||
if (!quad->neighbors[i]) // ok, create and add neighbor
|
||||
{
|
||||
@@ -1649,7 +1653,7 @@ static void icvFindQuadNeighbors( CvCBQuad *quads, int quad_count )
|
||||
|
||||
static int
|
||||
icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
CvMemStorage *storage, CvMat *image, int flags )
|
||||
CvMemStorage *storage, CvMat *image, int flags, int *max_quad_buf_size )
|
||||
{
|
||||
int quad_count = 0;
|
||||
cv::Ptr<CvMemStorage> temp_storage;
|
||||
@@ -1754,8 +1758,9 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
cvEndFindContours( &scanner );
|
||||
|
||||
// allocate quad & corner buffers
|
||||
*out_quads = (CvCBQuad*)cvAlloc((root->total+root->total / 2) * sizeof((*out_quads)[0]));
|
||||
*out_corners = (CvCBCorner*)cvAlloc((root->total+root->total / 2) * 4 * sizeof((*out_corners)[0]));
|
||||
*max_quad_buf_size = MAX(1, (root->total+root->total / 2)) * 2;
|
||||
*out_quads = (CvCBQuad*)cvAlloc(*max_quad_buf_size * sizeof((*out_quads)[0]));
|
||||
*out_corners = (CvCBCorner*)cvAlloc(*max_quad_buf_size * 4 * sizeof((*out_corners)[0]));
|
||||
|
||||
// Create array of quads structures
|
||||
for( idx = 0; idx < root->total; idx++ )
|
||||
|
||||
@@ -512,7 +512,7 @@ void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, Input
|
||||
OutputArray P, double balance, const Size& new_size, double fov_scale)
|
||||
{
|
||||
CV_Assert( K.size() == Size(3, 3) && (K.depth() == CV_32F || K.depth() == CV_64F));
|
||||
CV_Assert((D.empty() || D.total() == 4) && (D.depth() == CV_32F || D.depth() == CV_64F || D.empty()));
|
||||
CV_Assert(D.empty() || ((D.total() == 4) && (D.depth() == CV_32F || D.depth() == CV_64F)));
|
||||
|
||||
int w = image_size.width, h = image_size.height;
|
||||
balance = std::min(std::max(balance, 0.0), 1.0);
|
||||
@@ -694,12 +694,12 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray
|
||||
CV_Assert(!objectPoints.empty() && !imagePoints.empty() && objectPoints.total() == imagePoints.total());
|
||||
CV_Assert(objectPoints.type() == CV_32FC3 || objectPoints.type() == CV_64FC3);
|
||||
CV_Assert(imagePoints.type() == CV_32FC2 || imagePoints.type() == CV_64FC2);
|
||||
CV_Assert((!K.empty() && K.size() == Size(3,3)) || K.empty());
|
||||
CV_Assert((!D.empty() && D.total() == 4) || D.empty());
|
||||
CV_Assert((!rvecs.empty() && rvecs.channels() == 3) || rvecs.empty());
|
||||
CV_Assert((!tvecs.empty() && tvecs.channels() == 3) || tvecs.empty());
|
||||
CV_Assert(K.empty() || (K.size() == Size(3,3)));
|
||||
CV_Assert(D.empty() || (D.total() == 4));
|
||||
CV_Assert(rvecs.empty() || (rvecs.channels() == 3));
|
||||
CV_Assert(tvecs.empty() || (tvecs.channels() == 3));
|
||||
|
||||
CV_Assert(((flags & CALIB_USE_INTRINSIC_GUESS) && !K.empty() && !D.empty()) || !(flags & CALIB_USE_INTRINSIC_GUESS));
|
||||
CV_Assert((!K.empty() && !D.empty()) || !(flags & CALIB_USE_INTRINSIC_GUESS));
|
||||
|
||||
using namespace cv::internal;
|
||||
//-------------------------------Initialization
|
||||
@@ -825,12 +825,12 @@ double cv::fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO
|
||||
CV_Assert(imagePoints1.type() == CV_32FC2 || imagePoints1.type() == CV_64FC2);
|
||||
CV_Assert(imagePoints2.type() == CV_32FC2 || imagePoints2.type() == CV_64FC2);
|
||||
|
||||
CV_Assert((!K1.empty() && K1.size() == Size(3,3)) || K1.empty());
|
||||
CV_Assert((!D1.empty() && D1.total() == 4) || D1.empty());
|
||||
CV_Assert((!K2.empty() && K1.size() == Size(3,3)) || K2.empty());
|
||||
CV_Assert((!D2.empty() && D1.total() == 4) || D2.empty());
|
||||
CV_Assert(K1.empty() || (K1.size() == Size(3,3)));
|
||||
CV_Assert(D1.empty() || (D1.total() == 4));
|
||||
CV_Assert(K2.empty() || (K1.size() == Size(3,3)));
|
||||
CV_Assert(D2.empty() || (D1.total() == 4));
|
||||
|
||||
CV_Assert(((flags & CALIB_FIX_INTRINSIC) && !K1.empty() && !K2.empty() && !D1.empty() && !D2.empty()) || !(flags & CALIB_FIX_INTRINSIC));
|
||||
CV_Assert((!K1.empty() && !K2.empty() && !D1.empty() && !D2.empty()) || !(flags & CALIB_FIX_INTRINSIC));
|
||||
|
||||
//-------------------------------Initialization
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*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) 2015, Itseez 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*/
|
||||
|
||||
//
|
||||
// Library initialization file
|
||||
//
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
IPP_INITIALIZER_AUTO
|
||||
|
||||
/* End of file. */
|
||||
@@ -99,7 +99,7 @@ static bool ocl_prefilter_norm(InputArray _input, OutputArray _output, int winsi
|
||||
_output.create(input.size(), input.type());
|
||||
output = _output.getUMat();
|
||||
|
||||
size_t globalThreads[3] = { input.cols, input.rows, 1 };
|
||||
size_t globalThreads[3] = { (size_t)input.cols, (size_t)input.rows, 1 };
|
||||
|
||||
k.args(ocl::KernelArg::PtrReadOnly(input), ocl::KernelArg::PtrWriteOnly(output), input.rows, input.cols,
|
||||
prefilterCap, scale_g, scale_s);
|
||||
@@ -180,7 +180,7 @@ static bool ocl_prefilter_xsobel(InputArray _input, OutputArray _output, int pre
|
||||
_output.create(input.size(), input.type());
|
||||
output = _output.getUMat();
|
||||
|
||||
size_t globalThreads[3] = { input.cols, input.rows, 1 };
|
||||
size_t globalThreads[3] = { (size_t)input.cols, (size_t)input.rows, 1 };
|
||||
|
||||
k.args(ocl::KernelArg::PtrReadOnly(input), ocl::KernelArg::PtrWriteOnly(output), input.rows, input.cols, prefilterCap);
|
||||
|
||||
@@ -927,8 +927,8 @@ static bool ocl_stereobm( InputArray _left, InputArray _right,
|
||||
|
||||
int globalX = (disp.cols + sizeX - 1) / sizeX,
|
||||
globalY = (disp.rows + sizeY - 1) / sizeY;
|
||||
size_t globalThreads[3] = {N, globalX, globalY};
|
||||
size_t localThreads[3] = {N, 1, 1};
|
||||
size_t globalThreads[3] = {(size_t)N, (size_t)globalX, (size_t)globalY};
|
||||
size_t localThreads[3] = {(size_t)N, 1, 1};
|
||||
|
||||
int idx = 0;
|
||||
idx = k.set(idx, ocl::KernelArg::PtrReadOnly(left));
|
||||
|
||||
@@ -1688,6 +1688,45 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
int type = img.type();
|
||||
Ipp32s bufsize = 0;
|
||||
IppiSize roisize = { img.cols, img.rows };
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
|
||||
Ipp8u *pBuffer = NULL;
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
if(ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize) < 0)
|
||||
return false;
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufsize);
|
||||
if(!pBuffer && bufsize)
|
||||
return false;
|
||||
|
||||
if (type == CV_8UC1)
|
||||
{
|
||||
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
|
||||
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
|
||||
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
|
||||
if (status >= 0)
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSize,
|
||||
@@ -1700,37 +1739,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
|
||||
|
||||
int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff);
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
Ipp32s bufsize = 0;
|
||||
IppiSize roisize = { img.cols, img.rows };
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
|
||||
|
||||
if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1))
|
||||
{
|
||||
IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize);
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
|
||||
if ((int)status >= 0)
|
||||
{
|
||||
if (type == CV_8UC1)
|
||||
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
|
||||
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer);
|
||||
else
|
||||
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
|
||||
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer);
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 810 && !__buf.needed() && (type == CV_8UC1 || type == CV_16SC1), ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff));
|
||||
|
||||
if (type == CV_8UC1)
|
||||
filterSpecklesImpl<uchar>(img, newVal, maxSpeckleSize, maxDiff, _buf);
|
||||
|
||||
@@ -101,15 +101,15 @@ TEST_F(fisheyeTest, projectPoints)
|
||||
|
||||
TEST_F(fisheyeTest, DISABLED_undistortImage)
|
||||
{
|
||||
cv::Matx33d K = this->K;
|
||||
cv::Mat D = cv::Mat(this->D);
|
||||
cv::Matx33d theK = this->K;
|
||||
cv::Mat theD = cv::Mat(this->D);
|
||||
std::string file = combine(datasets_repository_path, "/calib-3_stereo_from_JY/left/stereo_pair_014.jpg");
|
||||
cv::Matx33d newK = K;
|
||||
cv::Matx33d newK = theK;
|
||||
cv::Mat distorted = cv::imread(file), undistorted;
|
||||
{
|
||||
newK(0, 0) = 100;
|
||||
newK(1, 1) = 100;
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, theK, theD, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "new_f_100.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "new_f_100.png"), undistorted));
|
||||
@@ -118,8 +118,8 @@ TEST_F(fisheyeTest, DISABLED_undistortImage)
|
||||
}
|
||||
{
|
||||
double balance = 1.0;
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(K, D, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(theK, theD, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, theK, theD, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "balance_1.0.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "balance_1.0.png"), undistorted));
|
||||
@@ -129,8 +129,8 @@ TEST_F(fisheyeTest, DISABLED_undistortImage)
|
||||
|
||||
{
|
||||
double balance = 0.0;
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(K, D, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(theK, theD, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, theK, theD, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "balance_0.0.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "balance_0.0.png"), undistorted));
|
||||
@@ -143,7 +143,7 @@ TEST_F(fisheyeTest, jacobians)
|
||||
{
|
||||
int n = 10;
|
||||
cv::Mat X(1, n, CV_64FC3);
|
||||
cv::Mat om(3, 1, CV_64F), T(3, 1, CV_64F);
|
||||
cv::Mat om(3, 1, CV_64F), theT(3, 1, CV_64F);
|
||||
cv::Mat f(2, 1, CV_64F), c(2, 1, CV_64F);
|
||||
cv::Mat k(4, 1, CV_64F);
|
||||
double alpha;
|
||||
@@ -156,8 +156,8 @@ TEST_F(fisheyeTest, jacobians)
|
||||
r.fill(om, cv::RNG::NORMAL, 0, 1);
|
||||
om = cv::abs(om);
|
||||
|
||||
r.fill(T, cv::RNG::NORMAL, 0, 1);
|
||||
T = cv::abs(T); T.at<double>(2) = 4; T *= 10;
|
||||
r.fill(theT, cv::RNG::NORMAL, 0, 1);
|
||||
theT = cv::abs(theT); theT.at<double>(2) = 4; theT *= 10;
|
||||
|
||||
r.fill(f, cv::RNG::NORMAL, 0, 1);
|
||||
f = cv::abs(f) * 1000;
|
||||
@@ -171,19 +171,19 @@ TEST_F(fisheyeTest, jacobians)
|
||||
alpha = 0.01*r.gaussian(1);
|
||||
|
||||
cv::Mat x1, x2, xpred;
|
||||
cv::Matx33d K(f.at<double>(0), alpha * f.at<double>(0), c.at<double>(0),
|
||||
cv::Matx33d theK(f.at<double>(0), alpha * f.at<double>(0), c.at<double>(0),
|
||||
0, f.at<double>(1), c.at<double>(1),
|
||||
0, 0, 1);
|
||||
|
||||
cv::Mat jacobians;
|
||||
cv::fisheye::projectPoints(X, x1, om, T, K, k, alpha, jacobians);
|
||||
cv::fisheye::projectPoints(X, x1, om, theT, theK, k, alpha, jacobians);
|
||||
|
||||
//test on T:
|
||||
cv::Mat dT(3, 1, CV_64FC1);
|
||||
r.fill(dT, cv::RNG::NORMAL, 0, 1);
|
||||
dT *= 1e-9*cv::norm(T);
|
||||
cv::Mat T2 = T + dT;
|
||||
cv::fisheye::projectPoints(X, x2, om, T2, K, k, alpha, cv::noArray());
|
||||
dT *= 1e-9*cv::norm(theT);
|
||||
cv::Mat T2 = theT + dT;
|
||||
cv::fisheye::projectPoints(X, x2, om, T2, theK, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(11,14) * dT).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
@@ -192,7 +192,7 @@ TEST_F(fisheyeTest, jacobians)
|
||||
r.fill(dom, cv::RNG::NORMAL, 0, 1);
|
||||
dom *= 1e-9*cv::norm(om);
|
||||
cv::Mat om2 = om + dom;
|
||||
cv::fisheye::projectPoints(X, x2, om2, T, K, k, alpha, cv::noArray());
|
||||
cv::fisheye::projectPoints(X, x2, om2, theT, theK, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(8,11) * dom).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
@@ -200,8 +200,8 @@ TEST_F(fisheyeTest, jacobians)
|
||||
cv::Mat df(2, 1, CV_64FC1);
|
||||
r.fill(df, cv::RNG::NORMAL, 0, 1);
|
||||
df *= 1e-9*cv::norm(f);
|
||||
cv::Matx33d K2 = K + cv::Matx33d(df.at<double>(0), df.at<double>(0) * alpha, 0, 0, df.at<double>(1), 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K2, k, alpha, cv::noArray());
|
||||
cv::Matx33d K2 = theK + cv::Matx33d(df.at<double>(0), df.at<double>(0) * alpha, 0, 0, df.at<double>(1), 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, theT, K2, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(0,2) * df).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
@@ -209,8 +209,8 @@ TEST_F(fisheyeTest, jacobians)
|
||||
cv::Mat dc(2, 1, CV_64FC1);
|
||||
r.fill(dc, cv::RNG::NORMAL, 0, 1);
|
||||
dc *= 1e-9*cv::norm(c);
|
||||
K2 = K + cv::Matx33d(0, 0, dc.at<double>(0), 0, 0, dc.at<double>(1), 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K2, k, alpha, cv::noArray());
|
||||
K2 = theK + cv::Matx33d(0, 0, dc.at<double>(0), 0, 0, dc.at<double>(1), 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, theT, K2, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(2,4) * dc).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
@@ -219,7 +219,7 @@ TEST_F(fisheyeTest, jacobians)
|
||||
r.fill(dk, cv::RNG::NORMAL, 0, 1);
|
||||
dk *= 1e-9*cv::norm(k);
|
||||
cv::Mat k2 = k + dk;
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K, k2, alpha, cv::noArray());
|
||||
cv::fisheye::projectPoints(X, x2, om, theT, theK, k2, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(4,8) * dk).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
@@ -228,8 +228,8 @@ TEST_F(fisheyeTest, jacobians)
|
||||
r.fill(dalpha, cv::RNG::NORMAL, 0, 1);
|
||||
dalpha *= 1e-9*cv::norm(f);
|
||||
double alpha2 = alpha + dalpha.at<double>(0);
|
||||
K2 = K + cv::Matx33d(0, f.at<double>(0) * dalpha.at<double>(0), 0, 0, 0, 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K, k, alpha2, cv::noArray());
|
||||
K2 = theK + cv::Matx33d(0, f.at<double>(0) * dalpha.at<double>(0), 0, 0, 0, 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, theT, theK, k, alpha2, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.col(14) * dalpha).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
}
|
||||
@@ -259,14 +259,14 @@ TEST_F(fisheyeTest, Calibration)
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
|
||||
cv::Matx33d K;
|
||||
cv::Vec4d D;
|
||||
cv::Matx33d theK;
|
||||
cv::Vec4d theD;
|
||||
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, K, D,
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, theK, theD,
|
||||
cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
|
||||
EXPECT_MAT_NEAR(K, this->K, 1e-10);
|
||||
EXPECT_MAT_NEAR(D, this->D, 1e-10);
|
||||
EXPECT_MAT_NEAR(theK, this->K, 1e-10);
|
||||
EXPECT_MAT_NEAR(theD, this->D, 1e-10);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, Homography)
|
||||
@@ -303,15 +303,15 @@ TEST_F(fisheyeTest, Homography)
|
||||
int Np = imagePointsNormalized.cols;
|
||||
cv::calcCovarMatrix(_objectPoints, covObjectPoints, objectPointsMean, cv::COVAR_NORMAL | cv::COVAR_COLS);
|
||||
cv::SVD svd(covObjectPoints);
|
||||
cv::Mat R(svd.vt);
|
||||
cv::Mat theR(svd.vt);
|
||||
|
||||
if (cv::norm(R(cv::Rect(2, 0, 1, 2))) < 1e-6)
|
||||
R = cv::Mat::eye(3,3, CV_64FC1);
|
||||
if (cv::determinant(R) < 0)
|
||||
R = -R;
|
||||
if (cv::norm(theR(cv::Rect(2, 0, 1, 2))) < 1e-6)
|
||||
theR = cv::Mat::eye(3,3, CV_64FC1);
|
||||
if (cv::determinant(theR) < 0)
|
||||
theR = -theR;
|
||||
|
||||
cv::Mat T = -R * objectPointsMean;
|
||||
cv::Mat X_new = R * _objectPoints + T * cv::Mat::ones(1, Np, CV_64FC1);
|
||||
cv::Mat theT = -theR * objectPointsMean;
|
||||
cv::Mat X_new = theR * _objectPoints + theT * cv::Mat::ones(1, Np, CV_64FC1);
|
||||
cv::Mat H = cv::internal::ComputeHomography(imagePointsNormalized, X_new.rowRange(0, 2));
|
||||
|
||||
cv::Mat M = cv::Mat::ones(3, X_new.cols, CV_64FC1);
|
||||
@@ -355,19 +355,19 @@ TEST_F(fisheyeTest, EtimateUncertainties)
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
|
||||
cv::Matx33d K;
|
||||
cv::Vec4d D;
|
||||
cv::Matx33d theK;
|
||||
cv::Vec4d theD;
|
||||
std::vector<cv::Vec3d> rvec;
|
||||
std::vector<cv::Vec3d> tvec;
|
||||
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, K, D,
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, theK, theD,
|
||||
rvec, tvec, flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
|
||||
cv::internal::IntrinsicParams param, errors;
|
||||
cv::Vec2d err_std;
|
||||
double thresh_cond = 1e6;
|
||||
int check_cond = 1;
|
||||
param.Init(cv::Vec2d(K(0,0), K(1,1)), cv::Vec2d(K(0,2), K(1, 2)), D);
|
||||
param.Init(cv::Vec2d(theK(0,0), theK(1,1)), cv::Vec2d(theK(0,2), theK(1, 2)), theD);
|
||||
param.isEstimate = std::vector<int>(9, 1);
|
||||
param.isEstimate[4] = 0;
|
||||
|
||||
@@ -399,12 +399,12 @@ TEST_F(fisheyeTest, rectify)
|
||||
cv::Matx33d K1 = this->K, K2 = K1;
|
||||
cv::Mat D1 = cv::Mat(this->D), D2 = D1;
|
||||
|
||||
cv::Vec3d T = this->T;
|
||||
cv::Matx33d R = this->R;
|
||||
cv::Vec3d theT = this->T;
|
||||
cv::Matx33d theR = this->R;
|
||||
|
||||
double balance = 0.0, fov_scale = 1.1;
|
||||
cv::Mat R1, R2, P1, P2, Q;
|
||||
cv::fisheye::stereoRectify(K1, D1, K2, D2, calibration_size, R, T, R1, R2, P1, P2, Q,
|
||||
cv::fisheye::stereoRectify(K1, D1, K2, D2, calibration_size, theR, theT, R1, R2, P1, P2, Q,
|
||||
cv::CALIB_ZERO_DISPARITY, requested_size, balance, fov_scale);
|
||||
|
||||
cv::Mat lmapx, lmapy, rmapx, rmapy;
|
||||
@@ -468,8 +468,8 @@ TEST_F(fisheyeTest, stereoCalibrate)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d K1, K2, R;
|
||||
cv::Vec3d T;
|
||||
cv::Matx33d K1, K2, theR;
|
||||
cv::Vec3d theT;
|
||||
cv::Vec4d D1, D2;
|
||||
|
||||
int flag = 0;
|
||||
@@ -479,7 +479,7 @@ TEST_F(fisheyeTest, stereoCalibrate)
|
||||
// flag |= cv::fisheye::CALIB_FIX_INTRINSIC;
|
||||
|
||||
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
|
||||
K1, D1, K2, D2, imageSize, R, T, flag,
|
||||
K1, D1, K2, D2, imageSize, theR, theT, flag,
|
||||
cv::TermCriteria(3, 12, 0));
|
||||
|
||||
cv::Matx33d R_correct( 0.9975587205950972, 0.06953016383322372, 0.006492709911733523,
|
||||
@@ -497,8 +497,8 @@ TEST_F(fisheyeTest, stereoCalibrate)
|
||||
cv::Vec4d D1_correct (-7.44253716539556e-05, -0.00702662033932424, 0.00737569823650885, -0.00342230256441771);
|
||||
cv::Vec4d D2_correct (-0.0130785435677431, 0.0284434505383497, -0.0360333869900506, 0.0144724062347222);
|
||||
|
||||
EXPECT_MAT_NEAR(R, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(T, T_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(theR, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(theT, T_correct, 1e-10);
|
||||
|
||||
EXPECT_MAT_NEAR(K1, K1_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(K2, K2_correct, 1e-10);
|
||||
@@ -536,8 +536,8 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d R;
|
||||
cv::Vec3d T;
|
||||
cv::Matx33d theR;
|
||||
cv::Vec3d theT;
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
@@ -557,7 +557,7 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
cv::Vec4d D2 (-0.0130785435677431, 0.0284434505383497, -0.0360333869900506, 0.0144724062347222);
|
||||
|
||||
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
|
||||
K1, D1, K2, D2, imageSize, R, T, flag,
|
||||
K1, D1, K2, D2, imageSize, theR, theT, flag,
|
||||
cv::TermCriteria(3, 12, 0));
|
||||
|
||||
cv::Matx33d R_correct( 0.9975587205950972, 0.06953016383322372, 0.006492709911733523,
|
||||
@@ -566,8 +566,8 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
cv::Vec3d T_correct(-0.099402724724121, 0.00270812139265413, 0.00129330292472699);
|
||||
|
||||
|
||||
EXPECT_MAT_NEAR(R, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(T, T_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(theR, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(theT, T_correct, 1e-10);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
set(the_description "The Core Functionality")
|
||||
ocv_add_module(core
|
||||
opencv_hal
|
||||
PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}"
|
||||
PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
|
||||
OPTIONAL opencv_cudev
|
||||
WRAP java python)
|
||||
|
||||
|
||||
@@ -2381,8 +2381,7 @@ class CV_EXPORTS LDA
|
||||
{
|
||||
public:
|
||||
/** @brief constructor
|
||||
Initializes a LDA with num_components (default 0) and specifies how
|
||||
samples are aligned (default dataAsRow=true).
|
||||
Initializes a LDA with num_components (default 0).
|
||||
*/
|
||||
explicit LDA(int num_components = 0);
|
||||
|
||||
@@ -2413,15 +2412,17 @@ public:
|
||||
*/
|
||||
~LDA();
|
||||
|
||||
/** Compute the discriminants for data in src and labels.
|
||||
/** Compute the discriminants for data in src (row aligned) and labels.
|
||||
*/
|
||||
void compute(InputArrayOfArrays src, InputArray labels);
|
||||
|
||||
/** Projects samples into the LDA subspace.
|
||||
src may be one or more row aligned samples.
|
||||
*/
|
||||
Mat project(InputArray src);
|
||||
|
||||
/** Reconstructs projections from the LDA subspace.
|
||||
src may be one or more row aligned projections.
|
||||
*/
|
||||
Mat reconstruct(InputArray src);
|
||||
|
||||
@@ -2437,11 +2438,10 @@ public:
|
||||
static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
|
||||
|
||||
protected:
|
||||
bool _dataAsRow;
|
||||
bool _dataAsRow; // unused, but needed for 3.0 ABI compatibility.
|
||||
int _num_components;
|
||||
Mat _eigenvectors;
|
||||
Mat _eigenvalues;
|
||||
|
||||
void lda(InputArrayOfArrays src, InputArray labels);
|
||||
};
|
||||
|
||||
|
||||
@@ -645,6 +645,7 @@ namespace cudev
|
||||
|
||||
namespace ipp
|
||||
{
|
||||
CV_EXPORTS int getIppFeatures();
|
||||
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
|
||||
int line = 0);
|
||||
CV_EXPORTS int getIppStatus();
|
||||
|
||||
@@ -496,6 +496,8 @@ struct CV_EXPORTS UMatData
|
||||
void* handle;
|
||||
void* userdata;
|
||||
int allocatorFlags_;
|
||||
int mapcount;
|
||||
UMatData* originalUMatData;
|
||||
};
|
||||
|
||||
|
||||
@@ -1071,6 +1073,7 @@ public:
|
||||
@param m Destination matrix. If it does not have a proper size or type before the operation, it is
|
||||
reallocated.
|
||||
@param mask Operation mask. Its non-zero elements indicate which matrix elements need to be copied.
|
||||
The mask has to be of type CV_8U and can have 1 or multiple channels.
|
||||
*/
|
||||
void copyTo( OutputArray m, InputArray mask ) const;
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1)
|
||||
{
|
||||
CV_StaticAssert(channels >= 2, "Matx should have at least 2 elaments.");
|
||||
CV_StaticAssert(channels >= 2, "Matx should have at least 2 elements.");
|
||||
val[0] = v0; val[1] = v1;
|
||||
for(int i = 2; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2)
|
||||
{
|
||||
CV_StaticAssert(channels >= 3, "Matx should have at least 3 elaments.");
|
||||
CV_StaticAssert(channels >= 3, "Matx should have at least 3 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2;
|
||||
for(int i = 3; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
@@ -510,7 +510,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
|
||||
{
|
||||
CV_StaticAssert(channels >= 4, "Matx should have at least 4 elaments.");
|
||||
CV_StaticAssert(channels >= 4, "Matx should have at least 4 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
for(int i = 4; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
@@ -518,7 +518,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4)
|
||||
{
|
||||
CV_StaticAssert(channels >= 5, "Matx should have at least 5 elaments.");
|
||||
CV_StaticAssert(channels >= 5, "Matx should have at least 5 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; val[4] = v4;
|
||||
for(int i = 5; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
@@ -526,7 +526,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5)
|
||||
{
|
||||
CV_StaticAssert(channels >= 6, "Matx should have at least 6 elaments.");
|
||||
CV_StaticAssert(channels >= 6, "Matx should have at least 6 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5;
|
||||
for(int i = 6; i < channels; i++) val[i] = _Tp(0);
|
||||
@@ -535,7 +535,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6)
|
||||
{
|
||||
CV_StaticAssert(channels >= 7, "Matx should have at least 7 elaments.");
|
||||
CV_StaticAssert(channels >= 7, "Matx should have at least 7 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6;
|
||||
for(int i = 7; i < channels; i++) val[i] = _Tp(0);
|
||||
@@ -544,7 +544,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6)
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7)
|
||||
{
|
||||
CV_StaticAssert(channels >= 8, "Matx should have at least 8 elaments.");
|
||||
CV_StaticAssert(channels >= 8, "Matx should have at least 8 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
for(int i = 8; i < channels; i++) val[i] = _Tp(0);
|
||||
@@ -553,7 +553,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _T
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8)
|
||||
{
|
||||
CV_StaticAssert(channels >= 9, "Matx should have at least 9 elaments.");
|
||||
CV_StaticAssert(channels >= 9, "Matx should have at least 9 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
val[8] = v8;
|
||||
@@ -563,7 +563,7 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _T
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9)
|
||||
{
|
||||
CV_StaticAssert(channels >= 10, "Matx should have at least 10 elaments.");
|
||||
CV_StaticAssert(channels >= 10, "Matx should have at least 10 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
val[8] = v8; val[9] = v9;
|
||||
@@ -574,20 +574,22 @@ Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _T
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11)
|
||||
{
|
||||
CV_StaticAssert(channels == 12, "Matx should have at least 12 elaments.");
|
||||
CV_StaticAssert(channels >= 12, "Matx should have at least 12 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
||||
for(int i = 12; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13, _Tp v14, _Tp v15)
|
||||
{
|
||||
CV_StaticAssert(channels == 16, "Matx should have at least 16 elaments.");
|
||||
CV_StaticAssert(channels >= 16, "Matx should have at least 16 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
||||
val[12] = v12; val[13] = v13; val[14] = v14; val[15] = v15;
|
||||
for(int i = 16; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
|
||||
template<typename _Tp, int m, int n> inline
|
||||
|
||||
@@ -191,9 +191,16 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
# include "ipp.h"
|
||||
#include "ipp.h"
|
||||
|
||||
# define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR)
|
||||
#ifndef IPP_VERSION_UPDATE // prior to 7.1
|
||||
#define IPP_VERSION_UPDATE 0
|
||||
#endif
|
||||
|
||||
#define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE)
|
||||
|
||||
// General define for ipp function disabling
|
||||
#define IPP_DISABLE_BLOCK 0
|
||||
|
||||
#ifdef CV_MALLOC_ALIGN
|
||||
#undef CV_MALLOC_ALIGN
|
||||
@@ -234,8 +241,33 @@ static inline IppDataType ippiGetDataType(int depth)
|
||||
depth == CV_64F ? ipp64f : (IppDataType)-1;
|
||||
}
|
||||
|
||||
// IPP temporary buffer hepler
|
||||
template<typename T>
|
||||
class IppAutoBuffer
|
||||
{
|
||||
public:
|
||||
IppAutoBuffer() { m_pBuffer = NULL; }
|
||||
IppAutoBuffer(int size) { Alloc(size); }
|
||||
~IppAutoBuffer() { Release(); }
|
||||
T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
|
||||
void Release() { if(m_pBuffer) ippFree(m_pBuffer); }
|
||||
inline operator T* () { return (T*)m_pBuffer;}
|
||||
inline operator const T* () const { return (const T*)m_pBuffer;}
|
||||
private:
|
||||
// Disable copy operations
|
||||
IppAutoBuffer(IppAutoBuffer &) {};
|
||||
IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;};
|
||||
|
||||
T* m_pBuffer;
|
||||
};
|
||||
|
||||
#else
|
||||
# define IPP_VERSION_X100 0
|
||||
#define IPP_VERSION_X100 0
|
||||
#endif
|
||||
|
||||
// There shoud be no API difference in OpenCV between ICV and IPP since 9.0
|
||||
#if (defined HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 900
|
||||
#undef HAVE_IPP_ICV_ONLY
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP_ICV_ONLY
|
||||
@@ -244,6 +276,42 @@ static inline IppDataType ippiGetDataType(int depth)
|
||||
#define HAVE_ICV 0
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
if(FEAT) \
|
||||
ippSetCpuFeatures(FEAT); \
|
||||
else \
|
||||
ippInit(); \
|
||||
}
|
||||
#elif IPP_VERSION_X100 >= 800
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
ippInit(); \
|
||||
}
|
||||
#else
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
ippStaticInit(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CVAPI_EXPORTS
|
||||
#define IPP_INITIALIZER_AUTO \
|
||||
struct __IppInitializer__ \
|
||||
{ \
|
||||
__IppInitializer__() \
|
||||
{IPP_INITIALIZER(cv::ipp::getIppFeatures())} \
|
||||
}; \
|
||||
static struct __IppInitializer__ __ipp_initializer__;
|
||||
#else
|
||||
#define IPP_INITIALIZER_AUTO
|
||||
#endif
|
||||
#else
|
||||
#define IPP_INITIALIZER
|
||||
#define IPP_INITIALIZER_AUTO
|
||||
#endif
|
||||
|
||||
#define CV_IPP_CHECK_COND (cv::ipp::useIPP())
|
||||
#define CV_IPP_CHECK() if(CV_IPP_CHECK_COND)
|
||||
|
||||
@@ -520,6 +520,7 @@ protected:
|
||||
TLSDataContainer();
|
||||
virtual ~TLSDataContainer();
|
||||
|
||||
void gatherData(std::vector<void*> &data) const;
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
void* getData() const;
|
||||
void release();
|
||||
@@ -546,9 +547,20 @@ public:
|
||||
inline ~TLSData() { release(); } // Release key and delete associated data
|
||||
inline T* get() const { return (T*)getData(); } // Get data assosiated with key
|
||||
|
||||
// Get data from all threads
|
||||
inline void gather(std::vector<T*> &data) const
|
||||
{
|
||||
std::vector<void*> &dataVoid = reinterpret_cast<std::vector<void*>&>(data);
|
||||
gatherData(dataVoid);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void* createDataInstance() const {return new T;} // Wrapper to allocate data by template
|
||||
virtual void deleteDataInstance(void* pData) const {delete (T*)pData;} // Wrapper to release data by template
|
||||
|
||||
// Disable TLS copy operations
|
||||
TLSData(TLSData &) {};
|
||||
TLSData& operator =(const TLSData &) {return *this;};
|
||||
};
|
||||
|
||||
/** @brief Designed for command line parsing
|
||||
@@ -597,7 +609,7 @@ For example:
|
||||
const String keys =
|
||||
"{help h usage ? | | print this message }"
|
||||
"{@image1 | | image1 for compare }"
|
||||
"{@image2 | | image2 for compare }"
|
||||
"{@image2 |<none>| image2 for compare }"
|
||||
"{@repeat |1 | number }"
|
||||
"{path |. | path to file }"
|
||||
"{fps | -1.0 | fps for output video }"
|
||||
@@ -607,6 +619,13 @@ For example:
|
||||
}
|
||||
@endcode
|
||||
|
||||
Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method.
|
||||
Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their
|
||||
actual value instead.
|
||||
|
||||
String keys like `get<String>("@image1")` return the empty string `""` by default - even with an empty default value.
|
||||
Use the special `<none>` default value to enforce that the returned string must not be empty. (like in `get<String>("@image2")`)
|
||||
|
||||
### Usage
|
||||
|
||||
For the described keys:
|
||||
@@ -618,7 +637,7 @@ For the described keys:
|
||||
# Bad call
|
||||
$ ./app -fps=aaa
|
||||
ERRORS:
|
||||
Exception: can not convert: [aaa] to [double]
|
||||
Parameter 'fps': can not convert: [aaa] to [double]
|
||||
@endcode
|
||||
*/
|
||||
class CV_EXPORTS CommandLineParser
|
||||
|
||||
+23
-20
@@ -5,36 +5,36 @@
|
||||
// Copyright (C) 2015, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#ifndef __OPENCV_CORE_VAAPI_HPP__
|
||||
#define __OPENCV_CORE_VAAPI_HPP__
|
||||
#ifndef __OPENCV_CORE_VA_INTEL_HPP__
|
||||
#define __OPENCV_CORE_VA_INTEL_HPP__
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error vaapi.hpp header must be compiled as C++
|
||||
# error va_intel.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "ocl.hpp"
|
||||
|
||||
#if defined(HAVE_VAAPI)
|
||||
#if defined(HAVE_VA)
|
||||
# include "va/va.h"
|
||||
#else // HAVE_VAAPI
|
||||
#else // HAVE_VA
|
||||
# if !defined(_VA_H_)
|
||||
typedef void* VADisplay;
|
||||
typedef unsigned int VASurfaceID;
|
||||
# endif // !_VA_H_
|
||||
#endif // HAVE_VAAPI
|
||||
#endif // HAVE_VA
|
||||
|
||||
namespace cv { namespace vaapi {
|
||||
namespace cv { namespace va_intel {
|
||||
|
||||
/** @addtogroup core_vaapi
|
||||
This section describes CL-VA (VA-API) interoperability.
|
||||
/** @addtogroup core_va_intel
|
||||
This section describes Intel VA-API/OpenCL (CL-VA) interoperability.
|
||||
|
||||
To enable CL-VA interoperability support, configure OpenCV using CMake with WITH_VAAPI=ON . Currently VA-API is
|
||||
To enable CL-VA interoperability support, configure OpenCV using CMake with WITH_VA_INTEL=ON . Currently VA-API is
|
||||
supported on Linux only. You should also install Intel Media Server Studio (MSS) to use this feature. You may
|
||||
have to specify the path(s) to MSS components for cmake in environment variables: VAAPI_MSDK_ROOT for Media SDK
|
||||
(default is "/opt/intel/mediasdk"), and VAAPI_IOCL_ROOT for Intel OpenCL (default is "/opt/intel/opencl").
|
||||
have to specify the path(s) to MSS components for cmake in environment variables: VA_INTEL_MSDK_ROOT for Media SDK
|
||||
(default is "/opt/intel/mediasdk"), and VA_INTEL_IOCL_ROOT for Intel OpenCL (default is "/opt/intel/opencl").
|
||||
|
||||
To use VA-API interoperability you should first create VADisplay (libva), and then call initializeContextFromVA()
|
||||
To use CL-VA interoperability you should first create VADisplay (libva), and then call initializeContextFromVA()
|
||||
function to create OpenCL context and set up interoperability.
|
||||
*/
|
||||
//! @{
|
||||
@@ -46,29 +46,32 @@ using namespace cv::ocl;
|
||||
|
||||
// TODO static functions in the Context class
|
||||
/** @brief Creates OpenCL context from VA.
|
||||
@param display - VADisplay for which CL interop should be established.
|
||||
@param display - VADisplay for which CL interop should be established.
|
||||
@param tryInterop - try to set up for interoperability, if true; set up for use slow copy if false.
|
||||
@return Returns reference to OpenCL Context
|
||||
*/
|
||||
CV_EXPORTS Context& initializeContextFromVA(VADisplay display);
|
||||
CV_EXPORTS Context& initializeContextFromVA(VADisplay display, bool tryInterop = true);
|
||||
|
||||
} // namespace cv::vaapi::ocl
|
||||
} // namespace cv::va_intel::ocl
|
||||
|
||||
/** @brief Converts InputArray to VASurfaceID object.
|
||||
@param display - VADisplay object.
|
||||
@param src - source InputArray.
|
||||
@param surface - destination VASurfaceID object.
|
||||
@param size - size of image represented by VASurfaceID object.
|
||||
*/
|
||||
CV_EXPORTS void convertToVASurface(InputArray src, VASurfaceID surface, Size size);
|
||||
CV_EXPORTS void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size);
|
||||
|
||||
/** @brief Converts VASurfaceID object to OutputArray.
|
||||
@param display - VADisplay object.
|
||||
@param surface - source VASurfaceID object.
|
||||
@param size - size of image represented by VASurfaceID object.
|
||||
@param dst - destination OutputArray.
|
||||
*/
|
||||
CV_EXPORTS void convertFromVASurface(VASurfaceID surface, Size size, OutputArray dst);
|
||||
CV_EXPORTS void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, OutputArray dst);
|
||||
|
||||
//! @}
|
||||
|
||||
}} // namespace cv::vaapi
|
||||
}} // namespace cv::va_intel
|
||||
|
||||
#endif /* __OPENCV_CORE_VAAPI_HPP__ */
|
||||
#endif /* __OPENCV_CORE_VA_INTEL_HPP__ */
|
||||
@@ -1504,7 +1504,7 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
k.args(src1arg, src2arg, maskarg, dstarg);
|
||||
}
|
||||
|
||||
size_t globalsize[] = { src1.cols * cn / kercn, (src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[] = { (size_t)src1.cols * cn / kercn, ((size_t)src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
@@ -1917,7 +1917,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
k.args(src1arg, src2arg, maskarg, dstarg);
|
||||
}
|
||||
|
||||
size_t globalsize[] = { src1.cols * cn / kercn, (src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[] = { (size_t)src1.cols * cn / kercn, ((size_t)src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -4692,7 +4692,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppCmpOp op = convert_cmp(*(int *)_cmpop);
|
||||
if( op > 0 )
|
||||
if( op >= 0 )
|
||||
{
|
||||
fixSteps(size, sizeof(dst[0]), step1, step2, step);
|
||||
if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
|
||||
@@ -4974,7 +4974,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
|
||||
ocl::KernelArg::WriteOnly(dst, cn, kercn));
|
||||
}
|
||||
|
||||
size_t globalsize[2] = { dst.cols * cn / kercn, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols * cn / kercn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -5668,7 +5668,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
|
||||
ker.args(srcarg, dstarg, ocl::KernelArg::ReadOnlyNoSize(lscalaru),
|
||||
ocl::KernelArg::ReadOnlyNoSize(uscalaru), rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { ssize.width / colsPerWI, (ssize.height + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)ssize.width / colsPerWI, ((size_t)ssize.height + rowsPerWI - 1) / rowsPerWI };
|
||||
return ker.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,20 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace {
|
||||
static const char* noneValue = "<none>";
|
||||
|
||||
static String cat_string(const String& str)
|
||||
{
|
||||
int left = 0, right = (int)str.length();
|
||||
while( left <= right && str[left] == ' ' )
|
||||
left++;
|
||||
while( right > left && str[right-1] == ' ' )
|
||||
right--;
|
||||
return left >= right ? String("") : str.substr(left, right-left);
|
||||
}
|
||||
}
|
||||
|
||||
struct CommandLineParserParams
|
||||
{
|
||||
public:
|
||||
@@ -27,7 +41,6 @@ struct CommandLineParser::Impl
|
||||
|
||||
std::vector<String> split_range_string(const String& str, char fs, char ss) const;
|
||||
std::vector<String> split_string(const String& str, char symbol = ' ', bool create_empty_item = false) const;
|
||||
String cat_string(const String& str) const;
|
||||
|
||||
void apply_params(const String& key, const String& value);
|
||||
void apply_params(int i, String value);
|
||||
@@ -37,7 +50,7 @@ struct CommandLineParser::Impl
|
||||
};
|
||||
|
||||
|
||||
static String get_type_name(int type)
|
||||
static const char* get_type_name(int type)
|
||||
{
|
||||
if( type == Param::INT )
|
||||
return "int";
|
||||
@@ -78,14 +91,11 @@ static void from_str(const String& str, int type, void* dst)
|
||||
else if( type == Param::STRING )
|
||||
*(String*)dst = str;
|
||||
else
|
||||
throw cv::Exception(CV_StsBadArg, "unknown/unsupported parameter type", "", __FILE__, __LINE__);
|
||||
CV_Error(Error::StsBadArg, "unknown/unsupported parameter type");
|
||||
|
||||
if (ss.fail())
|
||||
{
|
||||
String err_msg = "can not convert: [" + str +
|
||||
+ "] to [" + get_type_name(type) + "]";
|
||||
|
||||
throw cv::Exception(CV_StsBadArg, err_msg, "", __FILE__, __LINE__);
|
||||
CV_Error_(Error::StsBadArg, ("can not convert: [%s] to [%s]", str.c_str(), get_type_name(type)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,24 +107,33 @@ void CommandLineParser::getByName(const String& name, bool space_delete, int typ
|
||||
{
|
||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(impl->data[i].keys[j]) == 0)
|
||||
if (name == impl->data[i].keys[j])
|
||||
{
|
||||
String v = impl->data[i].def_value;
|
||||
if (space_delete)
|
||||
v = impl->cat_string(v);
|
||||
v = cat_string(v);
|
||||
|
||||
// the key was neither specified nor has it a default value
|
||||
if((v.empty() && type != Param::STRING) || v == noneValue) {
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + "Missing parameter: '" + name + "'\n";
|
||||
return;
|
||||
}
|
||||
|
||||
from_str(v, type, dst);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + "Unknown parameter " + name + "\n";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (Exception& e)
|
||||
{
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + "Exception: " + String(e.what()) + "\n";
|
||||
impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
|
||||
}
|
||||
|
||||
|
||||
@@ -127,19 +146,27 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
|
||||
if (impl->data[i].number == index)
|
||||
{
|
||||
String v = impl->data[i].def_value;
|
||||
if (space_delete == true) v = impl->cat_string(v);
|
||||
if (space_delete == true) v = cat_string(v);
|
||||
|
||||
// the key was neither specified nor has it a default value
|
||||
if((v.empty() && type != Param::STRING) || v == noneValue) {
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + format("Missing parameter #%d\n", index);
|
||||
return;
|
||||
}
|
||||
from_str(v, type, dst);
|
||||
return;
|
||||
}
|
||||
}
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + "Unknown parameter #" + format("%d", index) + "\n";
|
||||
}
|
||||
catch(std::exception & e)
|
||||
catch(Exception& e)
|
||||
{
|
||||
impl->error = true;
|
||||
impl->error_message = impl->error_message + "Exception: " + String(e.what()) + "\n";
|
||||
impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index));
|
||||
}
|
||||
|
||||
static bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2)
|
||||
@@ -184,7 +211,7 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const S
|
||||
CommandLineParserParams p;
|
||||
p.keys = impl->split_string(l[0]);
|
||||
p.def_value = l[1];
|
||||
p.help_message = impl->cat_string(l[2]);
|
||||
p.help_message = cat_string(l[2]);
|
||||
p.number = -1;
|
||||
if (p.keys.size() <= 0)
|
||||
{
|
||||
@@ -207,25 +234,21 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const S
|
||||
jj = 0;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
String s = String(argv[i]);
|
||||
String s(argv[i]);
|
||||
bool hasSingleDash = s.length() > 1 && s[0] == '-';
|
||||
|
||||
if (s.find('=') != String::npos && s.find('=') < s.length())
|
||||
if (hasSingleDash)
|
||||
{
|
||||
std::vector<String> k_v = impl->split_string(s, '=', true);
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (k_v[0][0] == '-')
|
||||
k_v[0] = k_v[0].substr(1, k_v[0].length() -1);
|
||||
bool hasDoubleDash = s.length() > 2 && s[1] == '-';
|
||||
String key = s.substr(hasDoubleDash ? 2 : 1);
|
||||
String value = "true";
|
||||
size_t equalsPos = key.find('=');
|
||||
|
||||
if(equalsPos != String::npos) {
|
||||
value = key.substr(equalsPos + 1);
|
||||
key = key.substr(0, equalsPos);
|
||||
}
|
||||
impl->apply_params(k_v[0], k_v[1]);
|
||||
}
|
||||
else if (s.length() > 2 && s[0] == '-' && s[1] == '-')
|
||||
{
|
||||
impl->apply_params(s.substr(2), "true");
|
||||
}
|
||||
else if (s.length() > 1 && s[0] == '-')
|
||||
{
|
||||
impl->apply_params(s.substr(1), "true");
|
||||
impl->apply_params(key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,16 +326,6 @@ void CommandLineParser::Impl::sort_params()
|
||||
std::sort (data.begin(), data.end(), cmp_params);
|
||||
}
|
||||
|
||||
String CommandLineParser::Impl::cat_string(const String& str) const
|
||||
{
|
||||
int left = 0, right = (int)str.length();
|
||||
while( left <= right && str[left] == ' ' )
|
||||
left++;
|
||||
while( right > left && str[right-1] == ' ' )
|
||||
right--;
|
||||
return left >= right ? String("") : str.substr(left, right-left);
|
||||
}
|
||||
|
||||
String CommandLineParser::getPathToApplication() const
|
||||
{
|
||||
return impl->path_to_app;
|
||||
@@ -324,12 +337,15 @@ bool CommandLineParser::has(const String& name) const
|
||||
{
|
||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(impl->data[i].keys[j]) == 0 && String("true").compare(impl->data[i].def_value) == 0)
|
||||
if (name == impl->data[i].keys[j])
|
||||
{
|
||||
return true;
|
||||
const String v = cat_string(impl->data[i].def_value);
|
||||
return !v.empty() && v != noneValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -388,7 +404,7 @@ void CommandLineParser::printMessage() const
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
String dv = impl->cat_string(impl->data[i].def_value);
|
||||
String dv = cat_string(impl->data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
printf(" (value:%s)", dv.c_str());
|
||||
@@ -408,7 +424,7 @@ void CommandLineParser::printMessage() const
|
||||
|
||||
printf("%s", k.c_str());
|
||||
|
||||
String dv = impl->cat_string(impl->data[i].def_value);
|
||||
String dv = cat_string(impl->data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
printf(" (value:%s)", dv.c_str());
|
||||
|
||||
@@ -902,7 +902,7 @@ static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv )
|
||||
argidx = k.set(argidx, ocl::KernelArg::WriteOnlyNoSize(dst[i]));
|
||||
k.set(argidx, rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { size.width, (size.height + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)size.width, ((size_t)size.height + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1069,7 +1069,7 @@ static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst )
|
||||
argidx = k.set(argidx, ocl::KernelArg::WriteOnly(dst));
|
||||
k.set(argidx, rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { dst.cols, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1338,7 +1338,7 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d
|
||||
argindex = k.set(argindex, size.width);
|
||||
k.set(argindex, rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { size.width, (size.height + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)size.width, ((size_t)size.height + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -5505,7 +5505,7 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
|
||||
else if (wdepth == CV_64F)
|
||||
k.args(srcarg, dstarg, alpha, beta);
|
||||
|
||||
size_t globalsize[2] = { src.cols * cn / kercn, (src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)src.cols * cn / kercn, ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -5673,7 +5673,7 @@ static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst)
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::ReadOnlyNoSize(lut),
|
||||
ocl::KernelArg::WriteOnly(dst, dcn, kercn));
|
||||
|
||||
size_t globalSize[2] = { dst.cols * dcn / kercn, (dst.rows + 3) / 4 };
|
||||
size_t globalSize[2] = { (size_t)dst.cols * dcn / kercn, ((size_t)dst.rows + 3) / 4 };
|
||||
return k.run(2, globalSize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -5682,7 +5682,7 @@ static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst)
|
||||
#if defined(HAVE_IPP)
|
||||
namespace ipp {
|
||||
|
||||
#if 0 // there are no performance benefits (PR #2653)
|
||||
#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
|
||||
class IppLUTParallelBody_LUTC1 : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
@@ -5850,7 +5850,7 @@ static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
|
||||
Ptr<ParallelLoopBody> body;
|
||||
|
||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
#if 0 // there are no performance benefits (PR #2653)
|
||||
#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
|
||||
if (lutcn == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
||||
@@ -6053,7 +6053,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m
|
||||
k.args(srcarg, maskarg, dstarg);
|
||||
}
|
||||
|
||||
size_t globalsize[2] = { src.cols, (src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)src.cols, ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -377,7 +377,7 @@ Mat& Mat::operator = (const Scalar& s)
|
||||
|
||||
if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 )
|
||||
{
|
||||
#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY && 0
|
||||
#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (dims <= 2 || isContinuous())
|
||||
@@ -692,7 +692,7 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode )
|
||||
size_t maxWorkGroupSize = dev.maxWorkGroupSize();
|
||||
CV_Assert(maxWorkGroupSize % 4 == 0);
|
||||
|
||||
size_t globalsize[2] = { cols, (rows + pxPerWIy - 1) / pxPerWIy },
|
||||
size_t globalsize[2] = { (size_t)cols, ((size_t)rows + pxPerWIy - 1) / pxPerWIy },
|
||||
localsize[2] = { maxWorkGroupSize / 4, 4 };
|
||||
return k.run(2, globalsize, (flipType == FLIP_COLS) && !dev.isIntel() ? localsize : NULL, false);
|
||||
}
|
||||
@@ -833,7 +833,7 @@ static bool ocl_repeat(InputArray _src, int ny, int nx, OutputArray _dst)
|
||||
UMat src = _src.getUMat(), dst = _dst.getUMat();
|
||||
k.args(ocl::KernelArg::ReadOnly(src, cn, kercn), ocl::KernelArg::WriteOnlyNoSize(dst));
|
||||
|
||||
size_t globalsize[] = { src.cols * cn / kercn, (src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[] = { (size_t)src.cols * cn / kercn, ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,7 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int
|
||||
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst),
|
||||
top, left, ocl::KernelArg::Constant(Mat(1, 1, sctype, value)));
|
||||
|
||||
size_t globalsize[2] = { dst.cols, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1157,7 +1157,7 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
|
||||
|
||||
borderType &= ~BORDER_ISOLATED;
|
||||
|
||||
#if defined HAVE_IPP && 0
|
||||
#if defined HAVE_IPP && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst,
|
||||
|
||||
@@ -352,6 +352,7 @@ CV_IMPL CvString
|
||||
cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len )
|
||||
{
|
||||
CvString str;
|
||||
memset(&str, 0, sizeof(CvString));
|
||||
|
||||
str.len = len >= 0 ? len : (int)strlen(ptr);
|
||||
str.ptr = (char*)cvMemStorageAlloc( storage, str.len + 1 );
|
||||
@@ -1694,6 +1695,9 @@ cvSeqRemoveSlice( CvSeq* seq, CvSlice slice )
|
||||
|
||||
slice.end_index = slice.start_index + length;
|
||||
|
||||
if ( slice.start_index == slice.end_index )
|
||||
return;
|
||||
|
||||
if( slice.end_index < total )
|
||||
{
|
||||
CvSeqReader reader_to, reader_from;
|
||||
|
||||
@@ -729,7 +729,7 @@ bool ocl_convert_nv12_to_bgr(
|
||||
|
||||
k.args(clImageY, clImageUV, clBuffer, step, cols, rows);
|
||||
|
||||
size_t globalsize[] = { cols, rows };
|
||||
size_t globalsize[] = { (size_t)cols, (size_t)rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ bool ocl_convert_bgr_to_nv12(
|
||||
|
||||
k.args(clBuffer, step, cols, rows, clImageY, clImageUV);
|
||||
|
||||
size_t globalsize[] = { cols, rows };
|
||||
size_t globalsize[] = { (size_t)cols, (size_t)rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D)
|
||||
{
|
||||
size_t offset = 0; // TODO
|
||||
size_t origin[3] = { 0, 0, 0 };
|
||||
size_t region[3] = { u.cols, u.rows, 1 };
|
||||
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1 };
|
||||
|
||||
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, origin, region, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
@@ -939,7 +939,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst
|
||||
{
|
||||
size_t offset = 0; // TODO
|
||||
size_t origin[3] = { 0, 0, 0 };
|
||||
size_t region[3] = { u.cols, u.rows, 1 };
|
||||
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1 };
|
||||
|
||||
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, origin, region, offset, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
@@ -1041,7 +1041,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
size_t dst_origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {u.cols, u.rows, 1};
|
||||
size_t region[3] = {(size_t)u.cols, (size_t)u.rows, 1};
|
||||
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
@@ -1100,7 +1100,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
size_t src_origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {u.cols, u.rows, 1};
|
||||
size_t region[3] = {(size_t)u.cols, (size_t)u.rows, 1};
|
||||
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
@@ -1195,7 +1195,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
size_t dst_origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {u.cols, u.rows, 1};
|
||||
size_t region[3] = {(size_t)u.cols, (size_t)u.rows, 1};
|
||||
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
@@ -1261,7 +1261,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
size_t src_origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {u.cols, u.rows, 1};
|
||||
size_t region[3] = {(size_t)u.cols, (size_t)u.rows, 1};
|
||||
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
|
||||
+163
-46
@@ -54,7 +54,7 @@ namespace cv
|
||||
# pragma warning(disable: 4748)
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 701
|
||||
#if IPP_VERSION_X100 >= 710
|
||||
#define USE_IPP_DFT 1
|
||||
#else
|
||||
#undef USE_IPP_DFT
|
||||
@@ -2934,7 +2934,7 @@ static bool ocl_mulSpectrums( InputArray _srcA, InputArray _srcB,
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(A), ocl::KernelArg::ReadOnlyNoSize(B),
|
||||
ocl::KernelArg::WriteOnly(dst), rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { asize.width, (asize.height + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)asize.width, ((size_t)asize.height + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -3318,28 +3318,102 @@ static void IDCT_64f(const double* src, int src_step, double* dft_src, double* d
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7
|
||||
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTFunc)(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, const void* pDCTSpec, Ipp8u* pBuffer);
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTInit)(void* pDCTSpec, IppiSize roiSize, Ipp8u* pMemInit );
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTGetSize)(IppiSize roiSize, int* pSizeSpec, int* pSizeInit, int* pSizeBuf);
|
||||
#elif IPP_VERSION_X100 >= 700
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTFunc)(const Ipp32f*, int, Ipp32f*, int, const void*, Ipp8u*);
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTInitAlloc)(void**, IppiSize, IppHintAlgorithm);
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTFree)(void* pDCTSpec);
|
||||
typedef IppStatus (CV_STDCALL * ippiDCTGetBufSize)(const void*, int*);
|
||||
#endif
|
||||
|
||||
template <typename Dct>
|
||||
class DctIPPLoop_Invoker : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
|
||||
DctIPPLoop_Invoker(const Mat& _src, Mat& _dst, const Dct* _ippidct, bool _inv, bool *_ok) :
|
||||
ParallelLoopBody(), src(&_src), dst(&_dst), ippidct(_ippidct), inv(_inv), ok(_ok)
|
||||
DctIPPLoop_Invoker(const Mat& _src, Mat& _dst, bool _inv, bool *_ok) :
|
||||
ParallelLoopBody(), src(&_src), dst(&_dst), inv(_inv), ok(_ok)
|
||||
{
|
||||
*ok = true;
|
||||
}
|
||||
|
||||
virtual void operator()(const Range& range) const
|
||||
{
|
||||
if(*ok == false)
|
||||
return;
|
||||
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
IppiSize srcRoiSize = {src->cols, 1};
|
||||
|
||||
int specSize = 0;
|
||||
int initSize = 0;
|
||||
int bufferSize = 0;
|
||||
|
||||
Ipp8u* pDCTSpec = NULL;
|
||||
Ipp8u* pBuffer = NULL;
|
||||
Ipp8u* pInitBuf = NULL;
|
||||
|
||||
#define IPP_RETURN \
|
||||
if(pDCTSpec) \
|
||||
ippFree(pDCTSpec); \
|
||||
if(pBuffer) \
|
||||
ippFree(pBuffer); \
|
||||
if(pInitBuf) \
|
||||
ippFree(pInitBuf); \
|
||||
return;
|
||||
|
||||
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
|
||||
ippiDCTInit ippDctInit = inv ? (ippiDCTInit)ippiDCTInvInit_32f : (ippiDCTInit)ippiDCTFwdInit_32f;
|
||||
ippiDCTGetSize ippDctGetSize = inv ? (ippiDCTGetSize)ippiDCTInvGetSize_32f : (ippiDCTGetSize)ippiDCTFwdGetSize_32f;
|
||||
|
||||
if(ippDctGetSize(srcRoiSize, &specSize, &initSize, &bufferSize) < 0)
|
||||
{
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
pDCTSpec = (Ipp8u*)ippMalloc(specSize);
|
||||
if(!pDCTSpec && specSize)
|
||||
{
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufferSize);
|
||||
if(!pBuffer && bufferSize)
|
||||
{
|
||||
*ok = false;
|
||||
IPP_RETURN
|
||||
}
|
||||
pInitBuf = (Ipp8u*)ippMalloc(initSize);
|
||||
if(!pInitBuf && initSize)
|
||||
{
|
||||
*ok = false;
|
||||
IPP_RETURN
|
||||
}
|
||||
|
||||
if(ippDctInit(pDCTSpec, srcRoiSize, pInitBuf) < 0)
|
||||
{
|
||||
*ok = false;
|
||||
IPP_RETURN
|
||||
}
|
||||
|
||||
for(int i = range.start; i < range.end; ++i)
|
||||
{
|
||||
if(ippDctFun(src->ptr<float>(i), (int)src->step,dst->ptr<float>(i), (int)dst->step, pDCTSpec, pBuffer) < 0)
|
||||
{
|
||||
*ok = false;
|
||||
IPP_RETURN
|
||||
}
|
||||
}
|
||||
IPP_RETURN
|
||||
#undef IPP_RETURN
|
||||
#elif IPP_VERSION_X100 >= 700
|
||||
void* pDCTSpec;
|
||||
AutoBuffer<uchar> buf;
|
||||
uchar* pBuffer = 0;
|
||||
@@ -3349,6 +3423,7 @@ public:
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
|
||||
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
|
||||
ippiDCTInitAlloc ippInitAlloc = inv ? (ippiDCTInitAlloc)ippiDCTInvInitAlloc_32f : (ippiDCTInitAlloc)ippiDCTFwdInitAlloc_32f;
|
||||
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
||||
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
||||
@@ -3359,8 +3434,13 @@ public:
|
||||
pBuffer = (uchar*)buf;
|
||||
|
||||
for( int i = range.start; i < range.end; ++i)
|
||||
if(!(*ippidct)(src->ptr<float>(i), (int)src->step,dst->ptr<float>(i), (int)dst->step, pDCTSpec, (Ipp8u*)pBuffer))
|
||||
{
|
||||
if(ippDctFun(src->ptr<float>(i), (int)src->step,dst->ptr<float>(i), (int)dst->step, pDCTSpec, (Ipp8u*)pBuffer) < 0)
|
||||
{
|
||||
*ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
*ok = false;
|
||||
@@ -3369,44 +3449,91 @@ public:
|
||||
ippFree(pDCTSpec);
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
#else
|
||||
CV_UNUSED(range);
|
||||
*ok = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat* src;
|
||||
Mat* dst;
|
||||
const Dct* ippidct;
|
||||
bool inv;
|
||||
bool *ok;
|
||||
};
|
||||
|
||||
template <typename Dct>
|
||||
bool DctIPPLoop(const Mat& src, Mat& dst, const Dct& ippidct, bool inv)
|
||||
static bool DctIPPLoop(const Mat& src, Mat& dst, bool inv)
|
||||
{
|
||||
bool ok;
|
||||
parallel_for_(Range(0, src.rows), DctIPPLoop_Invoker<Dct>(src, dst, &ippidct, inv, &ok), src.rows/(double)(1<<4) );
|
||||
parallel_for_(Range(0, src.rows), DctIPPLoop_Invoker(src, dst, inv, &ok), src.rows/(double)(1<<4) );
|
||||
return ok;
|
||||
}
|
||||
|
||||
struct IPPDCTFunctor
|
||||
{
|
||||
IPPDCTFunctor(ippiDCTFunc _func) : func(_func){}
|
||||
|
||||
bool operator()(const Ipp32f* src, int srcStep, Ipp32f* dst, int dstStep, const void* pDCTSpec, Ipp8u* pBuffer) const
|
||||
{
|
||||
return func ? func(src, srcStep, dst, dstStep, pDCTSpec, pBuffer) >= 0 : false;
|
||||
}
|
||||
private:
|
||||
ippiDCTFunc func;
|
||||
};
|
||||
|
||||
static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
||||
{
|
||||
ippiDCTFunc ippFunc = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R ;
|
||||
|
||||
if (row)
|
||||
return(DctIPPLoop(src,dst,IPPDCTFunctor(ippFunc),inv));
|
||||
if(row)
|
||||
return DctIPPLoop(src, dst, inv);
|
||||
else
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
IppiSize srcRoiSize = {src.cols, src.rows};
|
||||
|
||||
int specSize = 0;
|
||||
int initSize = 0;
|
||||
int bufferSize = 0;
|
||||
|
||||
Ipp8u* pDCTSpec = NULL;
|
||||
Ipp8u* pBuffer = NULL;
|
||||
Ipp8u* pInitBuf = NULL;
|
||||
|
||||
#define IPP_RELEASE \
|
||||
if(pDCTSpec) \
|
||||
ippFree(pDCTSpec); \
|
||||
if(pBuffer) \
|
||||
ippFree(pBuffer); \
|
||||
if(pInitBuf) \
|
||||
ippFree(pInitBuf); \
|
||||
|
||||
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
|
||||
ippiDCTInit ippDctInit = inv ? (ippiDCTInit)ippiDCTInvInit_32f : (ippiDCTInit)ippiDCTFwdInit_32f;
|
||||
ippiDCTGetSize ippDctGetSize = inv ? (ippiDCTGetSize)ippiDCTInvGetSize_32f : (ippiDCTGetSize)ippiDCTFwdGetSize_32f;
|
||||
|
||||
if(ippDctGetSize(srcRoiSize, &specSize, &initSize, &bufferSize) < 0)
|
||||
return false;
|
||||
|
||||
pDCTSpec = (Ipp8u*)ippMalloc(specSize);
|
||||
if(!pDCTSpec && specSize)
|
||||
return false;
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufferSize);
|
||||
if(!pBuffer && bufferSize)
|
||||
{
|
||||
IPP_RELEASE
|
||||
return false;
|
||||
}
|
||||
pInitBuf = (Ipp8u*)ippMalloc(initSize);
|
||||
if(!pInitBuf && initSize)
|
||||
{
|
||||
IPP_RELEASE
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ippDctInit(pDCTSpec, srcRoiSize, pInitBuf) < 0)
|
||||
{
|
||||
IPP_RELEASE
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ippDctFun(src.ptr<float>(), (int)src.step,dst.ptr<float>(), (int)dst.step, pDCTSpec, pBuffer) < 0)
|
||||
{
|
||||
IPP_RELEASE
|
||||
return false;
|
||||
}
|
||||
|
||||
IPP_RELEASE
|
||||
return true;
|
||||
#undef IPP_RELEASE
|
||||
#elif IPP_VERSION_X100 >= 700
|
||||
IppStatus status;
|
||||
void* pDCTSpec;
|
||||
AutoBuffer<uchar> buf;
|
||||
@@ -3417,6 +3544,7 @@ static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
|
||||
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
|
||||
ippiDCTInitAlloc ippInitAlloc = inv ? (ippiDCTInitAlloc)ippiDCTInvInitAlloc_32f : (ippiDCTInitAlloc)ippiDCTFwdInitAlloc_32f;
|
||||
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
||||
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
||||
@@ -3428,7 +3556,7 @@ static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
||||
buf.allocate( bufSize );
|
||||
pBuffer = (uchar*)buf;
|
||||
|
||||
status = ippFunc(src.ptr<float>(), (int)src.step, dst.ptr<float>(), (int)dst.step, pDCTSpec, (Ipp8u*)pBuffer);
|
||||
status = ippDctFun(src.ptr<float>(), (int)src.step, dst.ptr<float>(), (int)dst.step, pDCTSpec, (Ipp8u*)pBuffer);
|
||||
}
|
||||
|
||||
if (pDCTSpec)
|
||||
@@ -3437,11 +3565,14 @@ static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
return status >= 0;
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(inv); CV_UNUSED(row);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::dct( InputArray _src0, OutputArray _dst, int flags )
|
||||
{
|
||||
@@ -3473,21 +3604,7 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags )
|
||||
_dst.create( src.rows, src.cols, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool row = (flags & DCT_ROWS) != 0;
|
||||
if (src.type() == CV_32F)
|
||||
{
|
||||
if(ippi_DCT_32f(src,dst,inv, row))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700 && src.type() == CV_32F, ippi_DCT_32f(src, dst, inv, ((flags & DCT_ROWS) != 0)))
|
||||
|
||||
DCTFunc dct_func = dct_tbl[(int)inv + (depth == CV_64F)*2];
|
||||
|
||||
|
||||
@@ -937,9 +937,9 @@ public:
|
||||
// Linear Discriminant Analysis implementation
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
LDA::LDA(int num_components) : _num_components(num_components) { }
|
||||
LDA::LDA(int num_components) : _dataAsRow(true), _num_components(num_components) { }
|
||||
|
||||
LDA::LDA(InputArrayOfArrays src, InputArray labels, int num_components) : _num_components(num_components)
|
||||
LDA::LDA(InputArrayOfArrays src, InputArray labels, int num_components) : _dataAsRow(true), _num_components(num_components)
|
||||
{
|
||||
this->compute(src, labels); //! compute eigenvectors and eigenvalues
|
||||
}
|
||||
@@ -1106,14 +1106,14 @@ void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
|
||||
}
|
||||
}
|
||||
|
||||
// Projects samples into the LDA subspace.
|
||||
// Projects one or more row aligned samples into the LDA subspace.
|
||||
Mat LDA::project(InputArray src) {
|
||||
return subspaceProject(_eigenvectors, Mat(), _dataAsRow ? src : src.getMat().t());
|
||||
return subspaceProject(_eigenvectors, Mat(), src);
|
||||
}
|
||||
|
||||
// Reconstructs projections from the LDA subspace.
|
||||
// Reconstructs projections from the LDA subspace from one or more row aligned samples.
|
||||
Mat LDA::reconstruct(InputArray src) {
|
||||
return subspaceReconstruct(_eigenvectors, Mat(), _dataAsRow ? src : src.getMat().t());
|
||||
return subspaceReconstruct(_eigenvectors, Mat(), src);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static bool ocl_math_op(InputArray _src1, InputArray _src2, OutputArray _dst, in
|
||||
else
|
||||
k.args(src1arg, src2arg, dstarg);
|
||||
|
||||
size_t globalsize[] = { src1.cols * cn / kercn, (src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[] = { (size_t)src1.cols * cn / kercn, ((size_t)src1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ static bool ocl_cartToPolar( InputArray _src1, InputArray _src2,
|
||||
ocl::KernelArg::WriteOnly(dst1, cn),
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst2));
|
||||
|
||||
size_t globalsize[2] = { dst1.cols * cn, (dst1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst1.cols * cn, ((size_t)dst1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle,
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(mag), ocl::KernelArg::ReadOnlyNoSize(angle),
|
||||
ocl::KernelArg::WriteOnly(dst1, cn), ocl::KernelArg::WriteOnlyNoSize(dst2));
|
||||
|
||||
size_t globalsize[2] = { dst1.cols * cn, (dst1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst1.cols * cn, ((size_t)dst1.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1181,8 +1181,8 @@ iPow_i( const T* src, T* dst, int len, int power )
|
||||
{
|
||||
T tab[5] =
|
||||
{
|
||||
power == -1 ? saturate_cast<T>(-1) : 0, (power & 1) ? -1 : 1,
|
||||
std::numeric_limits<T>::max(), 1, power == -1 ? 1 : 0
|
||||
saturate_cast<T>(power == -1 ? -1 : 0), saturate_cast<T>((power & 1) ? -1 : 1),
|
||||
std::numeric_limits<T>::max(), 1, saturate_cast<T>(power == -1 ? 1 : 0)
|
||||
};
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
@@ -1349,7 +1349,7 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst,
|
||||
k.args(srcarg, dstarg, power);
|
||||
}
|
||||
|
||||
size_t globalsize[2] = { dst.cols * cn, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols * cn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -1734,7 +1734,7 @@ static bool ocl_patchNaNs( InputOutputArray _a, float value )
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(a),
|
||||
ocl::KernelArg::WriteOnly(a, cn), (float)value);
|
||||
|
||||
size_t globalsize[2] = { a.cols * cn, (a.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)a.cols * cn, ((size_t)a.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -859,8 +859,8 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
|
||||
ocl::KernelArg::ReadWrite(D, cn, kercn),
|
||||
sizeA.width, (float)alpha, (float)beta);
|
||||
|
||||
size_t globalsize[2] = { sizeD.width * cn / kercn, sizeD.height};
|
||||
size_t localsize[2] = { block_size, block_size};
|
||||
size_t globalsize[2] = { (size_t)sizeD.width * cn / kercn, (size_t)sizeD.height};
|
||||
size_t localsize[2] = { (size_t)block_size, (size_t)block_size};
|
||||
return k.run(2, globalsize, block_size!=1 ? localsize : NULL, false);
|
||||
}
|
||||
#endif
|
||||
@@ -2304,7 +2304,7 @@ static bool ocl_scaleAdd( InputArray _src1, double alpha, InputArray _src2, Outp
|
||||
else
|
||||
k.args(src1arg, src2arg, dstarg, alpha);
|
||||
|
||||
size_t globalsize[2] = { dst.cols * cn / kercn, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols * cn / kercn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -2916,7 +2916,7 @@ dotProd_(const T* src1, const T* src2, int len)
|
||||
static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
|
||||
{
|
||||
double r = 0;
|
||||
#if ARITHM_USE_IPP && 0
|
||||
#if ARITHM_USE_IPP && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (0 <= ippiDotProd_8u64f_C1R(src1, (int)(len*sizeof(src1[0])),
|
||||
@@ -3131,7 +3131,7 @@ static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
|
||||
|
||||
static double dotProd_16s(const short* src1, const short* src2, int len)
|
||||
{
|
||||
#if (ARITHM_USE_IPP == 1)
|
||||
#if (ARITHM_USE_IPP == 1) && (IPP_VERSION_X100 != 900) // bug in IPP 9.0.0
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
double r = 0;
|
||||
|
||||
@@ -1583,12 +1583,12 @@ void MatOp_Initializer::multiply(const MatExpr& e, double s, MatExpr& res) const
|
||||
|
||||
inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int type, double alpha)
|
||||
{
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(sz, type, (void*)0xEEEEEEEE), Mat(), Mat(), alpha, 0);
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(sz, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0);
|
||||
}
|
||||
|
||||
inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha)
|
||||
{
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(ndims, sizes, type, (void*)0xEEEEEEEE), Mat(), Mat(), alpha, 0);
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(ndims, sizes, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+90
-87
@@ -208,17 +208,14 @@ public:
|
||||
if(!u)
|
||||
return;
|
||||
|
||||
CV_Assert(u->urefcount >= 0);
|
||||
CV_Assert(u->refcount >= 0);
|
||||
if(u->refcount == 0)
|
||||
CV_Assert(u->urefcount == 0);
|
||||
CV_Assert(u->refcount == 0);
|
||||
if( !(u->flags & UMatData::USER_ALLOCATED) )
|
||||
{
|
||||
if( !(u->flags & UMatData::USER_ALLOCATED) )
|
||||
{
|
||||
fastFree(u->origdata);
|
||||
u->origdata = 0;
|
||||
}
|
||||
delete u;
|
||||
fastFree(u->origdata);
|
||||
u->origdata = 0;
|
||||
}
|
||||
delete u;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2834,7 +2831,7 @@ static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s )
|
||||
k.args(ocl::KernelArg::WriteOnly(m, cn, kercn),
|
||||
ocl::KernelArg::Constant(Mat(1, 1, sctype, s)));
|
||||
|
||||
size_t globalsize[2] = { m.cols * cn / kercn, (m.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)m.cols * cn / kercn, ((size_t)m.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -3074,7 +3071,7 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst )
|
||||
ocl::KernelArg::WriteOnlyNoSize(dst));
|
||||
|
||||
size_t localsize[2] = { TILE_DIM, BLOCK_ROWS };
|
||||
size_t globalsize[2] = { src.cols, inplace ? (src.rows + rowsPerWI - 1) / rowsPerWI : (divUp(src.rows, TILE_DIM) * BLOCK_ROWS) };
|
||||
size_t globalsize[2] = { (size_t)src.cols, inplace ? ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI : (divUp((size_t)src.rows, TILE_DIM) * BLOCK_ROWS) };
|
||||
|
||||
if (inplace && dev.isIntel())
|
||||
{
|
||||
@@ -3370,22 +3367,20 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst );
|
||||
#define reduceMinR32f reduceR_<float, float, OpMin<float> >
|
||||
#define reduceMinR64f reduceR_<double,double,OpMin<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
|
||||
static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
#ifdef HAVE_IPP
|
||||
static inline bool ipp_reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
{
|
||||
cv::Size size = srcmat.size();
|
||||
IppiSize roisize = { size.width, 1 };
|
||||
int sstep = (int)srcmat.step, stype = srcmat.type(),
|
||||
sdepth = CV_MAT_DEPTH(stype), ddepth = dstmat.depth();
|
||||
ddepth = dstmat.depth();
|
||||
|
||||
IppiSize roisize = { srcmat.size().width, 1 };
|
||||
|
||||
typedef IppStatus (CV_STDCALL * ippiSum)(const void * pSrc, int srcStep, IppiSize roiSize, Ipp64f* pSum);
|
||||
typedef IppStatus (CV_STDCALL * ippiSumHint)(const void * pSrc, int srcStep, IppiSize roiSize, Ipp64f* pSum, IppHintAlgorithm hint);
|
||||
ippiSum ippFunc = 0;
|
||||
ippiSumHint ippFuncHint = 0;
|
||||
cv::ReduceFunc func = 0;
|
||||
|
||||
if (ddepth == CV_64F)
|
||||
if(ddepth == CV_64F)
|
||||
{
|
||||
ippFunc =
|
||||
stype == CV_8UC1 ? (ippiSum)ippiSum_8u_C1R :
|
||||
@@ -3401,41 +3396,46 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
stype == CV_32FC1 ? (ippiSumHint)ippiSum_32f_C1R :
|
||||
stype == CV_32FC3 ? (ippiSumHint)ippiSum_32f_C3R :
|
||||
stype == CV_32FC4 ? (ippiSumHint)ippiSum_32f_C4R : 0;
|
||||
}
|
||||
|
||||
if(ippFunc)
|
||||
{
|
||||
for(int y = 0; y < srcmat.size().height; y++)
|
||||
{
|
||||
if(ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(ippFuncHint)
|
||||
{
|
||||
for(int y = 0; y < srcmat.size().height; y++)
|
||||
{
|
||||
if(ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
{
|
||||
CV_IPP_RUN(true, ipp_reduceSumC_8u16u16s32f_64f(srcmat, dstmat));
|
||||
|
||||
cv::ReduceFunc func = 0;
|
||||
|
||||
if(dstmat.depth() == CV_64F)
|
||||
{
|
||||
int sdepth = CV_MAT_DEPTH(srcmat.type());
|
||||
func =
|
||||
sdepth == CV_8U ? (cv::ReduceFunc)cv::reduceC_<uchar, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_16U ? (cv::ReduceFunc)cv::reduceC_<ushort, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_16S ? (cv::ReduceFunc)cv::reduceC_<short, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_32F ? (cv::ReduceFunc)cv::reduceC_<float, double, cv::OpAdd<double> > : 0;
|
||||
}
|
||||
CV_Assert(!(ippFunc && ippFuncHint) && func);
|
||||
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (ippFunc)
|
||||
{
|
||||
for (int y = 0; y < size.height; ++y)
|
||||
if (ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
|
||||
func(srcmat.rowRange(y, y + 1), dstroi);
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
else if (ippFuncHint)
|
||||
{
|
||||
for (int y = 0; y < size.height; ++y)
|
||||
if (ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
|
||||
func(srcmat.rowRange(y, y + 1), dstroi);
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CV_Assert(func);
|
||||
|
||||
func(srcmat, dstmat);
|
||||
}
|
||||
@@ -3449,7 +3449,7 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
#define reduceSumC32f32f reduceC_<float, float, OpAdd<float> >
|
||||
#define reduceSumC64f64f reduceC_<double,double,OpAdd<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define reduceSumC8u64f reduceSumC_8u16u16s32f_64f
|
||||
#define reduceSumC16u64f reduceSumC_8u16u16s32f_64f
|
||||
#define reduceSumC16s64f reduceSumC_8u16u16s32f_64f
|
||||
@@ -3461,35 +3461,32 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
#define reduceSumC32f64f reduceC_<float, double,OpAdd<double> >
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define REDUCE_OP(favor, optype, type1, type2) \
|
||||
static inline bool ipp_reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstmat) \
|
||||
{ \
|
||||
if((srcmat.channels() == 1)) \
|
||||
{ \
|
||||
int sstep = (int)srcmat.step; \
|
||||
typedef Ipp##favor IppType; \
|
||||
IppiSize roisize = ippiSize(srcmat.size().width, 1);\
|
||||
for(int y = 0; y < srcmat.size().height; y++)\
|
||||
{\
|
||||
if(ippi##optype##_##favor##_C1R(srcmat.ptr<IppType>(y), sstep, roisize, dstmat.ptr<IppType>(y)) < 0)\
|
||||
return false;\
|
||||
}\
|
||||
return true;\
|
||||
}\
|
||||
return false; \
|
||||
} \
|
||||
static inline void reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstmat) \
|
||||
{ \
|
||||
typedef Ipp##favor IppType; \
|
||||
cv::Size size = srcmat.size(); \
|
||||
IppiSize roisize = ippiSize(size.width, 1);\
|
||||
int sstep = (int)srcmat.step; \
|
||||
\
|
||||
if (CV_IPP_CHECK_COND && (srcmat.channels() == 1)) \
|
||||
{ \
|
||||
for (int y = 0; y < size.height; ++y) \
|
||||
if (ippi##optype##_##favor##_C1R(srcmat.ptr<IppType>(y), sstep, roisize, dstmat.ptr<IppType>(y)) < 0) \
|
||||
{ \
|
||||
setIppErrorStatus(); \
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1); \
|
||||
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat.rowRange(y, y + 1), dstroi); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);\
|
||||
} \
|
||||
return; \
|
||||
} \
|
||||
CV_IPP_RUN(true, ipp_reduce##optype##C##favor(srcmat, dstmat)); \
|
||||
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat, dstmat); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
REDUCE_OP(8u, Max, uchar, uchar)
|
||||
REDUCE_OP(16u, Max, ushort, ushort)
|
||||
REDUCE_OP(16s, Max, short, short)
|
||||
@@ -3502,7 +3499,7 @@ REDUCE_OP(32f, Max, float, float)
|
||||
#endif
|
||||
#define reduceMaxC64f reduceC_<double,double,OpMax<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
REDUCE_OP(8u, Min, uchar, uchar)
|
||||
REDUCE_OP(16u, Min, ushort, ushort)
|
||||
REDUCE_OP(16s, Min, short, short)
|
||||
@@ -3579,8 +3576,8 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
|
||||
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 };
|
||||
size_t localSize[2] = { (size_t)buf_cols, (size_t)tileHeight};
|
||||
size_t globalSize[2] = { (size_t)buf_cols, (size_t)src.rows };
|
||||
return k.run(2, globalSize, localSize, false);
|
||||
}
|
||||
else
|
||||
@@ -3775,7 +3772,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define USE_IPP_SORT
|
||||
|
||||
typedef IppStatus (CV_STDCALL * IppSortFunc)(void *, int);
|
||||
@@ -3785,18 +3782,24 @@ static IppSortFunc getSortFunc(int depth, bool sortDescending)
|
||||
{
|
||||
if (!sortDescending)
|
||||
return depth == CV_8U ? (IppSortFunc)ippsSortAscend_8u_I :
|
||||
/*depth == CV_16U ? (IppSortFunc)ippsSortAscend_16u_I :
|
||||
#if IPP_DISABLE_BLOCK
|
||||
depth == CV_16U ? (IppSortFunc)ippsSortAscend_16u_I :
|
||||
depth == CV_16S ? (IppSortFunc)ippsSortAscend_16s_I :
|
||||
depth == CV_32S ? (IppSortFunc)ippsSortAscend_32s_I :
|
||||
depth == CV_32F ? (IppSortFunc)ippsSortAscend_32f_I :
|
||||
depth == CV_64F ? (IppSortFunc)ippsSortAscend_64f_I :*/ 0;
|
||||
depth == CV_64F ? (IppSortFunc)ippsSortAscend_64f_I :
|
||||
#endif
|
||||
0;
|
||||
else
|
||||
return depth == CV_8U ? (IppSortFunc)ippsSortDescend_8u_I :
|
||||
/*depth == CV_16U ? (IppSortFunc)ippsSortDescend_16u_I :
|
||||
#if IPP_DISABLE_BLOCK
|
||||
depth == CV_16U ? (IppSortFunc)ippsSortDescend_16u_I :
|
||||
depth == CV_16S ? (IppSortFunc)ippsSortDescend_16s_I :
|
||||
depth == CV_32S ? (IppSortFunc)ippsSortDescend_32s_I :
|
||||
depth == CV_32F ? (IppSortFunc)ippsSortDescend_32f_I :
|
||||
depth == CV_64F ? (IppSortFunc)ippsSortDescend_64f_I :*/ 0;
|
||||
depth == CV_64F ? (IppSortFunc)ippsSortDescend_64f_I :
|
||||
#endif
|
||||
0;
|
||||
}
|
||||
|
||||
static IppFlipFunc getFlipFunc(int depth)
|
||||
@@ -3911,7 +3914,7 @@ public:
|
||||
const _Tp* arr;
|
||||
};
|
||||
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
|
||||
typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(void *, int *, int);
|
||||
|
||||
@@ -3958,7 +3961,7 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
|
||||
bptr = (T*)buf;
|
||||
_iptr = (int*)ibuf;
|
||||
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
int depth = src.depth();
|
||||
IppSortIndexFunc ippFunc = 0;
|
||||
IppFlipFunc ippFlipFunc = 0;
|
||||
@@ -3987,27 +3990,27 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
|
||||
for( j = 0; j < len; j++ )
|
||||
iptr[j] = j;
|
||||
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
if (sortRows || !ippFunc || ippFunc(ptr, iptr, len) < 0)
|
||||
#endif
|
||||
{
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
std::sort( iptr, iptr + len, LessThanIdx<T>(ptr) );
|
||||
if( sortDescending )
|
||||
{
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
if (!ippFlipFunc || ippFlipFunc(iptr, len) < 0)
|
||||
#endif
|
||||
{
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
for( j = 0; j < len/2; j++ )
|
||||
std::swap(iptr[j], iptr[len-1-j]);
|
||||
}
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
@@ -4015,7 +4018,7 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if defined USE_IPP_SORT && 0
|
||||
#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
|
||||
+59
-41
@@ -4453,8 +4453,11 @@ public:
|
||||
#endif
|
||||
{
|
||||
tempUMatFlags = UMatData::TEMP_UMAT;
|
||||
handle = clCreateBuffer(ctx_handle, CL_MEM_USE_HOST_PTR|createFlags,
|
||||
u->size, u->origdata, &retval);
|
||||
if (u->origdata == cv::alignPtr(u->origdata, 4)) // There are OpenCL runtime issues for less aligned data
|
||||
{
|
||||
handle = clCreateBuffer(ctx_handle, CL_MEM_USE_HOST_PTR|createFlags,
|
||||
u->size, u->origdata, &retval);
|
||||
}
|
||||
if((!handle || retval < 0) && !(accessFlags & ACCESS_FAST))
|
||||
{
|
||||
handle = clCreateBuffer(ctx_handle, CL_MEM_COPY_HOST_PTR|CL_MEM_READ_WRITE|createFlags,
|
||||
@@ -4510,16 +4513,17 @@ public:
|
||||
if(!u)
|
||||
return;
|
||||
|
||||
CV_Assert(u->urefcount >= 0);
|
||||
CV_Assert(u->refcount >= 0);
|
||||
CV_Assert(u->urefcount == 0);
|
||||
CV_Assert(u->refcount == 0 && "UMat deallocation error: some derived Mat is still alive");
|
||||
|
||||
CV_Assert(u->handle != 0 && u->urefcount == 0);
|
||||
CV_Assert(u->handle != 0);
|
||||
CV_Assert(u->mapcount == 0);
|
||||
if(u->tempUMat())
|
||||
{
|
||||
CV_Assert(u->origdata);
|
||||
// UMatDataAutoLock lock(u);
|
||||
|
||||
if( u->hostCopyObsolete() && u->refcount > 0 )
|
||||
if (u->hostCopyObsolete())
|
||||
{
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
if ((u->allocatorFlags_ & svm::OPENCL_SVM_BUFFER_MASK) != 0)
|
||||
@@ -4572,16 +4576,29 @@ public:
|
||||
else
|
||||
{
|
||||
cl_int retval = 0;
|
||||
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||
(CL_MAP_READ | CL_MAP_WRITE),
|
||||
0, u->size, 0, 0, 0, &retval);
|
||||
CV_OclDbgAssert(retval == CL_SUCCESS);
|
||||
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS);
|
||||
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
|
||||
if (u->tempUMat())
|
||||
{
|
||||
CV_Assert(u->mapcount == 0);
|
||||
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||
(CL_MAP_READ | CL_MAP_WRITE),
|
||||
0, u->size, 0, 0, 0, &retval);
|
||||
CV_Assert(u->origdata == data);
|
||||
CV_OclDbgAssert(retval == CL_SUCCESS);
|
||||
if (u->originalUMatData)
|
||||
{
|
||||
CV_Assert(u->originalUMatData->data == data);
|
||||
}
|
||||
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS);
|
||||
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
u->markHostCopyObsolete(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
if ((u->allocatorFlags_ & svm::OPENCL_SVM_BUFFER_MASK) != 0)
|
||||
{
|
||||
@@ -4607,16 +4624,12 @@ public:
|
||||
if(u->data && u->copyOnMap() && u->data != u->origdata)
|
||||
fastFree(u->data);
|
||||
u->data = u->origdata;
|
||||
if(u->refcount == 0)
|
||||
{
|
||||
u->currAllocator->deallocate(u);
|
||||
u = NULL;
|
||||
}
|
||||
u->currAllocator->deallocate(u);
|
||||
u = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(u->origdata == NULL);
|
||||
CV_Assert(u->refcount == 0);
|
||||
if(u->data && u->copyOnMap() && u->data != u->origdata)
|
||||
{
|
||||
fastFree(u->data);
|
||||
@@ -4665,17 +4678,13 @@ public:
|
||||
delete u;
|
||||
u = NULL;
|
||||
}
|
||||
CV_Assert(u == NULL || u->refcount);
|
||||
CV_Assert(u == NULL);
|
||||
}
|
||||
|
||||
// synchronized call (external UMatDataAutoLock, see UMat::getMat)
|
||||
void map(UMatData* u, int accessFlags) const
|
||||
{
|
||||
if(!u)
|
||||
return;
|
||||
|
||||
CV_Assert( u->handle != 0 );
|
||||
|
||||
UMatDataAutoLock autolock(u);
|
||||
CV_Assert(u && u->handle);
|
||||
|
||||
if(accessFlags & ACCESS_WRITE)
|
||||
u->markDeviceCopyObsolete(true);
|
||||
@@ -4715,11 +4724,16 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
cl_int retval = 0;
|
||||
u->data = (uchar*)clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||
(CL_MAP_READ | CL_MAP_WRITE),
|
||||
0, u->size, 0, 0, 0, &retval);
|
||||
if(u->data && retval == CL_SUCCESS)
|
||||
cl_int retval = CL_SUCCESS;
|
||||
if (!u->deviceMemMapped())
|
||||
{
|
||||
CV_Assert(u->refcount == 1);
|
||||
CV_Assert(u->mapcount++ == 0);
|
||||
u->data = (uchar*)clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||
(CL_MAP_READ | CL_MAP_WRITE),
|
||||
0, u->size, 0, 0, 0, &retval);
|
||||
}
|
||||
if (u->data && retval == CL_SUCCESS)
|
||||
{
|
||||
u->markHostCopyObsolete(false);
|
||||
u->markDeviceMemMapped(true);
|
||||
@@ -4765,7 +4779,6 @@ public:
|
||||
if( !u->copyOnMap() && u->deviceMemMapped() )
|
||||
{
|
||||
CV_Assert(u->data != NULL);
|
||||
u->markDeviceMemMapped(false);
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
if ((u->allocatorFlags_ & svm::OPENCL_SVM_BUFFER_MASK) != 0)
|
||||
{
|
||||
@@ -4792,16 +4805,21 @@ public:
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
CV_Assert( (retval = clEnqueueUnmapMemObject(q,
|
||||
(cl_mem)u->handle, u->data, 0, 0, 0)) == CL_SUCCESS );
|
||||
if (Device::getDefault().isAMD())
|
||||
{
|
||||
// required for multithreaded applications (see stitching test)
|
||||
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
|
||||
}
|
||||
|
||||
if (u->refcount == 0)
|
||||
{
|
||||
CV_Assert(u->mapcount-- == 1);
|
||||
CV_Assert((retval = clEnqueueUnmapMemObject(q,
|
||||
(cl_mem)u->handle, u->data, 0, 0, 0)) == CL_SUCCESS);
|
||||
if (Device::getDefault().isAMD())
|
||||
{
|
||||
// required for multithreaded applications (see stitching test)
|
||||
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS);
|
||||
}
|
||||
u->markDeviceMemMapped(false);
|
||||
u->data = 0;
|
||||
u->markDeviceCopyObsolete(false);
|
||||
u->markHostCopyObsolete(true);
|
||||
}
|
||||
}
|
||||
else if( u->copyOnMap() && u->deviceCopyObsolete() )
|
||||
{
|
||||
@@ -4811,9 +4829,9 @@ public:
|
||||
#endif
|
||||
CV_Assert( (retval = clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE, 0,
|
||||
u->size, alignedPtr.getAlignedPtr(), 0, 0, 0)) == CL_SUCCESS );
|
||||
u->markDeviceCopyObsolete(false);
|
||||
u->markHostCopyObsolete(true);
|
||||
}
|
||||
u->markDeviceCopyObsolete(false);
|
||||
u->markHostCopyObsolete(true);
|
||||
}
|
||||
|
||||
bool checkContinuous(int dims, const size_t sz[],
|
||||
|
||||
@@ -304,14 +304,18 @@ void ForThread::stop()
|
||||
{
|
||||
if(m_state == eFTStarted)
|
||||
{
|
||||
pthread_mutex_lock(&m_thread_mutex);
|
||||
m_state = eFTToStop;
|
||||
pthread_mutex_unlock(&m_thread_mutex);
|
||||
|
||||
run();
|
||||
|
||||
pthread_join(m_posix_thread, NULL);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&m_thread_mutex);
|
||||
m_state = eFTStoped;
|
||||
pthread_mutex_unlock(&m_thread_mutex);
|
||||
}
|
||||
|
||||
void ForThread::run()
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/core/opengl.hpp"
|
||||
#include "opencv2/core/vaapi.hpp"
|
||||
#include "opencv2/core/va_intel.hpp"
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
#include "opencv2/core/private.cuda.hpp"
|
||||
@@ -206,7 +206,7 @@ extern volatile bool USE_AVX2;
|
||||
|
||||
enum { BLOCK_SIZE = 1024 };
|
||||
|
||||
#if defined HAVE_IPP && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined HAVE_IPP && (IPP_VERSION_X100 >= 700)
|
||||
#define ARITHM_USE_IPP 1
|
||||
#else
|
||||
#define ARITHM_USE_IPP 0
|
||||
|
||||
+151
-106
@@ -1141,7 +1141,7 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_sum(Mat &src, Scalar &_res)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int cn = src.channels();
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
@@ -1203,7 +1203,7 @@ cv::Scalar cv::sum( InputArray _src )
|
||||
#endif
|
||||
|
||||
Mat src = _src.getMat();
|
||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_sum(src, _res), _res);
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_sum(src, _res), _res);
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
SumFunc func = getSumFunc(depth);
|
||||
@@ -1368,100 +1368,106 @@ int cv::countNonZero( InputArray _src )
|
||||
return nz;
|
||||
}
|
||||
|
||||
#if defined HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
ret = Scalar(res);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &res1) >= 0 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &res2) >= 0 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
ret = Scalar(res1, res2, res3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm);
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *);
|
||||
ippiMeanFuncHint ippFuncHint =
|
||||
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R :
|
||||
0;
|
||||
ippiMeanFuncNoHint ippFuncNoHint =
|
||||
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFuncNoHint)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFuncNoHint)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFuncNoHint)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFuncNoHint)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFuncNoHint)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R :
|
||||
0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
||||
if( ippFuncHint || ippFuncNoHint )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
IppStatus status = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
||||
if( status >= 0 )
|
||||
{
|
||||
for( int i = 0; i < src.channels(); i++ )
|
||||
ret[i] = res[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
Scalar s;
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return Scalar(res);
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &res1) >= 0 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &res2) >= 0 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return Scalar(res1, res2, res3);
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm);
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *);
|
||||
ippiMeanFuncHint ippFuncHint =
|
||||
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R :
|
||||
0;
|
||||
ippiMeanFuncNoHint ippFuncNoHint =
|
||||
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFuncNoHint)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFuncNoHint)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFuncNoHint)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFuncNoHint)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFuncNoHint)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R :
|
||||
0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
||||
if( ippFuncHint || ippFuncNoHint )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
||||
if( ret >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
sc[i] = res[i];
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return sc;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s)
|
||||
|
||||
SumFunc func = getSumFunc(depth);
|
||||
|
||||
@@ -1470,7 +1476,6 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
Scalar s;
|
||||
int total = (int)it.size, blockSize = total, intSumBlockSize = 0;
|
||||
int j, count = 0;
|
||||
AutoBuffer<int> _buf;
|
||||
@@ -1640,7 +1645,7 @@ namespace cv
|
||||
{
|
||||
static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& mask)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int cn = src.channels();
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
@@ -1712,7 +1717,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m
|
||||
ippiMeanStdDevFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_16u_C1R :
|
||||
#if (IPP_VERSION_X100 >= 801)
|
||||
#if (IPP_VERSION_X100 >= 810)
|
||||
type == CV_32FC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_32f_C1R ://Aug 2013: bug in IPP 7.1, 8.0
|
||||
#endif
|
||||
0;
|
||||
@@ -1756,7 +1761,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_meanStdDev(src, _mean, _sdv, mask));
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask));
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
|
||||
@@ -2212,7 +2217,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
@@ -2228,7 +2233,9 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiMaskMinMaxIndxFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
@@ -2265,8 +2272,12 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiMinMaxIndxFuncC1 ippFuncC1 =
|
||||
#if IPP_VERSION_X100 != 900 // bug in 9.0.0 avx2 optimization
|
||||
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
|
||||
#endif
|
||||
#if IPP_VERSION_X100 < 900
|
||||
depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
|
||||
#endif
|
||||
depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
|
||||
#if !((defined _MSC_VER && defined _M_IX86) || defined __i386__)
|
||||
depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R :
|
||||
@@ -2320,7 +2331,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
ocl_minMaxIdx(_src, minVal, maxVal, minIdx, maxIdx, _mask))
|
||||
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||
|
||||
MinMaxIdxFunc func = getMinmaxTab(depth);
|
||||
CV_Assert( func != 0 );
|
||||
@@ -2331,8 +2342,8 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
|
||||
size_t minidx = 0, maxidx = 0;
|
||||
int iminval = INT_MAX, imaxval = INT_MIN;
|
||||
float fminval = FLT_MAX, fmaxval = -FLT_MAX;
|
||||
double dminval = DBL_MAX, dmaxval = -DBL_MAX;
|
||||
float fminval = std::numeric_limits<float>::infinity(), fmaxval = -fminval;
|
||||
double dminval = std::numeric_limits<double>::infinity(), dmaxval = -dminval;
|
||||
size_t startidx = 1;
|
||||
int *minval = &iminval, *maxval = &imaxval;
|
||||
int planeSize = (int)it.size*cn;
|
||||
@@ -2345,6 +2356,14 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it, startidx += planeSize )
|
||||
func( ptrs[0], ptrs[1], minval, maxval, &minidx, &maxidx, planeSize, startidx );
|
||||
|
||||
if (!src.empty() && mask.empty())
|
||||
{
|
||||
if( minidx == 0 )
|
||||
minidx = 1;
|
||||
if( maxidx == 0 )
|
||||
maxidx = 1;
|
||||
}
|
||||
|
||||
if( minidx == 0 )
|
||||
dminval = dmaxval = 0;
|
||||
else if( depth == CV_32F )
|
||||
@@ -2645,7 +2664,7 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int cn = src.channels();
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
@@ -2663,19 +2682,25 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
ippiMaskNormFuncC1 ippFuncC1 =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
|
||||
#endif
|
||||
// type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
@@ -2688,7 +2713,8 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
#if IPP_DISABLE_BLOCK
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskNormFuncC3 ippFuncC3 =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR :
|
||||
@@ -2723,7 +2749,8 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm);
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2749,7 +2776,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R :
|
||||
#if (IPP_VERSION_X100 >= 801)
|
||||
#if (IPP_VERSION_X100 >= 810)
|
||||
type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
#endif
|
||||
@@ -2829,7 +2856,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
#endif
|
||||
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_norm(src, normType, mask, _result), _result);
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_norm(src, normType, mask, _result), _result);
|
||||
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
if( src.isContinuous() && mask.empty() )
|
||||
@@ -3033,7 +3060,7 @@ namespace cv
|
||||
{
|
||||
static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double &result)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
||||
|
||||
if( normType & CV_RELATIVE )
|
||||
@@ -3056,23 +3083,29 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
ippiMaskNormRelFuncC1 ippFuncC1 =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
@@ -3157,21 +3190,27 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
ippiMaskNormDiffFuncC1 ippFuncC1 =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
@@ -3189,19 +3228,25 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
ippiMaskNormDiffFuncC3 ippFuncC3 =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR :
|
||||
0) : 0;
|
||||
@@ -3247,7 +3292,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C1R :
|
||||
#if (IPP_VERSION_X100 >= 801)
|
||||
#if (IPP_VERSION_X100 >= 810)
|
||||
type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
#endif
|
||||
@@ -3262,7 +3307,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C4R :
|
||||
#if !(IPP_VERSION_X100 == 802 && (!defined(IPP_VERSION_UPDATE) || IPP_VERSION_UPDATE <= 1)) // Oct 2014: Accuracy issue with IPP 8.2 / 8.2.1
|
||||
#if !(IPP_VERSION_X100 == 820 || IPP_VERSION_X100 == 821) // Oct 2014: Accuracy issue with IPP 8.2 / 8.2.1
|
||||
type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C1R :
|
||||
#endif
|
||||
type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C3R :
|
||||
@@ -3326,7 +3371,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
_result)
|
||||
#endif
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_norm(_src1, _src2, normType, _mask, _result), _result);
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_norm(_src1, _src2, normType, _mask, _result), _result);
|
||||
|
||||
if( normType & CV_RELATIVE )
|
||||
{
|
||||
|
||||
+123
-40
@@ -42,6 +42,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace cv {
|
||||
|
||||
@@ -377,21 +378,6 @@ bool checkHardwareSupport(int feature)
|
||||
|
||||
|
||||
volatile bool useOptimizedFlag = true;
|
||||
#ifdef HAVE_IPP
|
||||
struct IPPInitializer
|
||||
{
|
||||
IPPInitializer(void)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 8
|
||||
ippInit();
|
||||
#else
|
||||
ippStaticInit();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
IPPInitializer ippInitializer;
|
||||
#endif
|
||||
|
||||
volatile bool USE_SSE2 = featuresEnabled.have[CV_CPU_SSE2];
|
||||
volatile bool USE_SSE4_2 = featuresEnabled.have[CV_CPU_SSE4_2];
|
||||
@@ -1034,7 +1020,7 @@ class TlsStorage
|
||||
public:
|
||||
TlsStorage()
|
||||
{
|
||||
tlsSlots = 0;
|
||||
tlsSlots.reserve(32);
|
||||
threads.reserve(32);
|
||||
}
|
||||
~TlsStorage()
|
||||
@@ -1077,15 +1063,27 @@ public:
|
||||
size_t reserveSlot()
|
||||
{
|
||||
AutoLock guard(mtxGlobalAccess);
|
||||
tlsSlots++;
|
||||
return (tlsSlots-1);
|
||||
|
||||
// Find unused slots
|
||||
for(size_t slot = 0; slot < tlsSlots.size(); slot++)
|
||||
{
|
||||
if(!tlsSlots[slot])
|
||||
{
|
||||
tlsSlots[slot] = 1;
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new slot
|
||||
tlsSlots.push_back(1);
|
||||
return (tlsSlots.size()-1);
|
||||
}
|
||||
|
||||
// Release TLS storage index and pass assosiated data to caller
|
||||
void releaseSlot(size_t slotIdx, std::vector<void*> &dataVec)
|
||||
{
|
||||
AutoLock guard(mtxGlobalAccess);
|
||||
CV_Assert(tlsSlots > slotIdx);
|
||||
CV_Assert(tlsSlots.size() > slotIdx);
|
||||
|
||||
for(size_t i = 0; i < threads.size(); i++)
|
||||
{
|
||||
@@ -1096,15 +1094,14 @@ public:
|
||||
threads[i]->slots[slotIdx] = 0;
|
||||
}
|
||||
}
|
||||
// If we removing last element, decriment slots size to save space
|
||||
if(tlsSlots-1 == slotIdx)
|
||||
tlsSlots--;
|
||||
|
||||
tlsSlots[slotIdx] = 0;
|
||||
}
|
||||
|
||||
// Get data by TLS storage index
|
||||
void* getData(size_t slotIdx) const
|
||||
{
|
||||
CV_Assert(tlsSlots > slotIdx);
|
||||
CV_Assert(tlsSlots.size() > slotIdx);
|
||||
|
||||
ThreadData* threadData = (ThreadData*)tls.GetData();
|
||||
if(threadData && threadData->slots.size() > slotIdx)
|
||||
@@ -1113,10 +1110,24 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Gather data from threads by TLS storage index
|
||||
void gather(size_t slotIdx, std::vector<void*> &dataVec)
|
||||
{
|
||||
AutoLock guard(mtxGlobalAccess);
|
||||
CV_Assert(tlsSlots.size() > slotIdx);
|
||||
|
||||
for(size_t i = 0; i < threads.size(); i++)
|
||||
{
|
||||
std::vector<void*>& thread_slots = threads[i]->slots;
|
||||
if (thread_slots.size() > slotIdx && thread_slots[slotIdx])
|
||||
dataVec.push_back(thread_slots[slotIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
// Set data to storage index
|
||||
void setData(size_t slotIdx, void* pData)
|
||||
{
|
||||
CV_Assert(pData != NULL);
|
||||
CV_Assert(tlsSlots.size() > slotIdx && pData != NULL);
|
||||
|
||||
ThreadData* threadData = (ThreadData*)tls.GetData();
|
||||
if(!threadData)
|
||||
@@ -1131,7 +1142,11 @@ public:
|
||||
}
|
||||
|
||||
if(slotIdx >= threadData->slots.size())
|
||||
threadData->slots.resize(slotIdx+1);
|
||||
{
|
||||
AutoLock guard(mtxGlobalAccess);
|
||||
while(slotIdx >= threadData->slots.size())
|
||||
threadData->slots.push_back(NULL);
|
||||
}
|
||||
threadData->slots[slotIdx] = pData;
|
||||
}
|
||||
|
||||
@@ -1139,7 +1154,7 @@ private:
|
||||
TlsAbstraction tls; // TLS abstraction layer instance
|
||||
|
||||
Mutex mtxGlobalAccess; // Shared objects operation guard
|
||||
size_t tlsSlots; // TLS storage counter
|
||||
std::vector<int> tlsSlots; // TLS keys state
|
||||
std::vector<ThreadData*> threads; // Array for all allocated data. Thread data pointers are placed here to allow data cleanup
|
||||
};
|
||||
|
||||
@@ -1159,6 +1174,11 @@ TLSDataContainer::~TLSDataContainer()
|
||||
CV_Assert(key_ == -1); // Key must be released in child object
|
||||
}
|
||||
|
||||
void TLSDataContainer::gatherData(std::vector<void*> &data) const
|
||||
{
|
||||
getTlsStorage().gather(key_, data);
|
||||
}
|
||||
|
||||
void TLSDataContainer::release()
|
||||
{
|
||||
std::vector<void*> data;
|
||||
@@ -1271,26 +1291,93 @@ void setUseCollection(bool flag)
|
||||
namespace ipp
|
||||
{
|
||||
|
||||
static int ippStatus = 0; // 0 - all is ok, -1 - IPP functions failed
|
||||
static const char * funcname = NULL, * filename = NULL;
|
||||
static int linen = 0;
|
||||
struct IPPInitSingelton
|
||||
{
|
||||
public:
|
||||
IPPInitSingelton()
|
||||
{
|
||||
useIPP = true;
|
||||
ippStatus = 0;
|
||||
funcname = NULL;
|
||||
filename = NULL;
|
||||
linen = 0;
|
||||
ippFeatures = 0;
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
const char* pIppEnv = getenv("OPENCV_IPP");
|
||||
cv::String env = pIppEnv;
|
||||
if(env.size())
|
||||
{
|
||||
if(env == "disabled")
|
||||
{
|
||||
std::cerr << "WARNING: IPP was disabled by OPENCV_IPP environment variable" << std::endl;
|
||||
useIPP = false;
|
||||
}
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
else if(env == "sse")
|
||||
ippFeatures = ippCPUID_SSE;
|
||||
else if(env == "sse2")
|
||||
ippFeatures = ippCPUID_SSE2;
|
||||
else if(env == "sse3")
|
||||
ippFeatures = ippCPUID_SSE3;
|
||||
else if(env == "ssse3")
|
||||
ippFeatures = ippCPUID_SSSE3;
|
||||
else if(env == "sse41")
|
||||
ippFeatures = ippCPUID_SSE41;
|
||||
else if(env == "sse42")
|
||||
ippFeatures = ippCPUID_SSE42;
|
||||
else if(env == "avx")
|
||||
ippFeatures = ippCPUID_AVX;
|
||||
else if(env == "avx2")
|
||||
ippFeatures = ippCPUID_AVX2;
|
||||
#endif
|
||||
else
|
||||
std::cerr << "ERROR: Improper value of OPENCV_IPP: " << env.c_str() << std::endl;
|
||||
}
|
||||
|
||||
IPP_INITIALIZER(ippFeatures)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool useIPP;
|
||||
|
||||
int ippStatus; // 0 - all is ok, -1 - IPP functions failed
|
||||
const char *funcname;
|
||||
const char *filename;
|
||||
int linen;
|
||||
int ippFeatures;
|
||||
};
|
||||
|
||||
static IPPInitSingelton& getIPPSingelton()
|
||||
{
|
||||
CV_SINGLETON_LAZY_INIT_REF(IPPInitSingelton, new IPPInitSingelton())
|
||||
}
|
||||
|
||||
int getIppFeatures()
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
return getIPPSingelton().ippFeatures;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line)
|
||||
{
|
||||
ippStatus = status;
|
||||
funcname = _funcname;
|
||||
filename = _filename;
|
||||
linen = _line;
|
||||
getIPPSingelton().ippStatus = status;
|
||||
getIPPSingelton().funcname = _funcname;
|
||||
getIPPSingelton().filename = _filename;
|
||||
getIPPSingelton().linen = _line;
|
||||
}
|
||||
|
||||
int getIppStatus()
|
||||
{
|
||||
return ippStatus;
|
||||
return getIPPSingelton().ippStatus;
|
||||
}
|
||||
|
||||
String getIppErrorLocation()
|
||||
{
|
||||
return format("%s:%d %s", filename ? filename : "", linen, funcname ? funcname : "");
|
||||
return format("%s:%d %s", getIPPSingelton().filename ? getIPPSingelton().filename : "", getIPPSingelton().linen, getIPPSingelton().funcname ? getIPPSingelton().funcname : "");
|
||||
}
|
||||
|
||||
bool useIPP()
|
||||
@@ -1299,11 +1386,7 @@ bool useIPP()
|
||||
CoreTLSData* data = getCoreTlsData().get();
|
||||
if(data->useIPP < 0)
|
||||
{
|
||||
const char* pIppEnv = getenv("OPENCV_IPP");
|
||||
if(pIppEnv && (cv::String(pIppEnv) == "disabled"))
|
||||
data->useIPP = false;
|
||||
else
|
||||
data->useIPP = true;
|
||||
data->useIPP = getIPPSingelton().useIPP;
|
||||
}
|
||||
return (data->useIPP > 0);
|
||||
#else
|
||||
|
||||
+106
-24
@@ -60,25 +60,71 @@ static Mutex umatLocks[UMAT_NLOCKS];
|
||||
UMatData::UMatData(const MatAllocator* allocator)
|
||||
{
|
||||
prevAllocator = currAllocator = allocator;
|
||||
urefcount = refcount = 0;
|
||||
urefcount = refcount = mapcount = 0;
|
||||
data = origdata = 0;
|
||||
size = 0;
|
||||
flags = 0;
|
||||
handle = 0;
|
||||
userdata = 0;
|
||||
allocatorFlags_ = 0;
|
||||
originalUMatData = NULL;
|
||||
}
|
||||
|
||||
UMatData::~UMatData()
|
||||
{
|
||||
prevAllocator = currAllocator = 0;
|
||||
urefcount = refcount = 0;
|
||||
CV_Assert(mapcount == 0);
|
||||
data = origdata = 0;
|
||||
size = 0;
|
||||
flags = 0;
|
||||
handle = 0;
|
||||
userdata = 0;
|
||||
allocatorFlags_ = 0;
|
||||
if (originalUMatData)
|
||||
{
|
||||
UMatData* u = originalUMatData;
|
||||
CV_XADD(&(u->urefcount), -1);
|
||||
CV_XADD(&(u->refcount), -1);
|
||||
bool showWarn = false;
|
||||
if (u->refcount == 0)
|
||||
{
|
||||
if (u->urefcount > 0)
|
||||
showWarn = true;
|
||||
// simulate Mat::deallocate
|
||||
if (u->mapcount != 0)
|
||||
{
|
||||
(u->currAllocator ? u->currAllocator : /* TODO allocator ? allocator :*/ Mat::getStdAllocator())->unmap(u);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't do "map", so we can't do "unmap"
|
||||
}
|
||||
}
|
||||
if (u->refcount == 0 && u->urefcount == 0) // oops, we need to free resources
|
||||
{
|
||||
showWarn = true;
|
||||
// simulate UMat::deallocate
|
||||
u->currAllocator->deallocate(u);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
if (showWarn)
|
||||
{
|
||||
static int warn_message_showed = 0;
|
||||
if (warn_message_showed++ < 100)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "\n! OPENCV warning: getUMat()/getMat() call chain possible problem."
|
||||
"\n! Base object is dead, while nested/derived object is still alive or processed."
|
||||
"\n! Please check lifetime of UMat/Mat objects!\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)showWarn;
|
||||
#endif
|
||||
originalUMatData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void UMatData::lock()
|
||||
@@ -221,19 +267,34 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
|
||||
UMat hdr;
|
||||
if(!data)
|
||||
return hdr;
|
||||
Size wholeSize;
|
||||
Point ofs;
|
||||
locateROI(wholeSize, ofs);
|
||||
Size sz(cols, rows);
|
||||
if (ofs.x != 0 || ofs.y != 0)
|
||||
{
|
||||
Mat src = *this;
|
||||
int dtop = ofs.y;
|
||||
int dbottom = wholeSize.height - src.rows - ofs.y;
|
||||
int dleft = ofs.x;
|
||||
int dright = wholeSize.width - src.cols - ofs.x;
|
||||
src.adjustROI(dtop, dbottom, dleft, dright);
|
||||
return src.getUMat(accessFlags, usageFlags)(cv::Rect(ofs.x, ofs.y, sz.width, sz.height));
|
||||
}
|
||||
CV_Assert(data == datastart);
|
||||
|
||||
accessFlags |= ACCESS_RW;
|
||||
UMatData* temp_u = u;
|
||||
if(!temp_u)
|
||||
UMatData* new_u = NULL;
|
||||
{
|
||||
MatAllocator *a = allocator, *a0 = getStdAllocator();
|
||||
if(!a)
|
||||
a = a0;
|
||||
temp_u = a->allocate(dims, size.p, type(), data, step.p, accessFlags, usageFlags);
|
||||
new_u = a->allocate(dims, size.p, type(), data, step.p, accessFlags, usageFlags);
|
||||
}
|
||||
bool allocated = false;
|
||||
try
|
||||
{
|
||||
allocated = UMat::getStdAllocator()->allocate(temp_u, accessFlags, usageFlags);
|
||||
allocated = UMat::getStdAllocator()->allocate(new_u, accessFlags, usageFlags);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
@@ -241,14 +302,26 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
|
||||
}
|
||||
if (!allocated)
|
||||
{
|
||||
allocated = getStdAllocator()->allocate(temp_u, accessFlags, usageFlags);
|
||||
allocated = getStdAllocator()->allocate(new_u, accessFlags, usageFlags);
|
||||
CV_Assert(allocated);
|
||||
}
|
||||
if (u != NULL)
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
if (ocl::useOpenCL() && new_u->currAllocator == ocl::getOpenCLAllocator())
|
||||
{
|
||||
CV_Assert(new_u->tempUMat());
|
||||
}
|
||||
#endif
|
||||
new_u->originalUMatData = u;
|
||||
CV_XADD(&(u->refcount), 1);
|
||||
CV_XADD(&(u->urefcount), 1);
|
||||
}
|
||||
hdr.flags = flags;
|
||||
setSize(hdr, dims, size.p, step.p);
|
||||
finalizeHdr(hdr);
|
||||
hdr.u = temp_u;
|
||||
hdr.offset = data - datastart;
|
||||
hdr.u = new_u;
|
||||
hdr.offset = 0; //data - datastart;
|
||||
hdr.addref();
|
||||
return hdr;
|
||||
}
|
||||
@@ -639,16 +712,25 @@ Mat UMat::getMat(int accessFlags) const
|
||||
return Mat();
|
||||
// TODO Support ACCESS_READ (ACCESS_WRITE) without unnecessary data transfers
|
||||
accessFlags |= ACCESS_RW;
|
||||
u->currAllocator->map(u, accessFlags);
|
||||
CV_Assert(u->data != 0);
|
||||
Mat hdr(dims, size.p, type(), u->data + offset, step.p);
|
||||
hdr.flags = flags;
|
||||
hdr.u = u;
|
||||
hdr.datastart = u->data;
|
||||
hdr.data = u->data + offset;
|
||||
hdr.datalimit = hdr.dataend = u->data + u->size;
|
||||
CV_XADD(&hdr.u->refcount, 1);
|
||||
return hdr;
|
||||
UMatDataAutoLock autolock(u);
|
||||
if(CV_XADD(&u->refcount, 1) == 0)
|
||||
u->currAllocator->map(u, accessFlags);
|
||||
if (u->data != 0)
|
||||
{
|
||||
Mat hdr(dims, size.p, type(), u->data + offset, step.p);
|
||||
hdr.flags = flags;
|
||||
hdr.u = u;
|
||||
hdr.datastart = u->data;
|
||||
hdr.data = u->data + offset;
|
||||
hdr.datalimit = hdr.dataend = u->data + u->size;
|
||||
return hdr;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_XADD(&u->refcount, -1);
|
||||
CV_Assert(u->data != 0 && "Error mapping of UMat to host memory.");
|
||||
return Mat();
|
||||
}
|
||||
}
|
||||
|
||||
void* UMat::handle(int accessFlags) const
|
||||
@@ -656,10 +738,10 @@ void* UMat::handle(int accessFlags) const
|
||||
if( !u )
|
||||
return 0;
|
||||
|
||||
// check flags: if CPU copy is newer, copy it back to GPU.
|
||||
if( u->deviceCopyObsolete() )
|
||||
CV_Assert(u->refcount == 0);
|
||||
CV_Assert(!u->deviceCopyObsolete() || u->copyOnMap());
|
||||
if (u->deviceCopyObsolete())
|
||||
{
|
||||
CV_Assert(u->refcount == 0 || u->origdata);
|
||||
u->currAllocator->unmap(u);
|
||||
}
|
||||
|
||||
@@ -758,7 +840,7 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const
|
||||
haveDstUninit ? ocl::KernelArg::WriteOnly(dst) :
|
||||
ocl::KernelArg::ReadWrite(dst));
|
||||
|
||||
size_t globalsize[2] = { cols, rows };
|
||||
size_t globalsize[2] = { (size_t)cols, (size_t)rows };
|
||||
if (k.run(2, globalsize, NULL, false))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_OCL);
|
||||
@@ -819,7 +901,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con
|
||||
else
|
||||
k.args(srcarg, dstarg, alpha, beta, rowsPerWI);
|
||||
|
||||
size_t globalsize[2] = { dst.cols * cn, (dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)dst.cols * cn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
if (k.run(2, globalsize, NULL, false))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_OCL);
|
||||
@@ -875,7 +957,7 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask)
|
||||
setK.args(dstarg, scalararg);
|
||||
}
|
||||
|
||||
size_t globalsize[] = { cols * cn / kercn, (rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[] = { (size_t)cols * cn / kercn, ((size_t)rows + rowsPerWI - 1) / rowsPerWI };
|
||||
if( setK.run(2, globalsize, NULL, false) )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_OCL);
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
// Copyright (C) 2015, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_VA
|
||||
# include <va/va.h>
|
||||
#else // HAVE_VA
|
||||
# define NO_VA_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without VA support (libva)")
|
||||
#endif // HAVE_VA
|
||||
|
||||
using namespace cv;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// CL-VA Interoperability
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
# include "opencv2/core/opencl/runtime/opencl_core.hpp"
|
||||
# include "opencv2/core.hpp"
|
||||
# include "opencv2/core/ocl.hpp"
|
||||
# include "opencl_kernels_core.hpp"
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
#if defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL)
|
||||
# include <CL/va_ext.h>
|
||||
#endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
|
||||
namespace cv { namespace va_intel {
|
||||
|
||||
#if defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL)
|
||||
|
||||
static clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn clGetDeviceIDsFromVA_APIMediaAdapterINTEL = NULL;
|
||||
static clCreateFromVA_APIMediaSurfaceINTEL_fn clCreateFromVA_APIMediaSurfaceINTEL = NULL;
|
||||
static clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn clEnqueueAcquireVA_APIMediaSurfacesINTEL = NULL;
|
||||
static clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn clEnqueueReleaseVA_APIMediaSurfacesINTEL = NULL;
|
||||
|
||||
static bool contextInitialized = false;
|
||||
|
||||
#endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
|
||||
namespace ocl {
|
||||
|
||||
Context& initializeContextFromVA(VADisplay display, bool tryInterop)
|
||||
{
|
||||
(void)display; (void)tryInterop;
|
||||
#if !defined(HAVE_VA)
|
||||
NO_VA_SUPPORT_ERROR;
|
||||
#else // !HAVE_VA
|
||||
# if (defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL))
|
||||
contextInitialized = false;
|
||||
if (tryInterop)
|
||||
{
|
||||
cl_uint numPlatforms;
|
||||
cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get number of platforms");
|
||||
if (numPlatforms == 0)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms");
|
||||
|
||||
std::vector<cl_platform_id> platforms(numPlatforms);
|
||||
status = clGetPlatformIDs(numPlatforms, &platforms[0], NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get platform Id list");
|
||||
|
||||
// For CL-VA interop, we must find platform/device with "cl_intel_va_api_media_sharing" extension.
|
||||
// With standard initialization procedure, we should examine platform extension string for that.
|
||||
// But in practice, the platform ext string doesn't contain it, while device ext string does.
|
||||
// Follow Intel procedure (see tutorial), we should obtain device IDs by extension call.
|
||||
// Note that we must obtain function pointers using specific platform ID, and can't provide pointers in advance.
|
||||
// So, we iterate and select the first platform, for which we got non-NULL pointers, device, and CL context.
|
||||
|
||||
int found = -1;
|
||||
cl_context context = 0;
|
||||
cl_device_id device = 0;
|
||||
|
||||
for (int i = 0; i < (int)numPlatforms; ++i)
|
||||
{
|
||||
// Get extension function pointers
|
||||
|
||||
clGetDeviceIDsFromVA_APIMediaAdapterINTEL = (clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clGetDeviceIDsFromVA_APIMediaAdapterINTEL");
|
||||
clCreateFromVA_APIMediaSurfaceINTEL = (clCreateFromVA_APIMediaSurfaceINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clCreateFromVA_APIMediaSurfaceINTEL");
|
||||
clEnqueueAcquireVA_APIMediaSurfacesINTEL = (clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clEnqueueAcquireVA_APIMediaSurfacesINTEL");
|
||||
clEnqueueReleaseVA_APIMediaSurfacesINTEL = (clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clEnqueueReleaseVA_APIMediaSurfacesINTEL");
|
||||
|
||||
if (((void*)clGetDeviceIDsFromVA_APIMediaAdapterINTEL == NULL) ||
|
||||
((void*)clCreateFromVA_APIMediaSurfaceINTEL == NULL) ||
|
||||
((void*)clEnqueueAcquireVA_APIMediaSurfacesINTEL == NULL) ||
|
||||
((void*)clEnqueueReleaseVA_APIMediaSurfacesINTEL == NULL))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Query device list
|
||||
|
||||
cl_uint numDevices = 0;
|
||||
|
||||
status = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(platforms[i], CL_VA_API_DISPLAY_INTEL, display,
|
||||
CL_PREFERRED_DEVICES_FOR_VA_API_INTEL, 0, NULL, &numDevices);
|
||||
if ((status != CL_SUCCESS) || !(numDevices > 0))
|
||||
continue;
|
||||
numDevices = 1; // initializeContextFromHandle() expects only 1 device
|
||||
status = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(platforms[i], CL_VA_API_DISPLAY_INTEL, display,
|
||||
CL_PREFERRED_DEVICES_FOR_VA_API_INTEL, numDevices, &device, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
continue;
|
||||
|
||||
// Creating CL-VA media sharing OpenCL context
|
||||
|
||||
cl_context_properties props[] = {
|
||||
CL_CONTEXT_VA_API_DISPLAY_INTEL, (cl_context_properties) display,
|
||||
CL_CONTEXT_INTEROP_USER_SYNC, CL_FALSE, // no explicit sync required
|
||||
0
|
||||
};
|
||||
|
||||
context = clCreateContext(props, numDevices, &device, NULL, NULL, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
{
|
||||
clReleaseDevice(device);
|
||||
}
|
||||
else
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found >= 0)
|
||||
{
|
||||
contextInitialized = true;
|
||||
Context& ctx = Context::getDefault(false);
|
||||
initializeContextFromHandle(ctx, platforms[found], context, device);
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
# endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
{
|
||||
Context& ctx = Context::getDefault(true);
|
||||
return ctx;
|
||||
}
|
||||
#endif // !HAVE_VA
|
||||
}
|
||||
|
||||
#if defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL)
|
||||
static bool ocl_convert_nv12_to_bgr(cl_mem clImageY, cl_mem clImageUV, cl_mem clBuffer, int step, int cols, int rows)
|
||||
{
|
||||
ocl::Kernel k;
|
||||
k.create("YUV2BGR_NV12_8u", cv::ocl::core::cvtclr_dx_oclsrc, "");
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
k.args(clImageY, clImageUV, clBuffer, step, cols, rows);
|
||||
|
||||
size_t globalsize[] = { (size_t)cols, (size_t)rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
static bool ocl_convert_bgr_to_nv12(cl_mem clBuffer, int step, int cols, int rows, cl_mem clImageY, cl_mem clImageUV)
|
||||
{
|
||||
ocl::Kernel k;
|
||||
k.create("BGR2YUV_NV12_8u", cv::ocl::core::cvtclr_dx_oclsrc, "");
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
k.args(clBuffer, step, cols, rows, clImageY, clImageUV);
|
||||
|
||||
size_t globalsize[] = { (size_t)cols, (size_t)rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
#endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
|
||||
} // namespace cv::va_intel::ocl
|
||||
|
||||
#if defined(HAVE_VA)
|
||||
const int NCHANNELS = 3;
|
||||
|
||||
static void copy_convert_nv12_to_bgr(const VAImage& image, const unsigned char* buffer, Mat& bgr)
|
||||
{
|
||||
const float d1 = 16.0f;
|
||||
const float d2 = 128.0f;
|
||||
|
||||
static const float coeffs[5] =
|
||||
{
|
||||
1.163999557f,
|
||||
2.017999649f,
|
||||
-0.390999794f,
|
||||
-0.812999725f,
|
||||
1.5959997177f
|
||||
};
|
||||
|
||||
const size_t srcOffsetY = image.offsets[0];
|
||||
const size_t srcOffsetUV = image.offsets[1];
|
||||
|
||||
const size_t srcStepY = image.pitches[0];
|
||||
const size_t srcStepUV = image.pitches[1];
|
||||
|
||||
const size_t dstStep = bgr.step;
|
||||
|
||||
const unsigned char* srcY0 = buffer + srcOffsetY;
|
||||
const unsigned char* srcUV = buffer + srcOffsetUV;
|
||||
|
||||
unsigned char* dst0 = bgr.data;
|
||||
|
||||
for (int y = 0; y < bgr.rows; y += 2)
|
||||
{
|
||||
const unsigned char* srcY1 = srcY0 + srcStepY;
|
||||
unsigned char *dst1 = dst0 + dstStep;
|
||||
|
||||
for (int x = 0; x < bgr.cols; x += 2)
|
||||
{
|
||||
float Y0 = float(srcY0[x+0]);
|
||||
float Y1 = float(srcY0[x+1]);
|
||||
float Y2 = float(srcY1[x+0]);
|
||||
float Y3 = float(srcY1[x+1]);
|
||||
|
||||
float U = float(srcUV[2*(x/2)+0]) - d2;
|
||||
float V = float(srcUV[2*(x/2)+1]) - d2;
|
||||
|
||||
Y0 = std::max(0.0f, Y0 - d1) * coeffs[0];
|
||||
Y1 = std::max(0.0f, Y1 - d1) * coeffs[0];
|
||||
Y2 = std::max(0.0f, Y2 - d1) * coeffs[0];
|
||||
Y3 = std::max(0.0f, Y3 - d1) * coeffs[0];
|
||||
|
||||
float ruv = coeffs[4]*V;
|
||||
float guv = coeffs[3]*V + coeffs[2]*U;
|
||||
float buv = coeffs[1]*U;
|
||||
|
||||
dst0[(x+0)*NCHANNELS+0] = saturate_cast<unsigned char>(Y0 + buv);
|
||||
dst0[(x+0)*NCHANNELS+1] = saturate_cast<unsigned char>(Y0 + guv);
|
||||
dst0[(x+0)*NCHANNELS+2] = saturate_cast<unsigned char>(Y0 + ruv);
|
||||
|
||||
dst0[(x+1)*NCHANNELS+0] = saturate_cast<unsigned char>(Y1 + buv);
|
||||
dst0[(x+1)*NCHANNELS+1] = saturate_cast<unsigned char>(Y1 + guv);
|
||||
dst0[(x+1)*NCHANNELS+2] = saturate_cast<unsigned char>(Y1 + ruv);
|
||||
|
||||
dst1[(x+0)*NCHANNELS+0] = saturate_cast<unsigned char>(Y2 + buv);
|
||||
dst1[(x+0)*NCHANNELS+1] = saturate_cast<unsigned char>(Y2 + guv);
|
||||
dst1[(x+0)*NCHANNELS+2] = saturate_cast<unsigned char>(Y2 + ruv);
|
||||
|
||||
dst1[(x+1)*NCHANNELS+0] = saturate_cast<unsigned char>(Y3 + buv);
|
||||
dst1[(x+1)*NCHANNELS+1] = saturate_cast<unsigned char>(Y3 + guv);
|
||||
dst1[(x+1)*NCHANNELS+2] = saturate_cast<unsigned char>(Y3 + ruv);
|
||||
}
|
||||
|
||||
srcY0 = srcY1 + srcStepY;
|
||||
srcUV += srcStepUV;
|
||||
dst0 = dst1 + dstStep;
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_convert_bgr_to_nv12(const VAImage& image, const Mat& bgr, unsigned char* buffer)
|
||||
{
|
||||
const float d1 = 16.0f;
|
||||
const float d2 = 128.0f;
|
||||
|
||||
static const float coeffs[8] =
|
||||
{
|
||||
0.256999969f, 0.50399971f, 0.09799957f, -0.1479988098f,
|
||||
-0.2909994125f, 0.438999176f, -0.3679990768f, -0.0709991455f
|
||||
};
|
||||
|
||||
const size_t dstOffsetY = image.offsets[0];
|
||||
const size_t dstOffsetUV = image.offsets[1];
|
||||
|
||||
const size_t dstStepY = image.pitches[0];
|
||||
const size_t dstStepUV = image.pitches[1];
|
||||
|
||||
const size_t srcStep = bgr.step;
|
||||
|
||||
const unsigned char* src0 = bgr.data;
|
||||
|
||||
unsigned char* dstY0 = buffer + dstOffsetY;
|
||||
unsigned char* dstUV = buffer + dstOffsetUV;
|
||||
|
||||
for (int y = 0; y < bgr.rows; y += 2)
|
||||
{
|
||||
const unsigned char *src1 = src0 + srcStep;
|
||||
unsigned char* dstY1 = dstY0 + dstStepY;
|
||||
|
||||
for (int x = 0; x < bgr.cols; x += 2)
|
||||
{
|
||||
float B0 = float(src0[(x+0)*NCHANNELS+0]);
|
||||
float G0 = float(src0[(x+0)*NCHANNELS+1]);
|
||||
float R0 = float(src0[(x+0)*NCHANNELS+2]);
|
||||
|
||||
float B1 = float(src0[(x+1)*NCHANNELS+0]);
|
||||
float G1 = float(src0[(x+1)*NCHANNELS+1]);
|
||||
float R1 = float(src0[(x+1)*NCHANNELS+2]);
|
||||
|
||||
float B2 = float(src1[(x+0)*NCHANNELS+0]);
|
||||
float G2 = float(src1[(x+0)*NCHANNELS+1]);
|
||||
float R2 = float(src1[(x+0)*NCHANNELS+2]);
|
||||
|
||||
float B3 = float(src1[(x+1)*NCHANNELS+0]);
|
||||
float G3 = float(src1[(x+1)*NCHANNELS+1]);
|
||||
float R3 = float(src1[(x+1)*NCHANNELS+2]);
|
||||
|
||||
float Y0 = coeffs[0]*R0 + coeffs[1]*G0 + coeffs[2]*B0 + d1;
|
||||
float Y1 = coeffs[0]*R1 + coeffs[1]*G1 + coeffs[2]*B1 + d1;
|
||||
float Y2 = coeffs[0]*R2 + coeffs[1]*G2 + coeffs[2]*B2 + d1;
|
||||
float Y3 = coeffs[0]*R3 + coeffs[1]*G3 + coeffs[2]*B3 + d1;
|
||||
|
||||
float U = coeffs[3]*R0 + coeffs[4]*G0 + coeffs[5]*B0 + d2;
|
||||
float V = coeffs[5]*R0 + coeffs[6]*G0 + coeffs[7]*B0 + d2;
|
||||
|
||||
dstY0[x+0] = saturate_cast<unsigned char>(Y0);
|
||||
dstY0[x+1] = saturate_cast<unsigned char>(Y1);
|
||||
dstY1[x+0] = saturate_cast<unsigned char>(Y2);
|
||||
dstY1[x+1] = saturate_cast<unsigned char>(Y3);
|
||||
|
||||
dstUV[2*(x/2)+0] = saturate_cast<unsigned char>(U);
|
||||
dstUV[2*(x/2)+1] = saturate_cast<unsigned char>(V);
|
||||
}
|
||||
|
||||
src0 = src1 + srcStep;
|
||||
dstY0 = dstY1 + dstStepY;
|
||||
dstUV += dstStepUV;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_VA
|
||||
|
||||
void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size)
|
||||
{
|
||||
(void)display; (void)src; (void)surface; (void)size;
|
||||
#if !defined(HAVE_VA)
|
||||
NO_VA_SUPPORT_ERROR;
|
||||
#else // !HAVE_VA
|
||||
const int stype = CV_8UC3;
|
||||
|
||||
int srcType = src.type();
|
||||
CV_Assert(srcType == stype);
|
||||
|
||||
Size srcSize = src.size();
|
||||
CV_Assert(srcSize.width == size.width && srcSize.height == size.height);
|
||||
|
||||
# if (defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL))
|
||||
if (contextInitialized)
|
||||
{
|
||||
UMat u = src.getUMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(u.offset == 0);
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
|
||||
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
|
||||
cl_int status = 0;
|
||||
|
||||
cl_mem clImageY = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_WRITE_ONLY, &surface, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (Y plane)");
|
||||
cl_mem clImageUV = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_WRITE_ONLY, &surface, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (UV plane)");
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
cl_mem images[2] = { clImageY, clImageUV };
|
||||
status = clEnqueueAcquireVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireVA_APIMediaSurfacesINTEL failed");
|
||||
if (!ocl::ocl_convert_bgr_to_nv12(clBuffer, (int)u.step[0], u.cols, u.rows, clImageY, clImageUV))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_bgr_to_nv12 failed");
|
||||
clEnqueueReleaseVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseVA_APIMediaSurfacesINTEL failed");
|
||||
|
||||
status = clFinish(q); // TODO Use events
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
|
||||
|
||||
status = clReleaseMemObject(clImageY); // TODO RAII
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (Y plane)");
|
||||
status = clReleaseMemObject(clImageUV);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (UV plane)");
|
||||
}
|
||||
else
|
||||
# endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
{
|
||||
Mat m = src.getMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(m.data == m.datastart);
|
||||
CV_Assert(m.isContinuous());
|
||||
|
||||
VAStatus status = 0;
|
||||
|
||||
status = vaSyncSurface(display, surface);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaSyncSurface failed");
|
||||
|
||||
VAImage image;
|
||||
status = vaDeriveImage(display, surface, &image);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaDeriveImage failed");
|
||||
|
||||
unsigned char* buffer = 0;
|
||||
status = vaMapBuffer(display, image.buf, (void **)&buffer);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
||||
|
||||
CV_Assert(image.format.fourcc == VA_FOURCC_NV12);
|
||||
|
||||
copy_convert_bgr_to_nv12(image, m, buffer);
|
||||
|
||||
status = vaUnmapBuffer(display, image.buf);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaUnmapBuffer failed");
|
||||
|
||||
status = vaDestroyImage(display, image.image_id);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaDestroyImage failed");
|
||||
}
|
||||
#endif // !HAVE_VA
|
||||
}
|
||||
|
||||
void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, OutputArray dst)
|
||||
{
|
||||
(void)display; (void)surface; (void)dst; (void)size;
|
||||
#if !defined(HAVE_VA)
|
||||
NO_VA_SUPPORT_ERROR;
|
||||
#else // !HAVE_VA
|
||||
const int dtype = CV_8UC3;
|
||||
|
||||
// TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying!
|
||||
dst.create(size, dtype);
|
||||
|
||||
# if (defined(HAVE_VA_INTEL) && defined(HAVE_OPENCL))
|
||||
if (contextInitialized)
|
||||
{
|
||||
UMat u = dst.getUMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(u.offset == 0);
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE);
|
||||
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
|
||||
cl_int status = 0;
|
||||
|
||||
cl_mem clImageY = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_READ_ONLY, &surface, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (Y plane)");
|
||||
cl_mem clImageUV = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_READ_ONLY, &surface, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (UV plane)");
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
cl_mem images[2] = { clImageY, clImageUV };
|
||||
status = clEnqueueAcquireVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireVA_APIMediaSurfacesINTEL failed");
|
||||
if (!ocl::ocl_convert_nv12_to_bgr(clImageY, clImageUV, clBuffer, (int)u.step[0], u.cols, u.rows))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_nv12_to_bgr failed");
|
||||
status = clEnqueueReleaseVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseVA_APIMediaSurfacesINTEL failed");
|
||||
|
||||
status = clFinish(q); // TODO Use events
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
|
||||
|
||||
status = clReleaseMemObject(clImageY); // TODO RAII
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (Y plane)");
|
||||
status = clReleaseMemObject(clImageUV);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (UV plane)");
|
||||
}
|
||||
else
|
||||
# endif // HAVE_VA_INTEL && HAVE_OPENCL
|
||||
{
|
||||
Mat m = dst.getMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(m.data == m.datastart);
|
||||
CV_Assert(m.isContinuous());
|
||||
|
||||
VAStatus status = 0;
|
||||
|
||||
status = vaSyncSurface(display, surface);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaSyncSurface failed");
|
||||
|
||||
VAImage image;
|
||||
status = vaDeriveImage(display, surface, &image);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaDeriveImage failed");
|
||||
|
||||
unsigned char* buffer = 0;
|
||||
status = vaMapBuffer(display, image.buf, (void **)&buffer);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
||||
|
||||
CV_Assert(image.format.fourcc == VA_FOURCC_NV12);
|
||||
|
||||
copy_convert_nv12_to_bgr(image, buffer, m);
|
||||
|
||||
status = vaUnmapBuffer(display, image.buf);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaUnmapBuffer failed");
|
||||
|
||||
status = vaDestroyImage(display, image.image_id);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
CV_Error(cv::Error::StsError, "VA-API: vaDestroyImage failed");
|
||||
}
|
||||
#endif // !HAVE_VA
|
||||
}
|
||||
|
||||
}} // namespace cv::va_intel
|
||||
@@ -1,302 +0,0 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
// Copyright (C) 2015, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_VAAPI
|
||||
#else // HAVE_VAAPI
|
||||
# define NO_VAAPI_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without VA-API support")
|
||||
#endif // HAVE_VAAPI
|
||||
|
||||
using namespace cv;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// CL-VA Interoperability
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
# include "opencv2/core/opencl/runtime/opencl_core.hpp"
|
||||
# include "opencv2/core.hpp"
|
||||
# include "opencv2/core/ocl.hpp"
|
||||
# include "opencl_kernels_core.hpp"
|
||||
#else // HAVE_OPENCL
|
||||
# define NO_OPENCL_SUPPORT_ERROR CV_ErrorNoReturn(cv::Error::StsBadFunc, "OpenCV was build without OpenCL support")
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
#if defined(HAVE_VAAPI) && defined(HAVE_OPENCL)
|
||||
# include <CL/va_ext.h>
|
||||
#endif // HAVE_VAAPI && HAVE_OPENCL
|
||||
|
||||
namespace cv { namespace vaapi {
|
||||
|
||||
#if defined(HAVE_VAAPI) && defined(HAVE_OPENCL)
|
||||
|
||||
static clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn clGetDeviceIDsFromVA_APIMediaAdapterINTEL = NULL;
|
||||
static clCreateFromVA_APIMediaSurfaceINTEL_fn clCreateFromVA_APIMediaSurfaceINTEL = NULL;
|
||||
static clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn clEnqueueAcquireVA_APIMediaSurfacesINTEL = NULL;
|
||||
static clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn clEnqueueReleaseVA_APIMediaSurfacesINTEL = NULL;
|
||||
|
||||
static bool contextInitialized = false;
|
||||
|
||||
#endif // HAVE_VAAPI && HAVE_OPENCL
|
||||
|
||||
namespace ocl {
|
||||
|
||||
Context& initializeContextFromVA(VADisplay display)
|
||||
{
|
||||
(void)display;
|
||||
#if !defined(HAVE_VAAPI)
|
||||
NO_VAAPI_SUPPORT_ERROR;
|
||||
#elif !defined(HAVE_OPENCL)
|
||||
NO_OPENCL_SUPPORT_ERROR;
|
||||
#else
|
||||
contextInitialized = false;
|
||||
|
||||
cl_uint numPlatforms;
|
||||
cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get number of platforms");
|
||||
if (numPlatforms == 0)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms");
|
||||
|
||||
std::vector<cl_platform_id> platforms(numPlatforms);
|
||||
status = clGetPlatformIDs(numPlatforms, &platforms[0], NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get platform Id list");
|
||||
|
||||
// For CL-VA interop, we must find platform/device with "cl_intel_va_api_media_sharing" extension.
|
||||
// With standard initialization procedure, we should examine platform extension string for that.
|
||||
// But in practice, the platform ext string doesn't contain it, while device ext string does.
|
||||
// Follow Intel procedure (see tutorial), we should obtain device IDs by extension call.
|
||||
// Note that we must obtain function pointers using specific platform ID, and can't provide pointers in advance.
|
||||
// So, we iterate and select the first platform, for which we got non-NULL pointers, device, and CL context.
|
||||
|
||||
int found = -1;
|
||||
cl_context context = 0;
|
||||
cl_device_id device = 0;
|
||||
|
||||
for (int i = 0; i < (int)numPlatforms; ++i)
|
||||
{
|
||||
// Get extension function pointers
|
||||
|
||||
clGetDeviceIDsFromVA_APIMediaAdapterINTEL = (clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clGetDeviceIDsFromVA_APIMediaAdapterINTEL");
|
||||
clCreateFromVA_APIMediaSurfaceINTEL = (clCreateFromVA_APIMediaSurfaceINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clCreateFromVA_APIMediaSurfaceINTEL");
|
||||
clEnqueueAcquireVA_APIMediaSurfacesINTEL = (clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clEnqueueAcquireVA_APIMediaSurfacesINTEL");
|
||||
clEnqueueReleaseVA_APIMediaSurfacesINTEL = (clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platforms[i], "clEnqueueReleaseVA_APIMediaSurfacesINTEL");
|
||||
|
||||
if (((void*)clGetDeviceIDsFromVA_APIMediaAdapterINTEL == NULL) ||
|
||||
((void*)clCreateFromVA_APIMediaSurfaceINTEL == NULL) ||
|
||||
((void*)clEnqueueAcquireVA_APIMediaSurfacesINTEL == NULL) ||
|
||||
((void*)clEnqueueReleaseVA_APIMediaSurfacesINTEL == NULL))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Query device list
|
||||
|
||||
cl_uint numDevices = 0;
|
||||
|
||||
status = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(platforms[i], CL_VA_API_DISPLAY_INTEL, display,
|
||||
CL_PREFERRED_DEVICES_FOR_VA_API_INTEL, 0, NULL, &numDevices);
|
||||
if ((status != CL_SUCCESS) || !(numDevices > 0))
|
||||
continue;
|
||||
numDevices = 1; // initializeContextFromHandle() expects only 1 device
|
||||
status = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(platforms[i], CL_VA_API_DISPLAY_INTEL, display,
|
||||
CL_PREFERRED_DEVICES_FOR_VA_API_INTEL, numDevices, &device, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
continue;
|
||||
|
||||
// Creating CL-VA media sharing OpenCL context
|
||||
|
||||
cl_context_properties props[] = {
|
||||
CL_CONTEXT_VA_API_DISPLAY_INTEL, (cl_context_properties) display,
|
||||
CL_CONTEXT_INTEROP_USER_SYNC, CL_FALSE, // no explicit sync required
|
||||
0
|
||||
};
|
||||
|
||||
context = clCreateContext(props, numDevices, &device, NULL, NULL, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
{
|
||||
clReleaseDevice(device);
|
||||
}
|
||||
else
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found < 0)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't create context for VA-API interop");
|
||||
|
||||
Context& ctx = Context::getDefault(false);
|
||||
initializeContextFromHandle(ctx, platforms[found], context, device);
|
||||
contextInitialized = true;
|
||||
return ctx;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_VAAPI) && defined(HAVE_OPENCL)
|
||||
static bool ocl_convert_nv12_to_bgr(cl_mem clImageY, cl_mem clImageUV, cl_mem clBuffer, int step, int cols, int rows)
|
||||
{
|
||||
ocl::Kernel k;
|
||||
k.create("YUV2BGR_NV12_8u", cv::ocl::core::cvtclr_dx_oclsrc, "");
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
k.args(clImageY, clImageUV, clBuffer, step, cols, rows);
|
||||
|
||||
size_t globalsize[] = { cols, rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
|
||||
static bool ocl_convert_bgr_to_nv12(cl_mem clBuffer, int step, int cols, int rows, cl_mem clImageY, cl_mem clImageUV)
|
||||
{
|
||||
ocl::Kernel k;
|
||||
k.create("BGR2YUV_NV12_8u", cv::ocl::core::cvtclr_dx_oclsrc, "");
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
k.args(clBuffer, step, cols, rows, clImageY, clImageUV);
|
||||
|
||||
size_t globalsize[] = { cols, rows };
|
||||
return k.run(2, globalsize, 0, false);
|
||||
}
|
||||
#endif // HAVE_VAAPI && HAVE_OPENCL
|
||||
|
||||
} // namespace cv::vaapi::ocl
|
||||
|
||||
void convertToVASurface(InputArray src, VASurfaceID surface, Size size)
|
||||
{
|
||||
(void)src; (void)surface; (void)size;
|
||||
#if !defined(HAVE_VAAPI)
|
||||
NO_VAAPI_SUPPORT_ERROR;
|
||||
#elif !defined(HAVE_OPENCL)
|
||||
NO_OPENCL_SUPPORT_ERROR;
|
||||
#else
|
||||
if (!contextInitialized)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Context for VA-API interop hasn't been created");
|
||||
|
||||
const int stype = CV_8UC4;
|
||||
|
||||
int srcType = src.type();
|
||||
CV_Assert(srcType == stype);
|
||||
|
||||
Size srcSize = src.size();
|
||||
CV_Assert(srcSize.width == size.width && srcSize.height == size.height);
|
||||
|
||||
UMat u = src.getUMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(u.offset == 0);
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
|
||||
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
|
||||
cl_int status = 0;
|
||||
|
||||
cl_mem clImageY = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_WRITE_ONLY, &surface, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (Y plane)");
|
||||
cl_mem clImageUV = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_WRITE_ONLY, &surface, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (UV plane)");
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
cl_mem images[2] = { clImageY, clImageUV };
|
||||
status = clEnqueueAcquireVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireVA_APIMediaSurfacesINTEL failed");
|
||||
if (!ocl::ocl_convert_bgr_to_nv12(clBuffer, (int)u.step[0], u.cols, u.rows, clImageY, clImageUV))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_bgr_to_nv12 failed");
|
||||
clEnqueueReleaseVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseVA_APIMediaSurfacesINTEL failed");
|
||||
|
||||
status = clFinish(q); // TODO Use events
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
|
||||
|
||||
status = clReleaseMemObject(clImageY); // TODO RAII
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (Y plane)");
|
||||
status = clReleaseMemObject(clImageUV);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (UV plane)");
|
||||
#endif
|
||||
}
|
||||
|
||||
void convertFromVASurface(VASurfaceID surface, Size size, OutputArray dst)
|
||||
{
|
||||
(void)surface; (void)dst; (void)size;
|
||||
#if !defined(HAVE_VAAPI)
|
||||
NO_VAAPI_SUPPORT_ERROR;
|
||||
#elif !defined(HAVE_OPENCL)
|
||||
NO_OPENCL_SUPPORT_ERROR;
|
||||
#else
|
||||
if (!contextInitialized)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Context for VA-API interop hasn't been created");
|
||||
|
||||
const int dtype = CV_8UC4;
|
||||
|
||||
// TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying!
|
||||
dst.create(size, dtype);
|
||||
UMat u = dst.getUMat();
|
||||
|
||||
// TODO Add support for roi
|
||||
CV_Assert(u.offset == 0);
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE);
|
||||
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
|
||||
cl_int status = 0;
|
||||
|
||||
cl_mem clImageY = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_READ_ONLY, &surface, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (Y plane)");
|
||||
cl_mem clImageUV = clCreateFromVA_APIMediaSurfaceINTEL(context, CL_MEM_READ_ONLY, &surface, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromVA_APIMediaSurfaceINTEL failed (UV plane)");
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
cl_mem images[2] = { clImageY, clImageUV };
|
||||
status = clEnqueueAcquireVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireVA_APIMediaSurfacesINTEL failed");
|
||||
if (!ocl::ocl_convert_nv12_to_bgr(clImageY, clImageUV, clBuffer, (int)u.step[0], u.cols, u.rows))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_nv12_to_bgr failed");
|
||||
status = clEnqueueReleaseVA_APIMediaSurfacesINTEL(q, 2, images, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseVA_APIMediaSurfacesINTEL failed");
|
||||
|
||||
status = clFinish(q); // TODO Use events
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed");
|
||||
|
||||
status = clReleaseMemObject(clImageY); // TODO RAII
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (Y plane)");
|
||||
status = clReleaseMemObject(clImageUV);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMem failed (UV plane)");
|
||||
#endif
|
||||
}
|
||||
|
||||
}} // namespace cv::vaapi
|
||||
@@ -1792,7 +1792,6 @@ INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine(
|
||||
testing::Values(-1, CV_16S, CV_32S, CV_32F),
|
||||
testing::Bool()));
|
||||
|
||||
|
||||
TEST(Core_FindNonZero, singular)
|
||||
{
|
||||
Mat img(10, 10, CV_8U, Scalar::all(0));
|
||||
@@ -1816,3 +1815,21 @@ TEST(Core_BoolVector, support)
|
||||
ASSERT_EQ( nz, countNonZero(test) );
|
||||
ASSERT_FLOAT_EQ((float)nz/n, (float)(mean(test)[0]));
|
||||
}
|
||||
|
||||
TEST(MinMaxLoc, Mat_IntMax_Without_Mask)
|
||||
{
|
||||
Mat_<int> mat(50, 50);
|
||||
int iMaxVal = numeric_limits<int>::max();
|
||||
mat.setTo(iMaxVal);
|
||||
|
||||
double min, max;
|
||||
Point minLoc, maxLoc;
|
||||
|
||||
minMaxLoc(mat, &min, &max, &minLoc, &maxLoc, Mat());
|
||||
|
||||
ASSERT_EQ(iMaxVal, min);
|
||||
ASSERT_EQ(iMaxVal, max);
|
||||
|
||||
ASSERT_EQ(Point(0, 0), minLoc);
|
||||
ASSERT_EQ(Point(0, 0), maxLoc);
|
||||
}
|
||||
|
||||
@@ -491,6 +491,7 @@ class Core_SeqBaseTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SeqBaseTest();
|
||||
virtual ~Core_SeqBaseTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -501,11 +502,14 @@ protected:
|
||||
int test_seq_ops( int iters );
|
||||
};
|
||||
|
||||
|
||||
Core_SeqBaseTest::Core_SeqBaseTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SeqBaseTest::~Core_SeqBaseTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SeqBaseTest::clear()
|
||||
{
|
||||
@@ -1206,6 +1210,7 @@ class Core_SetTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SetTest();
|
||||
virtual ~Core_SetTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1219,6 +1224,10 @@ Core_SetTest::Core_SetTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SetTest::~Core_SetTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SetTest::clear()
|
||||
{
|
||||
@@ -1417,6 +1426,7 @@ class Core_GraphTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_GraphTest();
|
||||
virtual ~Core_GraphTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1430,6 +1440,10 @@ Core_GraphTest::Core_GraphTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_GraphTest::~Core_GraphTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_GraphTest::clear()
|
||||
{
|
||||
@@ -2042,6 +2056,8 @@ void Core_GraphScanTest::run( int )
|
||||
CV_TS_SEQ_CHECK_CONDITION( vtx_count == 0 && edge_count == 0,
|
||||
"Not every vertex/edge has been visited" );
|
||||
update_progressbar();
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
// for a random graph the test just checks that every graph vertex and
|
||||
@@ -2106,8 +2122,6 @@ void Core_GraphScanTest::run( int )
|
||||
catch(int)
|
||||
{
|
||||
}
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -243,9 +243,11 @@ TEST_P(UMatBasicTests, GetUMat)
|
||||
EXPECT_MAT_NEAR(ub, ua, 0);
|
||||
}
|
||||
{
|
||||
Mat b;
|
||||
b = a.getUMat(ACCESS_RW).getMat(ACCESS_RW);
|
||||
EXPECT_MAT_NEAR(b, a, 0);
|
||||
UMat u = a.getUMat(ACCESS_RW);
|
||||
{
|
||||
Mat b = u.getMat(ACCESS_RW);
|
||||
EXPECT_MAT_NEAR(b, a, 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
Mat b;
|
||||
@@ -253,13 +255,15 @@ TEST_P(UMatBasicTests, GetUMat)
|
||||
EXPECT_MAT_NEAR(b, a, 0);
|
||||
}
|
||||
{
|
||||
UMat ub;
|
||||
ub = ua.getMat(ACCESS_RW).getUMat(ACCESS_RW);
|
||||
EXPECT_MAT_NEAR(ub, ua, 0);
|
||||
Mat m = ua.getMat(ACCESS_RW);
|
||||
{
|
||||
UMat ub = m.getUMat(ACCESS_RW);
|
||||
EXPECT_MAT_NEAR(ub, ua, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(UMat, UMatBasicTests, Combine(testing::Values(CV_8U), testing::Values(1, 2),
|
||||
INSTANTIATE_TEST_CASE_P(UMat, UMatBasicTests, Combine(testing::Values(CV_8U, CV_64F), testing::Values(1, 2),
|
||||
testing::Values(cv::Size(1, 1), cv::Size(1, 128), cv::Size(128, 1), cv::Size(128, 128), cv::Size(640, 480)), Bool()));
|
||||
|
||||
//////////////////////////////////////////////////////////////// Reshape ////////////////////////////////////////////////////////////////////////
|
||||
@@ -1080,7 +1084,7 @@ TEST(UMat, unmap_in_class)
|
||||
Mat dst;
|
||||
m.convertTo(dst, CV_32FC1);
|
||||
// some additional CPU-based per-pixel processing into dst
|
||||
intermediateResult = dst.getUMat(ACCESS_READ);
|
||||
intermediateResult = dst.getUMat(ACCESS_READ); // this violates lifetime of base(dst) / derived (intermediateResult) objects. Use copyTo?
|
||||
std::cout << "data processed..." << std::endl;
|
||||
} // problem is here: dst::~Mat()
|
||||
std::cout << "leave ProcessData()" << std::endl;
|
||||
@@ -1268,5 +1272,69 @@ TEST(UMat, DISABLED_Test_same_behaviour_write_and_write)
|
||||
ASSERT_TRUE(exceptionDetected); // data race
|
||||
}
|
||||
|
||||
TEST(UMat, mat_umat_sync)
|
||||
{
|
||||
UMat u(10, 10, CV_8UC1, Scalar(1));
|
||||
{
|
||||
Mat m = u.getMat(ACCESS_RW).reshape(1);
|
||||
m.setTo(Scalar(255));
|
||||
}
|
||||
|
||||
UMat uDiff;
|
||||
compare(u, 255, uDiff, CMP_NE);
|
||||
ASSERT_EQ(0, countNonZero(uDiff));
|
||||
}
|
||||
|
||||
TEST(UMat, testTempObjects_UMat)
|
||||
{
|
||||
UMat u(10, 10, CV_8UC1, Scalar(1));
|
||||
{
|
||||
UMat u2 = u.getMat(ACCESS_RW).getUMat(ACCESS_RW);
|
||||
u2.setTo(Scalar(255));
|
||||
}
|
||||
|
||||
UMat uDiff;
|
||||
compare(u, 255, uDiff, CMP_NE);
|
||||
ASSERT_EQ(0, countNonZero(uDiff));
|
||||
}
|
||||
|
||||
// Disabled due to failure in VS 2015:
|
||||
// C++11 is enabled by default ==>
|
||||
// destructors have implicit 'noexcept(true)' specifier ==>
|
||||
// throwing exception from destructor is not handled correctly
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 /* MSVC 14 */
|
||||
TEST(UMat, DISABLED_testTempObjects_Mat)
|
||||
#else
|
||||
TEST(UMat, testTempObjects_Mat)
|
||||
#endif
|
||||
{
|
||||
Mat m(10, 10, CV_8UC1, Scalar(1));
|
||||
{
|
||||
Mat m2;
|
||||
ASSERT_ANY_THROW(m2 = m.getUMat(ACCESS_RW).getMat(ACCESS_RW));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UMat, testWrongLifetime_UMat)
|
||||
{
|
||||
UMat u(10, 10, CV_8UC1, Scalar(1));
|
||||
{
|
||||
UMat u2 = u.getMat(ACCESS_RW).getUMat(ACCESS_RW);
|
||||
u.release(); // base object
|
||||
u2.release(); // derived object, should show warning message
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UMat, testWrongLifetime_Mat)
|
||||
{
|
||||
Mat m(10, 10, CV_8UC1, Scalar(1));
|
||||
{
|
||||
UMat u = m.getUMat(ACCESS_RW);
|
||||
Mat m2 = u.getMat(ACCESS_RW);
|
||||
m.release(); // base object
|
||||
m2.release(); // map of derived object
|
||||
u.release(); // derived object, should show warning message
|
||||
}
|
||||
}
|
||||
|
||||
} } // namespace cvtest::ocl
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
namespace {
|
||||
|
||||
static const char * const keys =
|
||||
"{ h help | | print help }"
|
||||
"{ i info | false | print info }"
|
||||
"{ t true | true | true value }"
|
||||
"{ n unused | | dummy }"
|
||||
;
|
||||
|
||||
TEST(CommandLineParser, testFailure)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-q"};
|
||||
const int argc = 2;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_ANY_THROW(parser.has("q"));
|
||||
EXPECT_ANY_THROW(parser.get<bool>("q"));
|
||||
EXPECT_ANY_THROW(parser.get<bool>(0));
|
||||
|
||||
parser.get<bool>("h");
|
||||
EXPECT_FALSE(parser.check());
|
||||
}
|
||||
TEST(CommandLineParser, testHas_noValues)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h", "--info"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_TRUE(parser.has("help"));
|
||||
EXPECT_TRUE(parser.has("h"));
|
||||
EXPECT_TRUE(parser.has("info"));
|
||||
EXPECT_TRUE(parser.has("i"));
|
||||
EXPECT_FALSE(parser.has("n"));
|
||||
EXPECT_FALSE(parser.has("unused"));
|
||||
}
|
||||
TEST(CommandLineParser, testHas_TrueValues)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h=TRUE", "--info=true"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_TRUE(parser.has("help"));
|
||||
EXPECT_TRUE(parser.has("h"));
|
||||
EXPECT_TRUE(parser.has("info"));
|
||||
EXPECT_TRUE(parser.has("i"));
|
||||
EXPECT_FALSE(parser.has("n"));
|
||||
EXPECT_FALSE(parser.has("unused"));
|
||||
}
|
||||
TEST(CommandLineParser, testHas_TrueValues1)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h=1", "--info=1"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_TRUE(parser.has("help"));
|
||||
EXPECT_TRUE(parser.has("h"));
|
||||
EXPECT_TRUE(parser.has("info"));
|
||||
EXPECT_TRUE(parser.has("i"));
|
||||
EXPECT_FALSE(parser.has("n"));
|
||||
EXPECT_FALSE(parser.has("unused"));
|
||||
}
|
||||
TEST(CommandLineParser, testHas_FalseValues0)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h=0", "--info=0"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_TRUE(parser.has("help"));
|
||||
EXPECT_TRUE(parser.has("h"));
|
||||
EXPECT_TRUE(parser.has("info"));
|
||||
EXPECT_TRUE(parser.has("i"));
|
||||
EXPECT_FALSE(parser.has("n"));
|
||||
EXPECT_FALSE(parser.has("unused"));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testBoolOption_noArgs)
|
||||
{
|
||||
const char* argv[] = {"<bin>"};
|
||||
const int argc = 1;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_FALSE(parser.get<bool>("help"));
|
||||
EXPECT_FALSE(parser.get<bool>("h"));
|
||||
EXPECT_FALSE(parser.get<bool>("info"));
|
||||
EXPECT_FALSE(parser.get<bool>("i"));
|
||||
EXPECT_TRUE(parser.get<bool>("true")); // default is true
|
||||
EXPECT_TRUE(parser.get<bool>("t"));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testBoolOption_noValues)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h", "--info"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_TRUE(parser.get<bool>("help"));
|
||||
EXPECT_TRUE(parser.get<bool>("h"));
|
||||
EXPECT_TRUE(parser.get<bool>("info"));
|
||||
EXPECT_TRUE(parser.get<bool>("i"));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testBoolOption_TrueValues)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h=TRUE", "--info=true"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
//EXPECT_TRUE(parser.get<bool>("help"));
|
||||
//EXPECT_TRUE(parser.get<bool>("h"));
|
||||
EXPECT_TRUE(parser.get<bool>("info"));
|
||||
EXPECT_TRUE(parser.get<bool>("i"));
|
||||
EXPECT_FALSE(parser.get<bool>("unused"));
|
||||
EXPECT_FALSE(parser.get<bool>("n"));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testBoolOption_FalseValues)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "--help=FALSE", "-i=false"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
EXPECT_FALSE(parser.get<bool>("help"));
|
||||
EXPECT_FALSE(parser.get<bool>("h"));
|
||||
EXPECT_FALSE(parser.get<bool>("info"));
|
||||
EXPECT_FALSE(parser.get<bool>("i"));
|
||||
}
|
||||
|
||||
|
||||
static const char * const keys2 =
|
||||
"{ h help | | print help }"
|
||||
"{ @arg1 | default1 | param1 }"
|
||||
"{ @arg2 | | param2 }"
|
||||
"{ n unused | | dummy }"
|
||||
;
|
||||
|
||||
TEST(CommandLineParser, testPositional_noArgs)
|
||||
{
|
||||
const char* argv[] = {"<bin>"};
|
||||
const int argc = 1;
|
||||
cv::CommandLineParser parser(argc, argv, keys2);
|
||||
EXPECT_TRUE(parser.has("@arg1"));
|
||||
EXPECT_FALSE(parser.has("@arg2"));
|
||||
EXPECT_EQ("default1", parser.get<String>("@arg1"));
|
||||
EXPECT_EQ("default1", parser.get<String>(0));
|
||||
|
||||
EXPECT_EQ("", parser.get<String>("@arg2"));
|
||||
EXPECT_EQ("", parser.get<String>(1));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testPositional_default)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "test1", "test2"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys2);
|
||||
EXPECT_TRUE(parser.has("@arg1"));
|
||||
EXPECT_TRUE(parser.has("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>("@arg1"));
|
||||
EXPECT_EQ("test2", parser.get<String>("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>(0));
|
||||
EXPECT_EQ("test2", parser.get<String>(1));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testPositional_withFlagsBefore)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "-h", "test1", "test2"};
|
||||
const int argc = 4;
|
||||
cv::CommandLineParser parser(argc, argv, keys2);
|
||||
EXPECT_TRUE(parser.has("@arg1"));
|
||||
EXPECT_TRUE(parser.has("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>("@arg1"));
|
||||
EXPECT_EQ("test2", parser.get<String>("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>(0));
|
||||
EXPECT_EQ("test2", parser.get<String>(1));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testPositional_withFlagsAfter)
|
||||
{
|
||||
const char* argv[] = {"<bin>", "test1", "test2", "-h"};
|
||||
const int argc = 4;
|
||||
cv::CommandLineParser parser(argc, argv, keys2);
|
||||
EXPECT_TRUE(parser.has("@arg1"));
|
||||
EXPECT_TRUE(parser.has("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>("@arg1"));
|
||||
EXPECT_EQ("test2", parser.get<String>("@arg2"));
|
||||
EXPECT_EQ("test1", parser.get<String>(0));
|
||||
EXPECT_EQ("test2", parser.get<String>(1));
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testEmptyStringValue)
|
||||
{
|
||||
static const char * const keys3 =
|
||||
"{ @pos0 | | empty default value }"
|
||||
"{ @pos1 | <none> | forbid empty default value }";
|
||||
|
||||
const char* argv[] = {"<bin>"};
|
||||
const int argc = 1;
|
||||
cv::CommandLineParser parser(argc, argv, keys3);
|
||||
// EXPECT_TRUE(parser.has("@pos0"));
|
||||
EXPECT_EQ("", parser.get<String>("@pos0"));
|
||||
EXPECT_TRUE(parser.check());
|
||||
|
||||
EXPECT_FALSE(parser.has("@pos1"));
|
||||
parser.get<String>(1);
|
||||
EXPECT_FALSE(parser.check());
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, positional_regression_5074_equal_sign)
|
||||
{
|
||||
static const char * const keys3 =
|
||||
"{ @eq0 | | }"
|
||||
"{ eq1 | | }";
|
||||
|
||||
const char* argv[] = {"<bin>", "1=0", "--eq1=1=0"};
|
||||
const int argc = 3;
|
||||
cv::CommandLineParser parser(argc, argv, keys3);
|
||||
EXPECT_EQ("1=0", parser.get<String>("@eq0"));
|
||||
EXPECT_EQ("1=0", parser.get<String>(0));
|
||||
EXPECT_EQ("1=0", parser.get<String>("eq1"));
|
||||
EXPECT_TRUE(parser.check());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -249,6 +249,10 @@ void cv::cuda::normalize(InputArray _src, OutputArray _dst, double a, double b,
|
||||
CV_Assert( src.channels() == 1 );
|
||||
CV_Assert( mask.empty() || (mask.size() == src.size() && mask.type() == CV_8U) );
|
||||
|
||||
if (dtype < 0)
|
||||
{
|
||||
dtype = _dst.fixedType() ? _dst.type() : src.type();
|
||||
}
|
||||
dtype = CV_MAT_DEPTH(dtype);
|
||||
|
||||
const int src_depth = src.depth();
|
||||
|
||||
@@ -951,11 +951,11 @@ CUDA_TEST_P(Normalize, WithMask)
|
||||
|
||||
cv::cuda::GpuMat dst = createMat(size, type, useRoi);
|
||||
dst.setTo(cv::Scalar::all(0));
|
||||
cv::cuda::normalize(loadMat(src, useRoi), dst, alpha, beta, norm_type, type, loadMat(mask, useRoi));
|
||||
cv::cuda::normalize(loadMat(src, useRoi), dst, alpha, beta, norm_type, -1, loadMat(mask, useRoi));
|
||||
|
||||
cv::Mat dst_gold(size, type);
|
||||
dst_gold.setTo(cv::Scalar::all(0));
|
||||
cv::normalize(src, dst_gold, alpha, beta, norm_type, type, mask);
|
||||
cv::normalize(src, dst_gold, alpha, beta, norm_type, -1, mask);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, type < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace cv { namespace cuda { namespace device
|
||||
float sigma_color2_inv_half = -0.5f/(sigma_color * sigma_color);
|
||||
|
||||
cudaSafeCall( cudaFuncSetCacheConfig (bilateral_kernel<T, B<T> >, cudaFuncCachePreferL1) );
|
||||
bilateral_kernel<<<grid, block>>>((PtrStepSz<T>)src, (PtrStepSz<T>)dst, b, kernel_size, sigma_spatial2_inv_half, sigma_color2_inv_half);
|
||||
bilateral_kernel<<<grid, block, 0, stream>>>((PtrStepSz<T>)src, (PtrStepSz<T>)dst, b, kernel_size, sigma_spatial2_inv_half, sigma_color2_inv_half);
|
||||
cudaSafeCall ( cudaGetLastError () );
|
||||
|
||||
if (stream == 0)
|
||||
|
||||
@@ -32,6 +32,10 @@ if(OCV_DEPENDENCIES_FOUND)
|
||||
ocv_target_link_libraries(${the_target} ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES})
|
||||
add_dependencies(opencv_tests ${the_target})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL}")
|
||||
set_source_files_properties(${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}
|
||||
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
|
||||
|
||||
# Additional target properties
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
@@ -42,9 +46,7 @@ if(OCV_DEPENDENCIES_FOUND)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
get_target_property(LOC ${the_target} LOCATION)
|
||||
add_test(${the_target} "${LOC}")
|
||||
ocv_add_test_from_target("${the_target}" "Accuracy" "${the_target}")
|
||||
|
||||
if(INSTALL_TESTS)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
|
||||
@@ -7511,19 +7511,22 @@ Ptr<AgastFeatureDetector> AgastFeatureDetector::create( int threshold, bool nonm
|
||||
|
||||
void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
|
||||
{
|
||||
|
||||
std::vector<KeyPoint> kpts;
|
||||
|
||||
// detect
|
||||
switch(type) {
|
||||
case AgastFeatureDetector::AGAST_5_8:
|
||||
AGAST_5_8(_img, keypoints, threshold);
|
||||
AGAST_5_8(_img, kpts, threshold);
|
||||
break;
|
||||
case AgastFeatureDetector::AGAST_7_12d:
|
||||
AGAST_7_12d(_img, keypoints, threshold);
|
||||
AGAST_7_12d(_img, kpts, threshold);
|
||||
break;
|
||||
case AgastFeatureDetector::AGAST_7_12s:
|
||||
AGAST_7_12s(_img, keypoints, threshold);
|
||||
AGAST_7_12s(_img, kpts, threshold);
|
||||
break;
|
||||
case AgastFeatureDetector::OAST_9_16:
|
||||
OAST_9_16(_img, keypoints, threshold);
|
||||
OAST_9_16(_img, kpts, threshold);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7534,7 +7537,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
makeAgastOffsets(pixel_, (int)img.step, type);
|
||||
|
||||
std::vector<KeyPoint>::iterator kpt;
|
||||
for(kpt = keypoints.begin(); kpt != keypoints.end(); kpt++)
|
||||
for(kpt = kpts.begin(); kpt != kpts.end(); kpt++)
|
||||
{
|
||||
switch(type) {
|
||||
case AgastFeatureDetector::AGAST_5_8:
|
||||
@@ -7555,20 +7558,21 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// suppression
|
||||
if(nonmax_suppression)
|
||||
{
|
||||
size_t j;
|
||||
size_t curr_idx;
|
||||
size_t lastRow = 0, next_lastRow = 0;
|
||||
size_t num_Corners = keypoints.size();
|
||||
size_t num_Corners = kpts.size();
|
||||
size_t lastRowCorner_ind = 0, next_lastRowCorner_ind = 0;
|
||||
|
||||
std::vector<int> nmsFlags;
|
||||
std::vector<KeyPoint>::iterator currCorner_nms;
|
||||
std::vector<KeyPoint>::const_iterator currCorner;
|
||||
|
||||
currCorner = keypoints.begin();
|
||||
currCorner = kpts.begin();
|
||||
|
||||
nmsFlags.resize((int)num_Corners);
|
||||
|
||||
@@ -7593,11 +7597,11 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
if(lastRow + 1 == currCorner->pt.y)
|
||||
{
|
||||
// find the corner above the current one
|
||||
while( (keypoints[lastRowCorner_ind].pt.x < currCorner->pt.x)
|
||||
&& (keypoints[lastRowCorner_ind].pt.y == lastRow) )
|
||||
while( (kpts[lastRowCorner_ind].pt.x < currCorner->pt.x)
|
||||
&& (kpts[lastRowCorner_ind].pt.y == lastRow) )
|
||||
lastRowCorner_ind++;
|
||||
|
||||
if( (keypoints[lastRowCorner_ind].pt.x == currCorner->pt.x)
|
||||
if( (kpts[lastRowCorner_ind].pt.x == currCorner->pt.x)
|
||||
&& (lastRowCorner_ind != curr_idx) )
|
||||
{
|
||||
size_t w = lastRowCorner_ind;
|
||||
@@ -7605,7 +7609,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
while(nmsFlags[w] != -1)
|
||||
w = nmsFlags[w];
|
||||
|
||||
if(keypoints[curr_idx].response < keypoints[w].response)
|
||||
if(kpts[curr_idx].response < kpts[w].response)
|
||||
nmsFlags[curr_idx] = (int)w;
|
||||
else
|
||||
nmsFlags[w] = (int)curr_idx;
|
||||
@@ -7614,8 +7618,8 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
|
||||
// check left
|
||||
t = (int)curr_idx - 1;
|
||||
if( (curr_idx != 0) && (keypoints[t].pt.y == currCorner->pt.y)
|
||||
&& (keypoints[t].pt.x + 1 == currCorner->pt.x) )
|
||||
if( (curr_idx != 0) && (kpts[t].pt.y == currCorner->pt.y)
|
||||
&& (kpts[t].pt.x + 1 == currCorner->pt.x) )
|
||||
{
|
||||
int currCornerMaxAbove_ind = nmsFlags[curr_idx];
|
||||
// find the maximum in that area
|
||||
@@ -7626,7 +7630,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
{
|
||||
if((size_t)t != curr_idx)
|
||||
{
|
||||
if ( keypoints[curr_idx].response < keypoints[t].response )
|
||||
if ( kpts[curr_idx].response < kpts[t].response )
|
||||
nmsFlags[curr_idx] = t;
|
||||
else
|
||||
nmsFlags[t] = (int)curr_idx;
|
||||
@@ -7636,7 +7640,7 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
{
|
||||
if(t != currCornerMaxAbove_ind)
|
||||
{
|
||||
if(keypoints[currCornerMaxAbove_ind].response < keypoints[t].response)
|
||||
if(kpts[currCornerMaxAbove_ind].response < kpts[t].response)
|
||||
{
|
||||
nmsFlags[currCornerMaxAbove_ind] = t;
|
||||
nmsFlags[curr_idx] = t;
|
||||
@@ -7652,19 +7656,15 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
|
||||
currCorner++;
|
||||
}
|
||||
|
||||
// marks non-maximum corners
|
||||
// collecting maximum corners
|
||||
for(curr_idx = 0; curr_idx < num_Corners; curr_idx++)
|
||||
{
|
||||
if (nmsFlags[curr_idx] != -1)
|
||||
keypoints[curr_idx].response = -1;
|
||||
}
|
||||
|
||||
// erase non-maximum corners
|
||||
for (j = keypoints.size(); j > 0; j--)
|
||||
{
|
||||
if (keypoints[j - 1].response == -1)
|
||||
keypoints.erase(keypoints.begin() + j - 1 );
|
||||
if (nmsFlags[curr_idx] == -1)
|
||||
keypoints.push_back(kpts[curr_idx]);
|
||||
}
|
||||
} else
|
||||
{
|
||||
keypoints = kpts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
|
||||
UMat img = _img.getUMat();
|
||||
if( img.cols < 7 || img.rows < 7 )
|
||||
return false;
|
||||
size_t globalsize[] = { img.cols-6, img.rows-6 };
|
||||
size_t globalsize[] = { (size_t)img.cols-6, (size_t)img.rows-6 };
|
||||
|
||||
ocl::Kernel fastKptKernel("FAST_findKeypoints", ocl::features2d::fast_oclsrc);
|
||||
if (fastKptKernel.empty())
|
||||
@@ -306,7 +306,7 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
|
||||
if (fastNMSKernel.empty())
|
||||
return false;
|
||||
|
||||
size_t globalsize_nms[] = { counter };
|
||||
size_t globalsize_nms[] = { (size_t)counter };
|
||||
if( !fastNMSKernel.args(ocl::KernelArg::PtrReadOnly(kp1),
|
||||
ocl::KernelArg::PtrReadWrite(kp2),
|
||||
ocl::KernelArg::ReadOnly(img),
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*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) 2015, Itseez 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*/
|
||||
|
||||
//
|
||||
// Library initialization file
|
||||
//
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
IPP_INITIALIZER_AUTO
|
||||
|
||||
/* End of file. */
|
||||
@@ -97,8 +97,8 @@ static bool ocl_matchSingle(InputArray query, InputArray train,
|
||||
if(k.empty())
|
||||
return false;
|
||||
|
||||
size_t globalSize[] = {(query.size().height + block_size - 1) / block_size * block_size, block_size};
|
||||
size_t localSize[] = {block_size, block_size};
|
||||
size_t globalSize[] = {((size_t)query.size().height + block_size - 1) / block_size * block_size, (size_t)block_size};
|
||||
size_t localSize[] = {(size_t)block_size, (size_t)block_size};
|
||||
|
||||
int idx = 0;
|
||||
idx = k.set(idx, ocl::KernelArg::PtrReadOnly(uquery));
|
||||
@@ -197,8 +197,8 @@ static bool ocl_knnMatchSingle(InputArray query, InputArray train, UMat &trainId
|
||||
if(k.empty())
|
||||
return false;
|
||||
|
||||
size_t globalSize[] = {(query_rows + block_size - 1) / block_size * block_size, block_size};
|
||||
size_t localSize[] = {block_size, block_size};
|
||||
size_t globalSize[] = {((size_t)query_rows + block_size - 1) / block_size * block_size, (size_t)block_size};
|
||||
size_t localSize[] = {(size_t)block_size, (size_t)block_size};
|
||||
|
||||
int idx = 0;
|
||||
idx = k.set(idx, ocl::KernelArg::PtrReadOnly(uquery));
|
||||
@@ -306,8 +306,8 @@ static bool ocl_radiusMatchSingle(InputArray query, InputArray train,
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
size_t globalSize[] = {(train_rows + block_size - 1) / block_size * block_size, (query_rows + block_size - 1) / block_size * block_size};
|
||||
size_t localSize[] = {block_size, block_size};
|
||||
size_t globalSize[] = {((size_t)train_rows + block_size - 1) / block_size * block_size, ((size_t)query_rows + block_size - 1) / block_size * block_size};
|
||||
size_t localSize[] = {(size_t)block_size, (size_t)block_size};
|
||||
|
||||
int idx = 0;
|
||||
idx = k.set(idx, ocl::KernelArg::PtrReadOnly(uquery));
|
||||
|
||||
@@ -64,7 +64,7 @@ ocl_HarrisResponses(const UMat& imgbuf,
|
||||
UMat& responses,
|
||||
int nkeypoints, int blockSize, float harris_k)
|
||||
{
|
||||
size_t globalSize[] = {nkeypoints};
|
||||
size_t globalSize[] = {(size_t)nkeypoints};
|
||||
|
||||
float scale = 1.f/((1 << 2) * blockSize * 255.f);
|
||||
float scale_sq_sq = scale * scale * scale * scale;
|
||||
@@ -86,7 +86,7 @@ ocl_ICAngles(const UMat& imgbuf, const UMat& layerinfo,
|
||||
const UMat& keypoints, UMat& responses,
|
||||
const UMat& umax, int nkeypoints, int half_k)
|
||||
{
|
||||
size_t globalSize[] = {nkeypoints};
|
||||
size_t globalSize[] = {(size_t)nkeypoints};
|
||||
|
||||
ocl::Kernel icangle_ker("ORB_ICAngle", ocl::features2d::orb_oclsrc, "-D ORB_ANGLES");
|
||||
if( icangle_ker.empty() )
|
||||
@@ -106,7 +106,7 @@ ocl_computeOrbDescriptors(const UMat& imgbuf, const UMat& layerInfo,
|
||||
const UMat& keypoints, UMat& desc, const UMat& pattern,
|
||||
int nkeypoints, int dsize, int wta_k)
|
||||
{
|
||||
size_t globalSize[] = {nkeypoints};
|
||||
size_t globalSize[] = {(size_t)nkeypoints};
|
||||
|
||||
ocl::Kernel desc_ker("ORB_computeDescriptor", ocl::features2d::orb_oclsrc,
|
||||
format("-D ORB_DESCRIPTORS -D WTA_K=%d", wta_k));
|
||||
|
||||
@@ -60,7 +60,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
|
||||
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
|
||||
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
|
||||
fwrite( (void*)&type, sizeof(int), 1, f );
|
||||
int dataSize = (int)(mat.step * mat.rows * mat.channels());
|
||||
int dataSize = (int)(mat.step * mat.rows);
|
||||
fwrite( (void*)&dataSize, sizeof(int), 1, f );
|
||||
fwrite( (void*)mat.ptr(), 1, dataSize, f );
|
||||
fclose(f);
|
||||
@@ -82,13 +82,14 @@ static Mat readMatFromBin( const string& filename )
|
||||
int step = dataSize / rows / CV_ELEM_SIZE(type);
|
||||
CV_Assert(step >= cols);
|
||||
|
||||
Mat m = Mat(rows, step, type).colRange(0, cols);
|
||||
Mat returnMat = Mat(rows, step, type).colRange(0, cols);
|
||||
|
||||
size_t elements_read = fread( m.ptr(), 1, dataSize, f );
|
||||
size_t elements_read = fread( returnMat.ptr(), 1, dataSize, f );
|
||||
CV_Assert(elements_read == (size_t)(dataSize));
|
||||
|
||||
fclose(f);
|
||||
|
||||
return m;
|
||||
return returnMat;
|
||||
}
|
||||
return Mat();
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ protected:
|
||||
virtual void run( int start_from );
|
||||
virtual void createModel( const Mat& data ) = 0;
|
||||
virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0;
|
||||
virtual int checkGetPoins( const Mat& data );
|
||||
virtual int checkGetPoints( const Mat& data );
|
||||
virtual int checkFindBoxed();
|
||||
virtual int checkFind( const Mat& data );
|
||||
virtual void releaseModel() = 0;
|
||||
};
|
||||
|
||||
int NearestNeighborTest::checkGetPoins( const Mat& )
|
||||
int NearestNeighborTest::checkGetPoints( const Mat& )
|
||||
{
|
||||
return cvtest::TS::OK;
|
||||
}
|
||||
@@ -127,11 +127,11 @@ int NearestNeighborTest::checkFind( const Mat& data )
|
||||
void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
int code = cvtest::TS::OK, tempCode;
|
||||
Mat desc( featuresCount, dims, CV_32FC1 );
|
||||
randu( desc, Scalar(minValue), Scalar(maxValue) );
|
||||
ts->get_rng().fill( desc, RNG::UNIFORM, minValue, maxValue );
|
||||
|
||||
createModel( desc );
|
||||
|
||||
tempCode = checkGetPoins( desc );
|
||||
tempCode = checkGetPoints( desc );
|
||||
if( tempCode != cvtest::TS::OK )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" );
|
||||
@@ -161,7 +161,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
class CV_FlannTest : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_FlannTest() {}
|
||||
CV_FlannTest() : NearestNeighborTest(), index(NULL) { }
|
||||
protected:
|
||||
void createIndex( const Mat& data, const IndexParams& params );
|
||||
int knnSearch( Mat& points, Mat& neighbors );
|
||||
@@ -172,6 +172,9 @@ protected:
|
||||
|
||||
void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params )
|
||||
{
|
||||
// release previously allocated index
|
||||
releaseModel();
|
||||
|
||||
index = new Index( data, params );
|
||||
}
|
||||
|
||||
@@ -238,7 +241,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
|
||||
|
||||
void CV_FlannTest::releaseModel()
|
||||
{
|
||||
delete index;
|
||||
if (index)
|
||||
{
|
||||
delete index;
|
||||
index = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
@@ -377,6 +377,7 @@ private:
|
||||
// evaluate kdtree for all parameter combinations
|
||||
for (size_t i = 0; i < FLANN_ARRAY_LEN(testTrees); ++i) {
|
||||
CostData cost;
|
||||
cost.params["algorithm"] = FLANN_INDEX_KDTREE;
|
||||
cost.params["trees"] = testTrees[i];
|
||||
|
||||
evaluate_kdtree(cost);
|
||||
|
||||
@@ -441,6 +441,8 @@ public:
|
||||
}
|
||||
|
||||
root_ = pool_.allocate<KMeansNode>();
|
||||
std::memset(root_, 0, sizeof(KMeansNode));
|
||||
|
||||
computeNodeStatistics(root_, indices_, (int)size_);
|
||||
computeClustering(root_, indices_, (int)size_, branching_,0);
|
||||
}
|
||||
@@ -864,11 +866,11 @@ private:
|
||||
variance -= distance_(centers[c], ZeroIterator<ElementType>(), veclen_);
|
||||
|
||||
node->childs[c] = pool_.allocate<KMeansNode>();
|
||||
std::memset(node->childs[c], 0, sizeof(KMeansNode));
|
||||
node->childs[c]->radius = radiuses[c];
|
||||
node->childs[c]->pivot = centers[c];
|
||||
node->childs[c]->variance = variance;
|
||||
node->childs[c]->mean_radius = mean_radius;
|
||||
node->childs[c]->indices = NULL;
|
||||
computeClustering(node->childs[c],indices+start, end-start, branching, level+1);
|
||||
start=end;
|
||||
}
|
||||
|
||||
@@ -49,10 +49,21 @@
|
||||
|
||||
/**
|
||||
@defgroup hal Hardware Acceleration Layer
|
||||
@{
|
||||
@defgroup hal_intrin Universal intrinsics
|
||||
@{
|
||||
@defgroup hal_intrin_impl Private implementation helpers
|
||||
@}
|
||||
@defgroup hal_utils Platform-dependent utils
|
||||
@}
|
||||
*/
|
||||
|
||||
|
||||
namespace cv { namespace hal {
|
||||
|
||||
//! @addtogroup hal
|
||||
//! @{
|
||||
|
||||
namespace Error {
|
||||
|
||||
enum
|
||||
@@ -93,6 +104,8 @@ void sqrt(const double* src, double* dst, int len);
|
||||
void invSqrt(const float* src, float* dst, int len);
|
||||
void invSqrt(const double* src, double* dst, int len);
|
||||
|
||||
//! @}
|
||||
|
||||
}} //cv::hal
|
||||
|
||||
#endif //__OPENCV_HAL_HPP__
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#ifndef __OPENCV_DEF_H__
|
||||
#define __OPENCV_DEF_H__
|
||||
|
||||
//! @addtogroup hal_utils
|
||||
//! @{
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
|
||||
#endif
|
||||
@@ -335,9 +338,6 @@ Cv64suf;
|
||||
# include "tegra_round.hpp"
|
||||
#endif
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
#if CV_VFP
|
||||
// 1. general scheme
|
||||
#define ARM_ROUND(_value, _asm_string) \
|
||||
@@ -567,15 +567,19 @@ CV_INLINE int cvIsInf( float value )
|
||||
return (ieee754.u & 0x7fffffff) == 0x7f800000;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup hal_utils
|
||||
//! @{
|
||||
|
||||
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
||||
|
||||
/**
|
||||
Template function for accurate conversion from one primitive type to another.
|
||||
/** @brief Template function for accurate conversion from one primitive type to another.
|
||||
|
||||
The functions saturate_cast resemble the standard C++ cast operations, such as static_cast\<T\>()
|
||||
and others. They perform an efficient and accurate conversion from one primitive type to another
|
||||
@@ -618,8 +622,6 @@ template<typename _Tp> static inline _Tp saturate_cast(int64 v) { return _Tp(
|
||||
/** @overload */
|
||||
template<typename _Tp> static inline _Tp saturate_cast(uint64 v) { return _Tp(v); }
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
template<> inline uchar saturate_cast<uchar>(schar v) { return (uchar)std::max((int)v, 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); }
|
||||
template<> inline uchar saturate_cast<uchar>(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); }
|
||||
@@ -664,12 +666,10 @@ template<> inline int saturate_cast<int>(double v) { return cvRound(v)
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v) { return cvRound(v); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
|
||||
|
||||
//! @endcond
|
||||
//! @}
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
//! @} core_utils
|
||||
|
||||
#endif //__OPENCV_HAL_H__
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <stdlib.h>
|
||||
#include "opencv2/hal/defs.h"
|
||||
|
||||
#define OPENCV_HAL_ADD(a, b) ((a) + (b))
|
||||
#define OPENCV_HAL_AND(a, b) ((a) & (b))
|
||||
@@ -59,6 +60,10 @@
|
||||
// access from within opencv code more accessible
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup hal_intrin
|
||||
//! @{
|
||||
|
||||
//! @cond IGNORED
|
||||
template<typename _Tp> struct V_TypeTraits
|
||||
{
|
||||
typedef _Tp int_type;
|
||||
@@ -82,6 +87,7 @@ template<> struct V_TypeTraits<uchar>
|
||||
typedef int sum_type;
|
||||
|
||||
typedef ushort w_type;
|
||||
typedef unsigned q_type;
|
||||
|
||||
enum { delta = 128, shift = 8 };
|
||||
|
||||
@@ -99,6 +105,7 @@ template<> struct V_TypeTraits<schar>
|
||||
typedef int sum_type;
|
||||
|
||||
typedef short w_type;
|
||||
typedef int q_type;
|
||||
|
||||
enum { delta = 128, shift = 8 };
|
||||
|
||||
@@ -265,8 +272,22 @@ template<> struct V_TypeTraits<double>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct V_SIMD128Traits
|
||||
{
|
||||
enum { nlanes = 16 / sizeof(T) };
|
||||
};
|
||||
|
||||
//! @endcond
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
|
||||
#ifdef CV_DOXYGEN
|
||||
# undef CV_SSE2
|
||||
# undef CV_NEON
|
||||
#endif
|
||||
|
||||
#if CV_SSE2
|
||||
|
||||
#include "opencv2/hal/intrin_sse.hpp"
|
||||
@@ -281,12 +302,19 @@ template<> struct V_TypeTraits<double>
|
||||
|
||||
#endif
|
||||
|
||||
//! @addtogroup hal_intrin
|
||||
//! @{
|
||||
|
||||
#ifndef CV_SIMD128
|
||||
//! Set to 1 if current compiler supports vector extensions (NEON or SSE is enabled)
|
||||
#define CV_SIMD128 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_SIMD128_64F
|
||||
//! Set to 1 if current intrinsics implementation supports 64-bit float vectors
|
||||
#define CV_SIMD128_64F 0
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,8 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
#define CV_SIMD128 1
|
||||
|
||||
struct v_uint8x16
|
||||
@@ -278,14 +280,15 @@ void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, u16, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, s16, pack_u, un)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, s16, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, u32, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, s32, pack_u, un)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, s32, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, u64, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, s64, pack, n)
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, s16, pack_u, un)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, s32, pack_u, un)
|
||||
|
||||
inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& m3)
|
||||
@@ -374,7 +377,7 @@ inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b)
|
||||
{
|
||||
int32x4_t c = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val));
|
||||
int32x4_t d = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val));
|
||||
int32x4x2_t cd = vtrnq_s32(c, d);
|
||||
int32x4x2_t cd = vuzpq_s32(c, d);
|
||||
return v_int32x4(vaddq_s32(cd.val[0], cd.val[1]));
|
||||
}
|
||||
|
||||
@@ -497,6 +500,16 @@ OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_absdiff, vabdq_u16)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_absdiff, vabdq_u32)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_absdiff, vabdq_f32)
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \
|
||||
inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
return _Tpvec2(cast(intrin(a.val, b.val))); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int8x16, v_uint8x16, vreinterpretq_u8_s8, v_absdiff, vabdq_s8)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int16x8, v_uint16x8, vreinterpretq_u16_s16, v_absdiff, vabdq_s16)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int32x4, v_uint32x4, vreinterpretq_u32_s32, v_absdiff, vabdq_s32)
|
||||
|
||||
inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b)
|
||||
{
|
||||
v_float32x4 x(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val));
|
||||
@@ -641,13 +654,13 @@ inline bool v_check_all(const v_float32x4& a)
|
||||
{ return v_check_all(v_reinterpret_as_u32(a)); }
|
||||
|
||||
inline bool v_check_any(const v_int8x16& a)
|
||||
{ return v_check_all(v_reinterpret_as_u8(a)); }
|
||||
{ return v_check_any(v_reinterpret_as_u8(a)); }
|
||||
inline bool v_check_any(const v_int16x8& a)
|
||||
{ return v_check_all(v_reinterpret_as_u16(a)); }
|
||||
{ return v_check_any(v_reinterpret_as_u16(a)); }
|
||||
inline bool v_check_any(const v_int32x4& a)
|
||||
{ return v_check_all(v_reinterpret_as_u32(a)); }
|
||||
{ return v_check_any(v_reinterpret_as_u32(a)); }
|
||||
inline bool v_check_any(const v_float32x4& a)
|
||||
{ return v_check_all(v_reinterpret_as_u32(a)); }
|
||||
{ return v_check_any(v_reinterpret_as_u32(a)); }
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_SELECT(_Tpvec, suffix, usuffix) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
@@ -678,6 +691,8 @@ OPENCV_HAL_IMPL_NEON_EXPAND(v_uint8x16, v_uint16x8, uchar, u8)
|
||||
OPENCV_HAL_IMPL_NEON_EXPAND(v_int8x16, v_int16x8, schar, s8)
|
||||
OPENCV_HAL_IMPL_NEON_EXPAND(v_uint16x8, v_uint32x4, ushort, u16)
|
||||
OPENCV_HAL_IMPL_NEON_EXPAND(v_int16x8, v_int32x4, short, s16)
|
||||
OPENCV_HAL_IMPL_NEON_EXPAND(v_uint32x4, v_uint64x2, uint, u32)
|
||||
OPENCV_HAL_IMPL_NEON_EXPAND(v_int32x4, v_int64x2, int, s32)
|
||||
|
||||
inline v_uint32x4 v_load_expand_q(const uchar* ptr)
|
||||
{
|
||||
@@ -840,6 +855,8 @@ inline v_float32x4 v_cvt_f32(const v_int32x4& a)
|
||||
return v_float32x4(vcvtq_f32_s32(a.val));
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
typedef uchar lane_type;
|
||||
@@ -296,6 +298,11 @@ OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int32x4, s32)
|
||||
OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint64x2, u64)
|
||||
OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int64x2, s64)
|
||||
|
||||
inline v_float32x4 v_reinterpret_as_f32(const v_float32x4& a) {return a; }
|
||||
inline v_float64x2 v_reinterpret_as_f64(const v_float64x2& a) {return a; }
|
||||
inline v_float32x4 v_reinterpret_as_f32(const v_float64x2& a) {return v_float32x4(_mm_castpd_ps(a.val)); }
|
||||
inline v_float64x2 v_reinterpret_as_f64(const v_float32x4& a) {return v_float64x2(_mm_castps_pd(a.val)); }
|
||||
|
||||
//////////////// PACK ///////////////
|
||||
inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b)
|
||||
{
|
||||
@@ -430,6 +437,17 @@ inline void v_pack_u_store(ushort* ptr, const v_int32x4& a)
|
||||
_mm_storel_epi64((__m128i*)ptr, r);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
v_uint16x8 v_rshr_pack_u(const v_int32x4& a, const v_int32x4& b)
|
||||
{
|
||||
__m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768);
|
||||
__m128i a1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), delta32);
|
||||
__m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768));
|
||||
__m128i b1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(b.val, delta), n), delta32);
|
||||
__m128i b2 = _mm_sub_epi16(_mm_packs_epi32(b1, b1), _mm_set1_epi16(-32768));
|
||||
return v_uint16x8(_mm_unpacklo_epi64(a2, b2));
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
void v_rshr_pack_u_store(ushort* ptr, const v_int32x4& a)
|
||||
{
|
||||
@@ -460,7 +478,7 @@ void v_rshr_pack_store(short* ptr, const v_int32x4& a)
|
||||
{
|
||||
__m128i delta = _mm_set1_epi32(1 << (n-1));
|
||||
__m128i a1 = _mm_srai_epi32(_mm_add_epi32(a.val, delta), n);
|
||||
_mm_storel_epi64((__m128i*)ptr, a1);
|
||||
_mm_storel_epi64((__m128i*)ptr, _mm_packs_epi32(a1, a1));
|
||||
}
|
||||
|
||||
|
||||
@@ -469,7 +487,7 @@ inline v_uint32x4 v_pack(const v_uint64x2& a, const v_uint64x2& b)
|
||||
{
|
||||
__m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0
|
||||
__m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0
|
||||
return v_uint32x4(_mm_unpacklo_epi64(v0, v1));
|
||||
return v_uint32x4(_mm_unpacklo_epi32(v0, v1));
|
||||
}
|
||||
|
||||
inline void v_pack_store(unsigned* ptr, const v_uint64x2& a)
|
||||
@@ -483,7 +501,7 @@ inline v_int32x4 v_pack(const v_int64x2& a, const v_int64x2& b)
|
||||
{
|
||||
__m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0
|
||||
__m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0
|
||||
return v_int32x4(_mm_unpacklo_epi64(v0, v1));
|
||||
return v_int32x4(_mm_unpacklo_epi32(v0, v1));
|
||||
}
|
||||
|
||||
inline void v_pack_store(int* ptr, const v_int64x2& a)
|
||||
@@ -501,7 +519,7 @@ v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b)
|
||||
__m128i b1 = _mm_srli_epi64(_mm_add_epi64(b.val, delta2.val), n);
|
||||
__m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0
|
||||
__m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0
|
||||
return v_uint32x4(_mm_unpacklo_epi64(v0, v1));
|
||||
return v_uint32x4(_mm_unpacklo_epi32(v0, v1));
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -534,7 +552,7 @@ v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b)
|
||||
__m128i b1 = v_srai_epi64(_mm_add_epi64(b.val, delta2.val), n);
|
||||
__m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0
|
||||
__m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0
|
||||
return v_int32x4(_mm_unpacklo_epi64(v0, v1));
|
||||
return v_int32x4(_mm_unpacklo_epi32(v0, v1));
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -630,8 +648,8 @@ inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b,
|
||||
{
|
||||
__m128i v0 = _mm_mullo_epi16(a.val, b.val);
|
||||
__m128i v1 = _mm_mulhi_epi16(a.val, b.val);
|
||||
c.val = _mm_unpacklo_epi32(v0, v1);
|
||||
d.val = _mm_unpackhi_epi32(v0, v1);
|
||||
c.val = _mm_unpacklo_epi16(v0, v1);
|
||||
d.val = _mm_unpackhi_epi16(v0, v1);
|
||||
}
|
||||
|
||||
inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b,
|
||||
@@ -639,8 +657,8 @@ inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b,
|
||||
{
|
||||
__m128i v0 = _mm_mullo_epi16(a.val, b.val);
|
||||
__m128i v1 = _mm_mulhi_epu16(a.val, b.val);
|
||||
c.val = _mm_unpacklo_epi32(v0, v1);
|
||||
d.val = _mm_unpackhi_epi32(v0, v1);
|
||||
c.val = _mm_unpacklo_epi16(v0, v1);
|
||||
d.val = _mm_unpackhi_epi16(v0, v1);
|
||||
}
|
||||
|
||||
inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b,
|
||||
@@ -869,6 +887,18 @@ inline _Tpuvec v_absdiff(const _Tpsvec& a, const _Tpsvec& b) \
|
||||
OPENCV_HAL_IMPL_SSE_ABSDIFF_8_16(v_uint8x16, v_int8x16, 8, (int)0x80808080)
|
||||
OPENCV_HAL_IMPL_SSE_ABSDIFF_8_16(v_uint16x8, v_int16x8, 16, (int)0x80008000)
|
||||
|
||||
inline v_uint32x4 v_absdiff(const v_uint32x4& a, const v_uint32x4& b)
|
||||
{
|
||||
return v_max(a, b) - v_min(a, b);
|
||||
}
|
||||
|
||||
inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b)
|
||||
{
|
||||
__m128i d = _mm_sub_epi32(a.val, b.val);
|
||||
__m128i m = _mm_cmpgt_epi32(b.val, a.val);
|
||||
return v_uint32x4(_mm_sub_epi32(_mm_xor_si128(d, m), m));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(_Tpvec, _Tp, _Tpreg, suffix, absmask_vec) \
|
||||
inline _Tpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
@@ -1047,8 +1077,8 @@ OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, si128)
|
||||
// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, si128)
|
||||
// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, ps)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, pd)
|
||||
|
||||
@@ -1257,7 +1287,7 @@ inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b,
|
||||
__m128i v0 = _mm_unpacklo_epi8(u0, u2); // a0 a8 b0 b8 ...
|
||||
__m128i v1 = _mm_unpackhi_epi8(u0, u2); // a2 a10 b2 b10 ...
|
||||
__m128i v2 = _mm_unpacklo_epi8(u1, u3); // a4 a12 b4 b12 ...
|
||||
__m128i v3 = _mm_unpackhi_epi8(u1, u3); // a6 a14 b4 b14 ...
|
||||
__m128i v3 = _mm_unpackhi_epi8(u1, u3); // a6 a14 b6 b14 ...
|
||||
|
||||
u0 = _mm_unpacklo_epi8(v0, v2); // a0 a4 a8 a12 ...
|
||||
u1 = _mm_unpacklo_epi8(v1, v3); // a2 a6 a10 a14 ...
|
||||
@@ -1266,13 +1296,13 @@ inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b,
|
||||
|
||||
v0 = _mm_unpacklo_epi8(u0, u1); // a0 a2 a4 a6 ...
|
||||
v1 = _mm_unpacklo_epi8(u2, u3); // a1 a3 a5 a7 ...
|
||||
v2 = _mm_unpackhi_epi8(u0, u1); // b0 b2 b4 b6 ...
|
||||
v3 = _mm_unpackhi_epi8(u2, u3); // b1 b3 b5 b7 ...
|
||||
v2 = _mm_unpackhi_epi8(u0, u1); // c0 c2 c4 c6 ...
|
||||
v3 = _mm_unpackhi_epi8(u2, u3); // c1 c3 c5 c7 ...
|
||||
|
||||
a.val = _mm_unpacklo_epi8(v0, v1);
|
||||
b.val = _mm_unpacklo_epi8(v2, v3);
|
||||
c.val = _mm_unpackhi_epi8(v0, v1);
|
||||
d.val = _mm_unpacklo_epi8(v2, v3);
|
||||
b.val = _mm_unpackhi_epi8(v0, v1);
|
||||
c.val = _mm_unpacklo_epi8(v2, v3);
|
||||
d.val = _mm_unpackhi_epi8(v2, v3);
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c)
|
||||
@@ -1560,6 +1590,8 @@ inline v_float64x2 v_cvt_f64(const v_float32x4& a)
|
||||
return v_float64x2(_mm_cvtps_pd(a.val));
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,864 @@
|
||||
#include "test_intrin_utils.hpp"
|
||||
#include <climits>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
template<typename R> struct TheTest
|
||||
{
|
||||
typedef typename R::lane_type LaneType;
|
||||
|
||||
TheTest & test_loadstore()
|
||||
{
|
||||
AlignedData<R> data;
|
||||
AlignedData<R> out;
|
||||
|
||||
// check if addresses are aligned and unaligned respectively
|
||||
EXPECT_EQ((size_t)0, (size_t)&data.a.d % 16);
|
||||
EXPECT_NE((size_t)0, (size_t)&data.u.d % 16);
|
||||
EXPECT_EQ((size_t)0, (size_t)&out.a.d % 16);
|
||||
EXPECT_NE((size_t)0, (size_t)&out.u.d % 16);
|
||||
|
||||
// check some initialization methods
|
||||
R r1 = data.a;
|
||||
R r2 = v_load(data.u.d);
|
||||
R r3 = v_load_aligned(data.a.d);
|
||||
R r4(r2);
|
||||
EXPECT_EQ(data.a[0], r1.get0());
|
||||
EXPECT_EQ(data.u[0], r2.get0());
|
||||
EXPECT_EQ(data.a[0], r3.get0());
|
||||
EXPECT_EQ(data.u[0], r4.get0());
|
||||
|
||||
// check some store methods
|
||||
out.u.clear();
|
||||
out.a.clear();
|
||||
v_store(out.u.d, r1);
|
||||
v_store_aligned(out.a.d, r2);
|
||||
EXPECT_EQ(data.a, out.a);
|
||||
EXPECT_EQ(data.u, out.u);
|
||||
|
||||
// check more store methods
|
||||
Data<R> d, res(0);
|
||||
R r5 = d;
|
||||
v_store_high(res.mid(), r5);
|
||||
v_store_low(res.d, r5);
|
||||
EXPECT_EQ(d, res);
|
||||
|
||||
// check halves load correctness
|
||||
res.clear();
|
||||
R r6 = v_load_halves(d.d, d.mid());
|
||||
v_store(res.d, r6);
|
||||
EXPECT_EQ(d, res);
|
||||
|
||||
// zero, all
|
||||
Data<R> resZ = RegTrait<R>::zero();
|
||||
Data<R> resV = RegTrait<R>::all(8);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ((LaneType)0, resZ[i]);
|
||||
EXPECT_EQ((LaneType)8, resV[i]);
|
||||
}
|
||||
|
||||
// reinterpret_as
|
||||
v_uint8x16 vu8 = v_reinterpret_as_u8(r1); out.a.clear(); v_store((uchar*)out.a.d, vu8); EXPECT_EQ(data.a, out.a);
|
||||
v_int8x16 vs8 = v_reinterpret_as_s8(r1); out.a.clear(); v_store((schar*)out.a.d, vs8); EXPECT_EQ(data.a, out.a);
|
||||
v_uint16x8 vu16 = v_reinterpret_as_u16(r1); out.a.clear(); v_store((ushort*)out.a.d, vu16); EXPECT_EQ(data.a, out.a);
|
||||
v_int16x8 vs16 = v_reinterpret_as_s16(r1); out.a.clear(); v_store((short*)out.a.d, vs16); EXPECT_EQ(data.a, out.a);
|
||||
v_uint32x4 vu32 = v_reinterpret_as_u32(r1); out.a.clear(); v_store((unsigned*)out.a.d, vu32); EXPECT_EQ(data.a, out.a);
|
||||
v_int32x4 vs32 = v_reinterpret_as_s32(r1); out.a.clear(); v_store((int*)out.a.d, vs32); EXPECT_EQ(data.a, out.a);
|
||||
v_uint64x2 vu64 = v_reinterpret_as_u64(r1); out.a.clear(); v_store((uint64*)out.a.d, vu64); EXPECT_EQ(data.a, out.a);
|
||||
v_int64x2 vs64 = v_reinterpret_as_s64(r1); out.a.clear(); v_store((int64*)out.a.d, vs64); EXPECT_EQ(data.a, out.a);
|
||||
v_float32x4 vf32 = v_reinterpret_as_f32(r1); out.a.clear(); v_store((float*)out.a.d, vf32); EXPECT_EQ(data.a, out.a);
|
||||
#if CV_SIMD128_64F
|
||||
v_float64x2 vf64 = v_reinterpret_as_f64(r1); out.a.clear(); v_store((double*)out.a.d, vf64); EXPECT_EQ(data.a, out.a);
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_interleave()
|
||||
{
|
||||
Data<R> data1, data2, data3, data4;
|
||||
data2 += 20;
|
||||
data3 += 40;
|
||||
data4 += 60;
|
||||
|
||||
|
||||
R a = data1, b = data2, c = data3;
|
||||
R d = data1, e = data2, f = data3, g = data4;
|
||||
|
||||
LaneType buf3[R::nlanes * 3];
|
||||
LaneType buf4[R::nlanes * 4];
|
||||
|
||||
v_store_interleave(buf3, a, b, c);
|
||||
v_store_interleave(buf4, d, e, f, g);
|
||||
|
||||
Data<R> z(0);
|
||||
a = b = c = d = e = f = g = z;
|
||||
|
||||
v_load_deinterleave(buf3, a, b, c);
|
||||
v_load_deinterleave(buf4, d, e, f, g);
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(data1, Data<R>(a));
|
||||
EXPECT_EQ(data2, Data<R>(b));
|
||||
EXPECT_EQ(data3, Data<R>(c));
|
||||
|
||||
EXPECT_EQ(data1, Data<R>(d));
|
||||
EXPECT_EQ(data2, Data<R>(e));
|
||||
EXPECT_EQ(data3, Data<R>(f));
|
||||
EXPECT_EQ(data4, Data<R>(g));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// v_expand and v_load_expand
|
||||
TheTest & test_expand()
|
||||
{
|
||||
typedef typename RegTrait<R>::w_reg Rx2;
|
||||
Data<R> dataA;
|
||||
R a = dataA;
|
||||
|
||||
Data<Rx2> resB = v_load_expand(dataA.d);
|
||||
|
||||
Rx2 c, d;
|
||||
v_expand(a, c, d);
|
||||
|
||||
Data<Rx2> resC = c, resD = d;
|
||||
const int n = Rx2::nlanes;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i], resB[i]);
|
||||
EXPECT_EQ(dataA[i], resC[i]);
|
||||
EXPECT_EQ(dataA[i + n], resD[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_expand_q()
|
||||
{
|
||||
typedef typename RegTrait<R>::q_reg Rx4;
|
||||
Data<R> data;
|
||||
Data<Rx4> out = v_load_expand_q(data.d);
|
||||
const int n = Rx4::nlanes;
|
||||
for (int i = 0; i < n; ++i)
|
||||
EXPECT_EQ(data[i], out[i]);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_addsub()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = a + b, resD = a - b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] + dataB[i]), resC[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] - dataB[i]), resD[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_addsub_wrap()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = v_add_wrap(a, b),
|
||||
resD = v_sub_wrap(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ((LaneType)(dataA[i] + dataB[i]), resC[i]);
|
||||
EXPECT_EQ((LaneType)(dataA[i] - dataB[i]), resD[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_mul()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = a * b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] * dataB[i], resC[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_div()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = a / b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] / dataB[i], resC[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_mul_expand()
|
||||
{
|
||||
typedef typename RegTrait<R>::w_reg Rx2;
|
||||
Data<R> dataA, dataB(2);
|
||||
R a = dataA, b = dataB;
|
||||
Rx2 c, d;
|
||||
|
||||
v_mul_expand(a, b, c, d);
|
||||
|
||||
Data<Rx2> resC = c, resD = d;
|
||||
const int n = R::nlanes / 2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ((typename Rx2::lane_type)dataA[i] * dataB[i], resC[i]);
|
||||
EXPECT_EQ((typename Rx2::lane_type)dataA[i + n] * dataB[i + n], resD[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <int s>
|
||||
TheTest & test_shift()
|
||||
{
|
||||
Data<R> dataA;
|
||||
R a = dataA;
|
||||
|
||||
Data<R> resB = a << s, resC = v_shl<s>(a), resD = a >> s, resE = v_shr<s>(a);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] << s, resB[i]);
|
||||
EXPECT_EQ(dataA[i] << s, resC[i]);
|
||||
EXPECT_EQ(dataA[i] >> s, resD[i]);
|
||||
EXPECT_EQ(dataA[i] >> s, resE[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_cmp()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
dataB += 1;
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = (a == b);
|
||||
Data<R> resD = (a != b);
|
||||
Data<R> resE = (a > b);
|
||||
Data<R> resF = (a >= b);
|
||||
Data<R> resG = (a < b);
|
||||
Data<R> resH = (a <= b);
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] == dataB[i], resC[i] != 0);
|
||||
EXPECT_EQ(dataA[i] != dataB[i], resD[i] != 0);
|
||||
EXPECT_EQ(dataA[i] > dataB[i], resE[i] != 0);
|
||||
EXPECT_EQ(dataA[i] >= dataB[i], resF[i] != 0);
|
||||
EXPECT_EQ(dataA[i] < dataB[i], resG[i] != 0);
|
||||
EXPECT_EQ(dataA[i] <= dataB[i], resH[i] != 0);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_dot_prod()
|
||||
{
|
||||
typedef typename RegTrait<R>::w_reg Rx2;
|
||||
Data<R> dataA, dataB(2);
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<Rx2> res = v_dotprod(a, b);
|
||||
|
||||
const int n = R::nlanes / 2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i*2] * dataB[i*2] + dataA[i*2 + 1] * dataB[i*2 + 1], res[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_logic()
|
||||
{
|
||||
Data<R> dataA, dataB(2);
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = a & b, resD = a | b, resE = a ^ b, resF = ~a;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] & dataB[i], resC[i]);
|
||||
EXPECT_EQ(dataA[i] | dataB[i], resD[i]);
|
||||
EXPECT_EQ(dataA[i] ^ dataB[i], resE[i]);
|
||||
EXPECT_EQ((LaneType)~dataA[i], resF[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_sqrt_abs()
|
||||
{
|
||||
Data<R> dataA, dataD;
|
||||
dataD *= -1.0;
|
||||
R a = dataA, d = dataD;
|
||||
|
||||
Data<R> resB = v_sqrt(a), resC = v_invsqrt(a), resE = v_abs(d);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_FLOAT_EQ((float)std::sqrt(dataA[i]), (float)resB[i]);
|
||||
EXPECT_FLOAT_EQ(1/(float)std::sqrt(dataA[i]), (float)resC[i]);
|
||||
EXPECT_FLOAT_EQ((float)abs(dataA[i]), (float)resE[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_min_max()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB.reverse();
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = v_min(a, b), resD = v_max(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(std::min(dataA[i], dataB[i]), resC[i]);
|
||||
EXPECT_EQ(std::max(dataA[i], dataB[i]), resD[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_absdiff()
|
||||
{
|
||||
typedef typename RegTrait<R>::u_reg Ru;
|
||||
typedef typename Ru::lane_type u_type;
|
||||
Data<R> dataA(std::numeric_limits<LaneType>::max()),
|
||||
dataB(std::numeric_limits<LaneType>::min());
|
||||
dataA[0] = (LaneType)-1;
|
||||
dataB[0] = 1;
|
||||
dataA[1] = 2;
|
||||
dataB[1] = (LaneType)-2;
|
||||
R a = dataA, b = dataB;
|
||||
Data<Ru> resC = v_absdiff(a, b);
|
||||
const u_type mask = std::numeric_limits<LaneType>::is_signed ? (u_type)(1 << (sizeof(u_type)*8 - 1)) : 0;
|
||||
for (int i = 0; i < Ru::nlanes; ++i)
|
||||
{
|
||||
u_type uA = dataA[i] ^ mask;
|
||||
u_type uB = dataB[i] ^ mask;
|
||||
EXPECT_EQ(uA > uB ? uA - uB : uB - uA, resC[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_float_absdiff()
|
||||
{
|
||||
Data<R> dataA(std::numeric_limits<LaneType>::max()),
|
||||
dataB(std::numeric_limits<LaneType>::min());
|
||||
dataA[0] = -1;
|
||||
dataB[0] = 1;
|
||||
dataA[1] = 2;
|
||||
dataB[1] = -2;
|
||||
R a = dataA, b = dataB;
|
||||
Data<R> resC = v_absdiff(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i] > dataB[i] ? dataA[i] - dataB[i] : dataB[i] - dataA[i], resC[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_reduce()
|
||||
{
|
||||
Data<R> dataA;
|
||||
R a = dataA;
|
||||
EXPECT_EQ((LaneType)1, v_reduce_min(a));
|
||||
EXPECT_EQ((LaneType)R::nlanes, v_reduce_max(a));
|
||||
EXPECT_EQ((LaneType)(1 + R::nlanes)*2, v_reduce_sum(a));
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_mask()
|
||||
{
|
||||
Data<R> dataA, dataB, dataC, dataD(1), dataE(2);
|
||||
dataA[1] *= (LaneType)-1;
|
||||
dataC *= (LaneType)-1;
|
||||
R a = dataA, b = dataB, c = dataC, d = dataD, e = dataE;
|
||||
|
||||
int m = v_signmask(a);
|
||||
EXPECT_EQ(2, m);
|
||||
|
||||
EXPECT_EQ(false, v_check_all(a));
|
||||
EXPECT_EQ(false, v_check_all(b));
|
||||
EXPECT_EQ(true, v_check_all(c));
|
||||
|
||||
EXPECT_EQ(true, v_check_any(a));
|
||||
EXPECT_EQ(false, v_check_any(b));
|
||||
EXPECT_EQ(true, v_check_any(c));
|
||||
|
||||
typedef V_TypeTraits<LaneType> Traits;
|
||||
typedef typename Traits::int_type int_type;
|
||||
|
||||
R f = v_select(b, d, e);
|
||||
Data<R> resF = f;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
int_type m2 = Traits::reinterpret_int(dataB[i]);
|
||||
EXPECT_EQ((Traits::reinterpret_int(dataD[i]) & m2)
|
||||
| (Traits::reinterpret_int(dataE[i]) & ~m2),
|
||||
Traits::reinterpret_int(resF[i]));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <int s>
|
||||
TheTest & test_pack()
|
||||
{
|
||||
typedef typename RegTrait<R>::w_reg Rx2;
|
||||
typedef typename Rx2::lane_type w_type;
|
||||
Data<Rx2> dataA, dataB;
|
||||
dataA += std::numeric_limits<LaneType>::is_signed ? -10 : 10;
|
||||
dataB *= 10;
|
||||
Rx2 a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = v_pack(a, b);
|
||||
Data<R> resD = v_rshr_pack<s>(a, b);
|
||||
|
||||
Data<R> resE(0);
|
||||
v_pack_store(resE.d, b);
|
||||
|
||||
Data<R> resF(0);
|
||||
v_rshr_pack_store<s>(resF.d, b);
|
||||
|
||||
const int n = Rx2::nlanes;
|
||||
const w_type add = (w_type)1 << (s - 1);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i]), resC[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataB[i]), resC[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataA[i] + add) >> s), resD[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataB[i] + add) >> s), resD[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataB[i]), resE[i]);
|
||||
EXPECT_EQ((LaneType)0, resE[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataB[i] + add) >> s), resF[i]);
|
||||
EXPECT_EQ((LaneType)0, resF[i + n]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <int s>
|
||||
TheTest & test_pack_u()
|
||||
{
|
||||
typedef typename RegTrait<R>::w_reg Rx2;
|
||||
typedef typename RegTrait<Rx2>::int_reg Ri2;
|
||||
typedef typename Ri2::lane_type w_type;
|
||||
|
||||
Data<Ri2> dataA, dataB;
|
||||
dataA += -10;
|
||||
dataB *= 10;
|
||||
Ri2 a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = v_pack_u(a, b);
|
||||
Data<R> resD = v_rshr_pack_u<s>(a, b);
|
||||
|
||||
Data<R> resE(0);
|
||||
v_pack_u_store(resE.d, b);
|
||||
|
||||
Data<R> resF(0);
|
||||
v_rshr_pack_u_store<s>(resF.d, b);
|
||||
|
||||
const int n = Ri2::nlanes;
|
||||
const w_type add = (w_type)1 << (s - 1);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i]), resC[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataB[i]), resC[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataA[i] + add) >> s), resD[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataB[i] + add) >> s), resD[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataB[i]), resE[i]);
|
||||
EXPECT_EQ((LaneType)0, resE[i + n]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>((dataB[i] + add) >> s), resF[i]);
|
||||
EXPECT_EQ((LaneType)0, resF[i + n]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_unpack()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB *= 10;
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
R c, d, e, f, lo, hi;
|
||||
v_zip(a, b, c, d);
|
||||
v_recombine(a, b, e, f);
|
||||
lo = v_combine_low(a, b);
|
||||
hi = v_combine_high(a, b);
|
||||
|
||||
Data<R> resC = c, resD = d, resE = e, resF = f, resLo = lo, resHi = hi;
|
||||
|
||||
const int n = R::nlanes/2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i], resC[i*2]);
|
||||
EXPECT_EQ(dataB[i], resC[i*2+1]);
|
||||
EXPECT_EQ(dataA[i+n], resD[i*2]);
|
||||
EXPECT_EQ(dataB[i+n], resD[i*2+1]);
|
||||
|
||||
EXPECT_EQ(dataA[i], resE[i]);
|
||||
EXPECT_EQ(dataB[i], resE[i+n]);
|
||||
EXPECT_EQ(dataA[i+n], resF[i]);
|
||||
EXPECT_EQ(dataB[i+n], resF[i+n]);
|
||||
|
||||
EXPECT_EQ(dataA[i], resLo[i]);
|
||||
EXPECT_EQ(dataB[i], resLo[i+n]);
|
||||
EXPECT_EQ(dataA[i+n], resHi[i]);
|
||||
EXPECT_EQ(dataB[i+n], resHi[i+n]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<int s>
|
||||
TheTest & test_extract()
|
||||
{
|
||||
Data<R> dataA, dataB;
|
||||
dataB *= 10;
|
||||
R a = dataA, b = dataB;
|
||||
|
||||
Data<R> resC = v_extract<s>(a, b);
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
if (i + s >= R::nlanes)
|
||||
EXPECT_EQ(dataB[i - R::nlanes + s], resC[i]);
|
||||
else
|
||||
EXPECT_EQ(dataA[i + s], resC[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_float_math()
|
||||
{
|
||||
typedef typename RegTrait<R>::int_reg Ri;
|
||||
Data<R> data1, data2, data3;
|
||||
data1 *= 1.1;
|
||||
data2 += 10;
|
||||
R a1 = data1, a2 = data2, a3 = data3;
|
||||
|
||||
Data<Ri> resB = v_round(a1),
|
||||
resC = v_trunc(a1),
|
||||
resD = v_floor(a1),
|
||||
resE = v_ceil(a1);
|
||||
|
||||
Data<R> resF = v_magnitude(a1, a2),
|
||||
resG = v_sqr_magnitude(a1, a2),
|
||||
resH = v_muladd(a1, a2, a3);
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(cvRound(data1[i]), resB[i]);
|
||||
EXPECT_EQ((typename Ri::lane_type)data1[i], resC[i]);
|
||||
EXPECT_EQ(cvFloor(data1[i]), resD[i]);
|
||||
EXPECT_EQ(cvCeil(data1[i]), resE[i]);
|
||||
|
||||
EXPECT_DOUBLE_EQ(std::sqrt(data1[i]*data1[i] + data2[i]*data2[i]), resF[i]);
|
||||
EXPECT_DOUBLE_EQ(data1[i]*data1[i] + data2[i]*data2[i], resG[i]);
|
||||
EXPECT_DOUBLE_EQ(data1[i]*data2[i] + data3[i], resH[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_float_cvt32()
|
||||
{
|
||||
typedef v_float32x4 Rt;
|
||||
Data<R> dataA;
|
||||
dataA *= 1.1;
|
||||
R a = dataA;
|
||||
Rt b = v_cvt_f32(a);
|
||||
Data<Rt> resB = b;
|
||||
int n = std::min<int>(Rt::nlanes, R::nlanes);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ((typename Rt::lane_type)dataA[i], resB[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_float_cvt64()
|
||||
{
|
||||
#if CV_SIMD128_64F
|
||||
typedef v_float64x2 Rt;
|
||||
Data<R> dataA;
|
||||
dataA *= 1.1;
|
||||
R a = dataA;
|
||||
Rt b = v_cvt_f64(a);
|
||||
Data<Rt> resB = b;
|
||||
int n = std::min<int>(Rt::nlanes, R::nlanes);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
EXPECT_EQ((typename Rt::lane_type)dataA[i], resB[i]);
|
||||
}
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_matmul()
|
||||
{
|
||||
Data<R> dataV, dataA, dataB, dataC, dataD;
|
||||
dataB.reverse();
|
||||
dataC += 2;
|
||||
dataD *= 0.3;
|
||||
R v = dataV, a = dataA, b = dataB, c = dataC, d = dataD;
|
||||
|
||||
Data<R> res = v_matmul(v, a, b, c, d);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
LaneType val = dataV[0] * dataA[i]
|
||||
+ dataV[1] * dataB[i]
|
||||
+ dataV[2] * dataC[i]
|
||||
+ dataV[3] * dataD[i];
|
||||
EXPECT_DOUBLE_EQ(val, res[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
TheTest & test_transpose()
|
||||
{
|
||||
Data<R> dataA, dataB, dataC, dataD;
|
||||
dataB *= 5;
|
||||
dataC *= 10;
|
||||
dataD *= 15;
|
||||
R a = dataA, b = dataB, c = dataC, d = dataD;
|
||||
R e, f, g, h;
|
||||
v_transpose4x4(a, b, c, d,
|
||||
e, f, g, h);
|
||||
|
||||
Data<R> res[4] = {e, f, g, h};
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
EXPECT_EQ(dataA[i], res[i][0]);
|
||||
EXPECT_EQ(dataB[i], res[i][1]);
|
||||
EXPECT_EQ(dataC[i], res[i][2]);
|
||||
EXPECT_EQ(dataD[i], res[i][3]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//============= 8-bit integer =====================================================================
|
||||
|
||||
TEST(hal_intrin, uint8x16) {
|
||||
TheTest<v_uint8x16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<3>().test_pack_u<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
;
|
||||
}
|
||||
|
||||
TEST(hal_intrin, int8x16) {
|
||||
TheTest<v_int8x16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 16-bit integer =====================================================================
|
||||
|
||||
TEST(hal_intrin, uint16x8) {
|
||||
TheTest<v_uint16x8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<7>().test_pack_u<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
;
|
||||
}
|
||||
|
||||
TEST(hal_intrin, int16x8) {
|
||||
TheTest<v_int16x8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_dot_prod()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 32-bit integer =====================================================================
|
||||
|
||||
TEST(hal_intrin, uint32x4) {
|
||||
TheTest<v_uint32x4>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
TEST(hal_intrin, int32x4) {
|
||||
TheTest<v_int32x4>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_cmp()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_float_cvt32()
|
||||
.test_float_cvt64()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 64-bit integer =====================================================================
|
||||
|
||||
TEST(hal_intrin, uint64x2) {
|
||||
TheTest<v_uint64x2>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
;
|
||||
}
|
||||
|
||||
TEST(hal_intrin, int64x2) {
|
||||
TheTest<v_int64x2>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= Floating point =====================================================================
|
||||
|
||||
TEST(hal_intrin, float32x4) {
|
||||
TheTest<v_float32x4>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt64()
|
||||
.test_matmul()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
TEST(hal_intrin, float64x2) {
|
||||
TheTest<v_float64x2>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt32()
|
||||
;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,234 @@
|
||||
#ifndef _TEST_UTILS_HPP_
|
||||
#define _TEST_UTILS_HPP_
|
||||
|
||||
#include "opencv2/hal/intrin.hpp"
|
||||
#include "opencv2/ts.hpp"
|
||||
#include <ostream>
|
||||
#include <algorithm>
|
||||
|
||||
template <typename R> struct Data;
|
||||
template <int N> struct initializer;
|
||||
|
||||
template <> struct initializer<16>
|
||||
{
|
||||
template <typename R> static R init(const Data<R> & d)
|
||||
{
|
||||
return R(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct initializer<8>
|
||||
{
|
||||
template <typename R> static R init(const Data<R> & d)
|
||||
{
|
||||
return R(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct initializer<4>
|
||||
{
|
||||
template <typename R> static R init(const Data<R> & d)
|
||||
{
|
||||
return R(d[0], d[1], d[2], d[3]);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct initializer<2>
|
||||
{
|
||||
template <typename R> static R init(const Data<R> & d)
|
||||
{
|
||||
return R(d[0], d[1]);
|
||||
}
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
template <typename R> struct Data
|
||||
{
|
||||
typedef typename R::lane_type LaneType;
|
||||
Data()
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
d[i] = (LaneType)(i + 1);
|
||||
}
|
||||
Data(LaneType val)
|
||||
{
|
||||
fill(val);
|
||||
}
|
||||
Data(const R & r)
|
||||
{
|
||||
*this = r;
|
||||
}
|
||||
operator R ()
|
||||
{
|
||||
return initializer<R::nlanes>().init(*this);
|
||||
}
|
||||
Data<R> & operator=(const R & r)
|
||||
{
|
||||
v_store(d, r);
|
||||
return *this;
|
||||
}
|
||||
template <typename T> Data<R> & operator*=(T m)
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
d[i] *= (LaneType)m;
|
||||
return *this;
|
||||
}
|
||||
template <typename T> Data<R> & operator+=(T m)
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
d[i] += (LaneType)m;
|
||||
return *this;
|
||||
}
|
||||
void fill(LaneType val)
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
d[i] = val;
|
||||
}
|
||||
void reverse()
|
||||
{
|
||||
for (int i = 0; i < R::nlanes / 2; ++i)
|
||||
std::swap(d[i], d[R::nlanes - i - 1]);
|
||||
}
|
||||
const LaneType & operator[](int i) const
|
||||
{
|
||||
CV_Assert(i >= 0 && i < R::nlanes);
|
||||
return d[i];
|
||||
}
|
||||
LaneType & operator[](int i)
|
||||
{
|
||||
CV_Assert(i >= 0 && i < R::nlanes);
|
||||
return d[i];
|
||||
}
|
||||
const LaneType * mid() const
|
||||
{
|
||||
return d + R::nlanes / 2;
|
||||
}
|
||||
LaneType * mid()
|
||||
{
|
||||
return d + R::nlanes / 2;
|
||||
}
|
||||
bool operator==(const Data<R> & other) const
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
if (d[i] != other.d[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
fill(0);
|
||||
}
|
||||
bool isZero() const
|
||||
{
|
||||
return isValue(0);
|
||||
}
|
||||
bool isValue(uchar val) const
|
||||
{
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
if (d[i] != val)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
LaneType d[R::nlanes];
|
||||
};
|
||||
|
||||
template<typename R> struct AlignedData
|
||||
{
|
||||
Data<R> CV_DECL_ALIGNED(16) a; // aligned
|
||||
char dummy;
|
||||
Data<R> u; // unaligned
|
||||
};
|
||||
|
||||
template <typename R> std::ostream & operator<<(std::ostream & out, const Data<R> & d)
|
||||
{
|
||||
out << "{ ";
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
// out << std::hex << +V_TypeTraits<typename R::lane_type>::reinterpret_int(d.d[i]);
|
||||
out << +d.d[i];
|
||||
if (i + 1 < R::nlanes)
|
||||
out << ", ";
|
||||
}
|
||||
out << " }";
|
||||
return out;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
template <typename R> struct RegTrait;
|
||||
|
||||
template <> struct RegTrait<cv::v_uint8x16> {
|
||||
typedef cv::v_uint16x8 w_reg;
|
||||
typedef cv::v_uint32x4 q_reg;
|
||||
typedef cv::v_uint8x16 u_reg;
|
||||
static cv::v_uint8x16 zero() { return cv::v_setzero_u8(); }
|
||||
static cv::v_uint8x16 all(uchar val) { return cv::v_setall_u8(val); }
|
||||
};
|
||||
template <> struct RegTrait<cv::v_int8x16> {
|
||||
typedef cv::v_int16x8 w_reg;
|
||||
typedef cv::v_int32x4 q_reg;
|
||||
typedef cv::v_uint8x16 u_reg;
|
||||
static cv::v_int8x16 zero() { return cv::v_setzero_s8(); }
|
||||
static cv::v_int8x16 all(schar val) { return cv::v_setall_s8(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_uint16x8> {
|
||||
typedef cv::v_uint32x4 w_reg;
|
||||
typedef cv::v_int16x8 int_reg;
|
||||
typedef cv::v_uint16x8 u_reg;
|
||||
static cv::v_uint16x8 zero() { return cv::v_setzero_u16(); }
|
||||
static cv::v_uint16x8 all(ushort val) { return cv::v_setall_u16(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_int16x8> {
|
||||
typedef cv::v_int32x4 w_reg;
|
||||
typedef cv::v_uint16x8 u_reg;
|
||||
static cv::v_int16x8 zero() { return cv::v_setzero_s16(); }
|
||||
static cv::v_int16x8 all(short val) { return cv::v_setall_s16(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_uint32x4> {
|
||||
typedef cv::v_uint64x2 w_reg;
|
||||
typedef cv::v_int32x4 int_reg;
|
||||
typedef cv::v_uint32x4 u_reg;
|
||||
static cv::v_uint32x4 zero() { return cv::v_setzero_u32(); }
|
||||
static cv::v_uint32x4 all(unsigned val) { return cv::v_setall_u32(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_int32x4> {
|
||||
typedef cv::v_int64x2 w_reg;
|
||||
typedef cv::v_uint32x4 u_reg;
|
||||
static cv::v_int32x4 zero() { return cv::v_setzero_s32(); }
|
||||
static cv::v_int32x4 all(int val) { return cv::v_setall_s32(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_uint64x2> {
|
||||
static cv::v_uint64x2 zero() { return cv::v_setzero_u64(); }
|
||||
static cv::v_uint64x2 all(uint64 val) { return cv::v_setall_u64(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_int64x2> {
|
||||
static cv::v_int64x2 zero() { return cv::v_setzero_s64(); }
|
||||
static cv::v_int64x2 all(int64 val) { return cv::v_setall_s64(val); }
|
||||
};
|
||||
|
||||
template <> struct RegTrait<cv::v_float32x4> {
|
||||
typedef cv::v_int32x4 int_reg;
|
||||
typedef cv::v_float32x4 u_reg;
|
||||
static cv::v_float32x4 zero() { return cv::v_setzero_f32(); }
|
||||
static cv::v_float32x4 all(float val) { return cv::v_setall_f32(val); }
|
||||
};
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
template <> struct RegTrait<cv::v_float64x2> {
|
||||
typedef cv::v_int32x4 int_reg;
|
||||
typedef cv::v_float64x2 u_reg;
|
||||
static cv::v_float64x2 zero() { return cv::v_setzero_f64(); }
|
||||
static cv::v_float64x2 all(double val) { return cv::v_setall_f64(val); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "opencv2/ts.hpp"
|
||||
|
||||
CV_TEST_MAIN("cv")
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __OPENCV_HAL_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_HAL_TEST_PRECOMP_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/hal.hpp"
|
||||
#include "opencv2/hal/defs.h"
|
||||
#include "opencv2/hal/intrin.hpp"
|
||||
|
||||
#endif
|
||||
@@ -82,42 +82,44 @@ It provides easy interface to:
|
||||
See below the example used to generate the figure:
|
||||
@code
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int value = 50;
|
||||
int value2 = 0;
|
||||
|
||||
cvNamedWindow("main1",CV_WINDOW_NORMAL);
|
||||
cvNamedWindow("main2",CV_WINDOW_AUTOSIZE | CV_GUI_NORMAL);
|
||||
|
||||
cvCreateTrackbar( "track1", "main1", &value, 255, NULL);//OK tested
|
||||
char* nameb1 = "button1";
|
||||
char* nameb2 = "button2";
|
||||
cvCreateButton(nameb1,callbackButton,nameb1,CV_CHECKBOX,1);
|
||||
namedWindow("main1",WINDOW_NORMAL);
|
||||
namedWindow("main2",WINDOW_AUTOSIZE | CV_GUI_NORMAL);
|
||||
createTrackbar( "track1", "main1", &value, 255, NULL);
|
||||
|
||||
cvCreateButton(nameb2,callbackButton,nameb2,CV_CHECKBOX,0);
|
||||
cvCreateTrackbar( "track2", NULL, &value2, 255, NULL);
|
||||
cvCreateButton("button5",callbackButton1,NULL,CV_RADIOBOX,0);
|
||||
cvCreateButton("button6",callbackButton2,NULL,CV_RADIOBOX,1);
|
||||
String nameb1 = "button1";
|
||||
String nameb2 = "button2";
|
||||
|
||||
cvSetMouseCallback( "main2",on_mouse,NULL );
|
||||
createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1);
|
||||
createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0);
|
||||
createTrackbar( "track2", NULL, &value2, 255, NULL);
|
||||
createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0);
|
||||
createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1);
|
||||
|
||||
IplImage* img1 = cvLoadImage("files/flower.jpg");
|
||||
IplImage* img2 = cvCreateImage(cvGetSize(img1),8,3);
|
||||
CvCapture* video = cvCaptureFromFile("files/hockey.avi");
|
||||
IplImage* img3 = cvCreateImage(cvGetSize(cvQueryFrame(video)),8,3);
|
||||
setMouseCallback( "main2",on_mouse,NULL );
|
||||
|
||||
while(cvWaitKey(33) != 27)
|
||||
Mat img1 = imread("files/flower.jpg");
|
||||
VideoCapture video;
|
||||
video.open("files/hockey.avi");
|
||||
|
||||
Mat img2,img3;
|
||||
|
||||
while( waitKey(33) != 27 )
|
||||
{
|
||||
cvAddS(img1,cvScalarAll(value),img2);
|
||||
cvAddS(cvQueryFrame(video),cvScalarAll(value2),img3);
|
||||
cvShowImage("main1",img2);
|
||||
cvShowImage("main2",img3);
|
||||
img1.convertTo(img2,-1,1,value);
|
||||
video >> img3;
|
||||
|
||||
imshow("main1",img2);
|
||||
imshow("main2",img3);
|
||||
}
|
||||
|
||||
cvDestroyAllWindows();
|
||||
cvReleaseImage(&img1);
|
||||
cvReleaseImage(&img2);
|
||||
cvReleaseImage(&img3);
|
||||
cvReleaseCapture(&video);
|
||||
destroyAllWindows();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
@@ -140,7 +142,7 @@ It provides easy interface to:
|
||||
|
||||
cv::Mat image = cv::imread("Assets/sample.jpg");
|
||||
cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4);
|
||||
cvtColor(image, converted, CV_BGR2BGRA);
|
||||
cv::cvtColor(image, converted, COLOR_BGR2BGRA);
|
||||
cv::imshow(windowName, converted); // this will create window if it hasn't been created before
|
||||
|
||||
int state = 42;
|
||||
@@ -174,79 +176,100 @@ namespace cv
|
||||
|
||||
//! Flags for cv::namedWindow
|
||||
enum WindowFlags {
|
||||
WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
|
||||
WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed
|
||||
WINDOW_OPENGL = 0x00001000, //!< window with opengl support
|
||||
WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size.
|
||||
WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed.
|
||||
WINDOW_OPENGL = 0x00001000, //!< window with opengl support.
|
||||
|
||||
WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen
|
||||
WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint)
|
||||
WINDOW_KEEPRATIO = 0x00000000 //!< the ratio of the image is respected
|
||||
WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen.
|
||||
WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint).
|
||||
WINDOW_KEEPRATIO = 0x00000000 //!< the ratio of the image is respected.
|
||||
};
|
||||
|
||||
//! Flags for cv::setWindowProperty / cv::getWindowProperty
|
||||
enum WindowPropertyFlags {
|
||||
WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN)
|
||||
WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE)
|
||||
WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO);
|
||||
WND_PROP_OPENGL = 3 //!< opengl support
|
||||
WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN).
|
||||
WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE).
|
||||
WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO).
|
||||
WND_PROP_OPENGL = 3 //!< opengl support.
|
||||
};
|
||||
|
||||
enum { EVENT_MOUSEMOVE = 0,
|
||||
EVENT_LBUTTONDOWN = 1,
|
||||
EVENT_RBUTTONDOWN = 2,
|
||||
EVENT_MBUTTONDOWN = 3,
|
||||
EVENT_LBUTTONUP = 4,
|
||||
EVENT_RBUTTONUP = 5,
|
||||
EVENT_MBUTTONUP = 6,
|
||||
EVENT_LBUTTONDBLCLK = 7,
|
||||
EVENT_RBUTTONDBLCLK = 8,
|
||||
EVENT_MBUTTONDBLCLK = 9,
|
||||
EVENT_MOUSEWHEEL = 10,
|
||||
EVENT_MOUSEHWHEEL = 11
|
||||
//! Mouse Events see cv::MouseCallback
|
||||
enum MouseEventTypes {
|
||||
EVENT_MOUSEMOVE = 0, //!< indicates that the mouse pointer has moved over the window.
|
||||
EVENT_LBUTTONDOWN = 1, //!< indicates that the left mouse button is pressed.
|
||||
EVENT_RBUTTONDOWN = 2, //!< indicates that the right mouse button is pressed.
|
||||
EVENT_MBUTTONDOWN = 3, //!< indicates that the middle mouse button is pressed.
|
||||
EVENT_LBUTTONUP = 4, //!< indicates that left mouse button is released.
|
||||
EVENT_RBUTTONUP = 5, //!< indicates that right mouse button is released.
|
||||
EVENT_MBUTTONUP = 6, //!< indicates that middle mouse button is released.
|
||||
EVENT_LBUTTONDBLCLK = 7, //!< indicates that left mouse button is double clicked.
|
||||
EVENT_RBUTTONDBLCLK = 8, //!< indicates that right mouse button is double clicked.
|
||||
EVENT_MBUTTONDBLCLK = 9, //!< indicates that middle mouse button is double clicked.
|
||||
EVENT_MOUSEWHEEL = 10,//!< positive and negative values mean forward and backward scrolling, respectively.
|
||||
EVENT_MOUSEHWHEEL = 11 //!< positive and negative values mean right and left scrolling, respectively.
|
||||
};
|
||||
|
||||
enum { EVENT_FLAG_LBUTTON = 1,
|
||||
EVENT_FLAG_RBUTTON = 2,
|
||||
EVENT_FLAG_MBUTTON = 4,
|
||||
EVENT_FLAG_CTRLKEY = 8,
|
||||
EVENT_FLAG_SHIFTKEY = 16,
|
||||
EVENT_FLAG_ALTKEY = 32
|
||||
//! Mouse Event Flags see cv::MouseCallback
|
||||
enum MouseEventFlags {
|
||||
EVENT_FLAG_LBUTTON = 1, //!< indicates that the left mouse button is down.
|
||||
EVENT_FLAG_RBUTTON = 2, //!< indicates that the right mouse button is down.
|
||||
EVENT_FLAG_MBUTTON = 4, //!< indicates that the middle mouse button is down.
|
||||
EVENT_FLAG_CTRLKEY = 8, //!< indicates that CTRL Key is pressed.
|
||||
EVENT_FLAG_SHIFTKEY = 16,//!< indicates that SHIFT Key is pressed.
|
||||
EVENT_FLAG_ALTKEY = 32 //!< indicates that ALT Key is pressed.
|
||||
};
|
||||
|
||||
//! Qt font weight
|
||||
enum QtFontWeights {
|
||||
QT_FONT_LIGHT = 25, //!< QFont::Light ( Weight of 25 )
|
||||
QT_FONT_NORMAL = 50, //!< QFont::Normal ( Weight of 50 )
|
||||
QT_FONT_DEMIBOLD = 63, //!< QFont::DemiBold ( Weight of 63 )
|
||||
QT_FONT_BOLD = 75, //!< QFont::Bold ( Weight of 75 )
|
||||
QT_FONT_BLACK = 87 //!< QFont::Black ( Weight of 87 )
|
||||
QT_FONT_LIGHT = 25, //!< Weight of 25
|
||||
QT_FONT_NORMAL = 50, //!< Weight of 50
|
||||
QT_FONT_DEMIBOLD = 63, //!< Weight of 63
|
||||
QT_FONT_BOLD = 75, //!< Weight of 75
|
||||
QT_FONT_BLACK = 87 //!< Weight of 87
|
||||
};
|
||||
|
||||
//! Qt font style
|
||||
enum QtFontStyles {
|
||||
QT_STYLE_NORMAL = 0, //!< QFont::StyleNormal
|
||||
QT_STYLE_ITALIC = 1, //!< QFont::StyleItalic
|
||||
QT_STYLE_OBLIQUE = 2 //!< QFont::StyleOblique
|
||||
QT_STYLE_NORMAL = 0, //!< Normal font.
|
||||
QT_STYLE_ITALIC = 1, //!< Italic font.
|
||||
QT_STYLE_OBLIQUE = 2 //!< Oblique font.
|
||||
};
|
||||
|
||||
//! Qt "button" type
|
||||
enum QtButtonTypes {
|
||||
QT_PUSH_BUTTON = 0, //!< Push button
|
||||
QT_CHECKBOX = 1, //!< Checkbox button
|
||||
QT_RADIOBOX = 2 //!< Radiobox button
|
||||
QT_PUSH_BUTTON = 0, //!< Push button.
|
||||
QT_CHECKBOX = 1, //!< Checkbox button.
|
||||
QT_RADIOBOX = 2 //!< Radiobox button.
|
||||
};
|
||||
|
||||
|
||||
/** @brief Callback function for mouse events. see cv::setMouseCallback
|
||||
@param event one of the cv::MouseEventTypes constants.
|
||||
@param x The x-coordinate of the mouse event.
|
||||
@param y The y-coordinate of the mouse event.
|
||||
@param flags one of the cv::MouseEventFlags constants.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
|
||||
|
||||
/** @brief Callback function for Trackbar see cv::createTrackbar
|
||||
@param pos current position of the specified trackbar.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*TrackbarCallback)(int pos, void* userdata);
|
||||
|
||||
/** @brief Callback function defined to be called every frame. See cv::setOpenGlDrawCallback
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*OpenGlDrawCallback)(void* userdata);
|
||||
|
||||
/** @brief Callback function for a button created by cv::createButton
|
||||
@param state current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*ButtonCallback)(int state, void* userdata);
|
||||
|
||||
/** @brief Creates a window.
|
||||
|
||||
@param winname Name of the window in the window caption that may be used as a window identifier.
|
||||
@param flags Flags of the window. The supported flags are: (cv::WindowFlags)
|
||||
|
||||
The function namedWindow creates a window that can be used as a placeholder for images and
|
||||
trackbars. Created windows are referred to by their names.
|
||||
|
||||
@@ -267,14 +290,17 @@ Qt backend supports additional flags:
|
||||
- **CV_GUI_NORMAL or CV_GUI_EXPANDED:** CV_GUI_NORMAL is the old way to draw the window
|
||||
without statusbar and toolbar, whereas CV_GUI_EXPANDED is a new enhanced GUI.
|
||||
By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | CV_GUI_EXPANDED
|
||||
|
||||
@param winname Name of the window in the window caption that may be used as a window identifier.
|
||||
@param flags Flags of the window. The supported flags are: (cv::WindowFlags)
|
||||
*/
|
||||
CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);
|
||||
|
||||
/** @brief Destroys a window.
|
||||
|
||||
@param winname Name of the window to be destroyed.
|
||||
/** @brief Destroys the specified window.
|
||||
|
||||
The function destroyWindow destroys the window with the given name.
|
||||
|
||||
@param winname Name of the window to be destroyed.
|
||||
*/
|
||||
CV_EXPORTS_W void destroyWindow(const String& winname);
|
||||
|
||||
@@ -288,8 +314,6 @@ CV_EXPORTS_W int startWindowThread();
|
||||
|
||||
/** @brief Waits for a pressed key.
|
||||
|
||||
@param delay Delay in milliseconds. 0 is the special value that means "forever".
|
||||
|
||||
The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay
|
||||
milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the
|
||||
function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is
|
||||
@@ -306,16 +330,15 @@ takes care of event processing.
|
||||
|
||||
The function only works if there is at least one HighGUI window created and the window is active.
|
||||
If there are several HighGUI windows, any of them can be active.
|
||||
|
||||
@param delay Delay in milliseconds. 0 is the special value that means "forever".
|
||||
*/
|
||||
CV_EXPORTS_W int waitKey(int delay = 0);
|
||||
|
||||
/** @brief Displays an image in the specified window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param mat Image to be shown.
|
||||
|
||||
The function imshow displays an image in the specified window. If the window was created with the
|
||||
WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution.
|
||||
cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution.
|
||||
Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth:
|
||||
|
||||
- If the image is 8-bit unsigned, it is displayed as is.
|
||||
@@ -324,77 +347,81 @@ Otherwise, the image is scaled to fit the window. The function may scale the ima
|
||||
- If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the
|
||||
value range [0,1] is mapped to [0,255].
|
||||
|
||||
If window was created with OpenGL support, imshow also support ogl::Buffer , ogl::Texture2D and
|
||||
If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and
|
||||
cuda::GpuMat as input.
|
||||
|
||||
If the window was not created before this function, it is assumed creating a window with WINDOW_AUTOSIZE.
|
||||
If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE.
|
||||
|
||||
If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.
|
||||
|
||||
@note This function should be followed by cv::waitKey function which displays the image for specified
|
||||
milliseconds. Otherwise, it won't display the image. For example, cv::waitKey(0) will display the window
|
||||
infinitely until any keypress (it is suitable for image display). cv::waitKey(25) will display a frame
|
||||
milliseconds. Otherwise, it won't display the image. For example, **waitKey(0)** will display the window
|
||||
infinitely until any keypress (it is suitable for image display). **waitKey(25)** will display a frame
|
||||
for 25 ms, after which display will be automatically closed. (If you put it in a loop to read
|
||||
videos, it will display the video frame-by-frame)
|
||||
|
||||
@note
|
||||
|
||||
[Windows Backend Only] Pressing Ctrl+C will copy the image to the clipboard.
|
||||
[__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard.
|
||||
|
||||
[Windows Backend Only] Pressing Ctrl+S will show a dialog to save the image.
|
||||
[__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param mat Image to be shown.
|
||||
*/
|
||||
CV_EXPORTS_W void imshow(const String& winname, InputArray mat);
|
||||
|
||||
/** @brief Resizes window to the specified size
|
||||
|
||||
@param winname Window name
|
||||
@param width The new window width
|
||||
@param height The new window height
|
||||
|
||||
@note
|
||||
|
||||
- The specified window size is for the image area. Toolbars are not counted.
|
||||
- Only windows created without WINDOW_AUTOSIZE flag can be resized.
|
||||
- Only windows created without cv::WINDOW_AUTOSIZE flag can be resized.
|
||||
|
||||
@param winname Window name.
|
||||
@param width The new window width.
|
||||
@param height The new window height.
|
||||
*/
|
||||
CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height);
|
||||
|
||||
/** @brief Moves window to the specified position
|
||||
|
||||
@param winname Window name
|
||||
@param x The new x-coordinate of the window
|
||||
@param y The new y-coordinate of the window
|
||||
@param winname Name of the window.
|
||||
@param x The new x-coordinate of the window.
|
||||
@param y The new y-coordinate of the window.
|
||||
*/
|
||||
CV_EXPORTS_W void moveWindow(const String& winname, int x, int y);
|
||||
|
||||
/** @brief Changes parameters of a window dynamically.
|
||||
|
||||
The function setWindowProperty enables changing properties of a window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param prop_id Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags)
|
||||
@param prop_value New value of the window property. The supported flags are: (cv::WindowFlags)
|
||||
|
||||
The function setWindowProperty enables changing properties of a window.
|
||||
*/
|
||||
CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
|
||||
|
||||
/** @brief Updates window title
|
||||
@param winname Name of the window.
|
||||
@param title New title.
|
||||
*/
|
||||
CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title);
|
||||
|
||||
/** @brief Provides parameters of a window.
|
||||
|
||||
The function getWindowProperty returns properties of a window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param prop_id Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags)
|
||||
|
||||
See setWindowProperty to know the meaning of the returned values.
|
||||
|
||||
The function getWindowProperty returns properties of a window.
|
||||
@sa setWindowProperty
|
||||
*/
|
||||
CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
|
||||
|
||||
/** @brief Sets mouse handler for the specified window
|
||||
|
||||
@param winname Window name
|
||||
@param winname Name of the window.
|
||||
@param onMouse Mouse callback. See OpenCV samples, such as
|
||||
<https://github.com/Itseez/opencv/tree/master/samples/cpp/ffilldemo.cpp>, on how to specify and
|
||||
use the callback.
|
||||
@@ -402,18 +429,16 @@ use the callback.
|
||||
*/
|
||||
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
|
||||
|
||||
/** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events EVENT_MOUSEWHEEL and
|
||||
EVENT_MOUSEHWHEEL.
|
||||
|
||||
@param flags The mouse callback flags parameter.
|
||||
/** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and
|
||||
cv::EVENT_MOUSEHWHEEL.
|
||||
|
||||
For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to
|
||||
a one notch rotation of the wheel or the threshold for action to be taken and one such action should
|
||||
occur for each delta. Some high-precision mice with higher-resolution freely-rotating wheels may
|
||||
generate smaller values.
|
||||
|
||||
For EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling,
|
||||
respectively. For EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and
|
||||
For cv::EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling,
|
||||
respectively. For cv::EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and
|
||||
left scrolling, respectively.
|
||||
|
||||
With the C API, the macro CV_GET_WHEEL_DELTA(flags) can be used alternatively.
|
||||
@@ -421,11 +446,25 @@ With the C API, the macro CV_GET_WHEEL_DELTA(flags) can be used alternatively.
|
||||
@note
|
||||
|
||||
Mouse-wheel events are currently supported only on Windows.
|
||||
|
||||
@param flags The mouse callback flags parameter.
|
||||
*/
|
||||
CV_EXPORTS int getMouseWheelDelta(int flags);
|
||||
|
||||
/** @brief Creates a trackbar and attaches it to the specified window.
|
||||
|
||||
The function createTrackbar creates a trackbar (a slider or range control) with the specified name
|
||||
and range, assigns a variable value to be a position synchronized with the trackbar and specifies
|
||||
the callback function onChange to be called on the trackbar position change. The created trackbar is
|
||||
displayed in the specified window winname.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar should be attached to the
|
||||
control panel.
|
||||
|
||||
Clicking the label of each trackbar enables editing the trackbar values manually.
|
||||
|
||||
@param trackbarname Name of the created trackbar.
|
||||
@param winname Name of the window that will be used as a parent of the created trackbar.
|
||||
@param value Optional pointer to an integer variable whose value reflects the position of the
|
||||
@@ -437,19 +476,6 @@ position and the second parameter is the user data (see the next parameter). If
|
||||
the NULL pointer, no callbacks are called, but only value is updated.
|
||||
@param userdata User data that is passed as is to the callback. It can be used to handle trackbar
|
||||
events without using global variables.
|
||||
|
||||
The function createTrackbar creates a trackbar (a slider or range control) with the specified name
|
||||
and range, assigns a variable value to be a position synchronized with the trackbar and specifies
|
||||
the callback function onChange to be called on the trackbar position change. The created trackbar is
|
||||
displayed in the specified window winname.
|
||||
|
||||
@note
|
||||
|
||||
**[Qt Backend Only]** winname can be empty (or NULL) if the trackbar should be attached to the
|
||||
control panel.
|
||||
|
||||
Clicking the label of each trackbar enables editing the trackbar values manually.
|
||||
|
||||
*/
|
||||
CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
|
||||
int* value, int count,
|
||||
@@ -458,63 +484,77 @@ CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
|
||||
|
||||
/** @brief Returns the trackbar position.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of the trackbar.
|
||||
|
||||
The function returns the current position of the specified trackbar.
|
||||
|
||||
@note
|
||||
|
||||
**[Qt Backend Only]** winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of the trackbar.
|
||||
*/
|
||||
CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname);
|
||||
|
||||
/** @brief Sets the trackbar position.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param pos New position.
|
||||
|
||||
The function sets the position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
**[Qt Backend Only]** winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param pos New position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos);
|
||||
|
||||
/** @brief Sets the trackbar maximum position.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param maxval New maximum position.
|
||||
|
||||
The function sets the maximum position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
**[Qt Backend Only]** winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param maxval New maximum position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval);
|
||||
|
||||
/** @brief Sets the trackbar minimum position.
|
||||
|
||||
The function sets the minimum position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param minval New maximum position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval);
|
||||
|
||||
//! @addtogroup highgui_opengl OpenGL support
|
||||
//! @{
|
||||
|
||||
/** @brief Displays OpenGL 2D texture in the specified window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param tex OpenGL 2D texture data.
|
||||
*/
|
||||
CV_EXPORTS void imshow(const String& winname, const ogl::Texture2D& tex);
|
||||
|
||||
/** @brief Sets a callback function to be called to draw on top of displayed image.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param onOpenGlDraw Pointer to the function to be called every frame. This function should be
|
||||
prototyped as void Foo(void\*) .
|
||||
@param userdata Pointer passed to the callback function. *(Optional)*
|
||||
|
||||
The function setOpenGlDrawCallback can be used to draw 3D data on the window. See the example of
|
||||
callback function below: :
|
||||
callback function below:
|
||||
@code
|
||||
void on_opengl(void* param)
|
||||
{
|
||||
@@ -545,18 +585,23 @@ callback function below: :
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
|
||||
@param winname Name of the window.
|
||||
@param onOpenGlDraw Pointer to the function to be called every frame. This function should be
|
||||
prototyped as void Foo(void\*) .
|
||||
@param userdata Pointer passed to the callback function.(__Optional__)
|
||||
*/
|
||||
CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
|
||||
|
||||
/** @brief Sets the specified window as current OpenGL context.
|
||||
|
||||
@param winname Window name
|
||||
@param winname Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void setOpenGlContext(const String& winname);
|
||||
|
||||
/** @brief Force window to redraw its context and call draw callback ( setOpenGlDrawCallback ).
|
||||
/** @brief Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ).
|
||||
|
||||
@param winname Window name
|
||||
@param winname Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void updateWindow(const String& winname);
|
||||
|
||||
@@ -564,102 +609,103 @@ CV_EXPORTS void updateWindow(const String& winname);
|
||||
|
||||
//! @addtogroup highgui_qt
|
||||
//! @{
|
||||
// Only for Qt
|
||||
|
||||
/** @brief QtFont available only for Qt. See cv::fontQt
|
||||
*/
|
||||
struct QtFont
|
||||
{
|
||||
const char* nameFont; // Qt: nameFont
|
||||
Scalar color; // Qt: ColorFont -> cvScalar(blue_component, green_component, red_component[, alpha_component])
|
||||
int font_face; // Qt: bool italic
|
||||
const int* ascii; // font data and metrics
|
||||
const char* nameFont; //!< Name of the font
|
||||
Scalar color; //!< Color of the font. Scalar(blue_component, green_component, red_component[, alpha_component])
|
||||
int font_face; //!< See cv::QtFontStyles
|
||||
const int* ascii; //!< font data and metrics
|
||||
const int* greek;
|
||||
const int* cyrillic;
|
||||
float hscale, vscale;
|
||||
float shear; // slope coefficient: 0 - normal, >0 - italic
|
||||
int thickness; // Qt: weight
|
||||
float dx; // horizontal interval between letters
|
||||
int line_type; // Qt: PointSize
|
||||
float shear; //!< slope coefficient: 0 - normal, >0 - italic
|
||||
int thickness; //!< See cv::QtFontWeights
|
||||
float dx; //!< horizontal interval between letters
|
||||
int line_type; //!< PointSize
|
||||
};
|
||||
|
||||
/** @brief Creates the font to draw a text on an image.
|
||||
|
||||
The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText .
|
||||
|
||||
A basic usage of this function is the following: :
|
||||
@code
|
||||
QtFont font = fontQt("Times");
|
||||
addText( img1, "Hello World !", Point(50,50), font);
|
||||
@endcode
|
||||
|
||||
@param nameFont Name of the font. The name should match the name of a system font (such as
|
||||
*Times*). If the font is not found, a default one is used.
|
||||
@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the
|
||||
font is set to a system-dependent default value. Generally, this is 12 points.
|
||||
@param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV _ RGB
|
||||
@param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB
|
||||
for simplicity.
|
||||
@param weight Font weight. Available operation flags are : (cv::QtFontWeights) You can also specify a positive integer for better control.
|
||||
@param style Font style. The following operation flags are available: (cv::QtFontStyles)
|
||||
@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
|
||||
@param style Font style. Available operation flags are : cv::QtFontStyles
|
||||
@param spacing Spacing between characters. It can be negative or positive.
|
||||
|
||||
The function fontQt creates a QtFont object. This QtFont is not compatible with putText .
|
||||
|
||||
A basic usage of this function is the following: :
|
||||
@code
|
||||
QtFont font = fontQt(''Times'');
|
||||
addText( img1, ``Hello World !'', Point(50,50), font);
|
||||
@endcode
|
||||
*/
|
||||
CV_EXPORTS QtFont fontQt(const String& nameFont, int pointSize = -1,
|
||||
Scalar color = Scalar::all(0), int weight = QT_FONT_NORMAL,
|
||||
int style = QT_STYLE_NORMAL, int spacing = 0);
|
||||
|
||||
/** @brief Creates the font to draw a text on an image.
|
||||
/** @brief Draws a text on the image.
|
||||
|
||||
The function addText draws *text* on the image *img* using a specific font *font* (see example cv::fontQt
|
||||
)
|
||||
|
||||
@param img 8-bit 3-channel image where the text should be drawn.
|
||||
@param text Text to write on an image.
|
||||
@param org Point(x,y) where the text should start on an image.
|
||||
@param font Font to use to draw a text.
|
||||
|
||||
The function addText draws *text* on an image *img* using a specific font *font* (see example cv::fontQt
|
||||
)
|
||||
*/
|
||||
CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font);
|
||||
|
||||
/** @brief Displays a text on a window image as an overlay for a specified duration.
|
||||
|
||||
The function displayOverlay displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms*. The function does not modify the image, displayed in the window, that is,
|
||||
after the specified delay the original content of the window is restored.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param text Overlay text to write on a window image.
|
||||
@param delayms The period (in milliseconds), during which the overlay text is displayed. If this
|
||||
function is called before the previous overlay text timed out, the timer is restarted and the text
|
||||
is updated. If this value is zero, the text never disappears.
|
||||
|
||||
The function displayOverlay displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms*. The function does not modify the image, displayed in the window, that is,
|
||||
after the specified delay the original content of the window is restored.
|
||||
*/
|
||||
CV_EXPORTS void displayOverlay(const String& winname, const String& text, int delayms = 0);
|
||||
|
||||
/** @brief Displays a text on the window statusbar during the specified period of time.
|
||||
|
||||
The function displayStatusBar displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms* . This information is displayed on the window statusbar (the window must be
|
||||
created with the CV_GUI_EXPANDED flags).
|
||||
|
||||
@param winname Name of the window.
|
||||
@param text Text to write on the window statusbar.
|
||||
@param delayms Duration (in milliseconds) to display the text. If this function is called before
|
||||
the previous text timed out, the timer is restarted and the text is updated. If this value is
|
||||
zero, the text never disappears.
|
||||
|
||||
The function displayStatusBar displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms* . This information is displayed on the window statusbar (the window must be
|
||||
created with the CV_GUI_EXPANDED flags).
|
||||
*/
|
||||
CV_EXPORTS void displayStatusBar(const String& winname, const String& text, int delayms = 0);
|
||||
|
||||
/** @brief Saves parameters of the specified window.
|
||||
|
||||
@param windowName Name of the window.
|
||||
|
||||
The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning
|
||||
location of the window window_name .
|
||||
location of the window windowName.
|
||||
|
||||
@param windowName Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void saveWindowParameters(const String& windowName);
|
||||
|
||||
/** @brief Loads parameters of the specified window.
|
||||
|
||||
@param windowName Name of the window.
|
||||
|
||||
The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning
|
||||
location of the window window_name .
|
||||
location of the window windowName.
|
||||
|
||||
@param windowName Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void loadWindowParameters(const String& windowName);
|
||||
|
||||
@@ -669,21 +715,11 @@ CV_EXPORTS void stopLoop();
|
||||
|
||||
/** @brief Attaches a button to the control panel.
|
||||
|
||||
@param bar_name
|
||||
Name of the button.
|
||||
@param on_change Pointer to the function to be called every time the button changes its state.
|
||||
This function should be prototyped as void Foo(int state,\*void); . *state* is the current state
|
||||
of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
|
||||
@param userdata Pointer passed to the callback function.
|
||||
@param type Optional type of the button. Available types are: (cv::QtButtonTypes)
|
||||
@param initial_button_state Default state of the button. Use for checkbox and radiobox. Its
|
||||
value could be 0 or 1. *(Optional)*
|
||||
|
||||
The function createButton attaches a button to the control panel. Each button is added to a
|
||||
buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the
|
||||
control panel before, or if the last element attached to the control panel was a trackbar.
|
||||
|
||||
See below various examples of the createButton function call: :
|
||||
See below various examples of the cv::createButton function call: :
|
||||
@code
|
||||
createButton(NULL,callbackButton);//create a push button "button 0", that will call callbackButton.
|
||||
createButton("button2",callbackButton,NULL,QT_CHECKBOX,0);
|
||||
@@ -691,6 +727,15 @@ See below various examples of the createButton function call: :
|
||||
createButton("button5",callbackButton1,NULL,QT_RADIOBOX);
|
||||
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1);
|
||||
@endcode
|
||||
|
||||
@param bar_name Name of the button.
|
||||
@param on_change Pointer to the function to be called every time the button changes its state.
|
||||
This function should be prototyped as void Foo(int state,\*void); . *state* is the current state
|
||||
of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
|
||||
@param userdata Pointer passed to the callback function.
|
||||
@param type Optional type of the button. Available types are: (cv::QtButtonTypes)
|
||||
@param initial_button_state Default state of the button. Use for checkbox and radiobox. Its
|
||||
value could be 0 or 1. (__Optional__)
|
||||
*/
|
||||
CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change,
|
||||
void* userdata = 0, int type = QT_PUSH_BUTTON,
|
||||
|
||||
@@ -166,6 +166,7 @@ CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name
|
||||
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
|
||||
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
|
||||
CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
|
||||
CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -216,6 +216,11 @@ void cv::setTrackbarMax(const String& trackbarName, const String& winName, int m
|
||||
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
|
||||
}
|
||||
|
||||
void cv::setTrackbarMin(const String& trackbarName, const String& winName, int minval)
|
||||
{
|
||||
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
|
||||
}
|
||||
|
||||
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
|
||||
{
|
||||
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
|
||||
@@ -589,6 +594,11 @@ CV_IMPL void cvSetTrackbarMax(const char*, const char*, int)
|
||||
CV_NO_GUI_ERROR( "cvSetTrackbarMax" );
|
||||
}
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char*, const char*, int)
|
||||
{
|
||||
CV_NO_GUI_ERROR( "cvSetTrackbarMin" );
|
||||
}
|
||||
|
||||
CV_IMPL void* cvGetWindowHandle( const char* )
|
||||
{
|
||||
CV_NO_GUI_ERROR( "cvGetWindowHandle" );
|
||||
|
||||
@@ -664,12 +664,29 @@ CV_IMPL void cvSetTrackbarMax(const char* name_bar, const char* window_name, int
|
||||
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
|
||||
if (t)
|
||||
{
|
||||
int minval = t->slider->minimum();
|
||||
maxval = (maxval>minval)?maxval:minval;
|
||||
t->slider->setMaximum(maxval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char* name_bar, const char* window_name, int minval)
|
||||
{
|
||||
if (minval >= 0)
|
||||
{
|
||||
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
|
||||
if (t)
|
||||
{
|
||||
int maxval = t->slider->maximum();
|
||||
minval = (maxval<minval)?maxval:minval;
|
||||
t->slider->setMinimum(minval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* assign callback for mouse events */
|
||||
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
|
||||
{
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
#include <QFileDialog>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
|
||||
@@ -62,6 +62,7 @@ CV_IMPL void cvSetMouseCallback( const char* name, CvMouseCallback function, voi
|
||||
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name ) {return 0;}
|
||||
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos) {}
|
||||
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval) {}
|
||||
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval) {}
|
||||
CV_IMPL void* cvGetWindowHandle( const char* name ) {return NULL;}
|
||||
CV_IMPL const char* cvGetWindowName( void* window_handle ) {return NULL;}
|
||||
CV_IMPL int cvNamedWindow( const char* name, int flags ) {return 0; }
|
||||
@@ -426,7 +427,7 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
|
||||
|
||||
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
|
||||
{
|
||||
CV_FUNCNAME("cvSetTrackbarPos");
|
||||
CV_FUNCNAME("cvSetTrackbarMax");
|
||||
|
||||
CVWindow *window = nil;
|
||||
CVSlider *slider = nil;
|
||||
@@ -445,6 +446,8 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
slider = [[window sliders] valueForKey:[NSString stringWithFormat:@"%s", trackbar_name]];
|
||||
if(slider) {
|
||||
if(maxval >= 0) {
|
||||
int minval = [[slider slider] minValue];
|
||||
maxval = (minval>maxval)?minval:maxval;
|
||||
[[slider slider] setMaxValue:maxval];
|
||||
}
|
||||
}
|
||||
@@ -454,6 +457,37 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
__END__;
|
||||
}
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
|
||||
{
|
||||
CV_FUNCNAME("cvSetTrackbarMin");
|
||||
|
||||
CVWindow *window = nil;
|
||||
CVSlider *slider = nil;
|
||||
NSAutoreleasePool* localpool5 = nil;
|
||||
|
||||
__BEGIN__;
|
||||
if(trackbar_name == NULL || window_name == NULL)
|
||||
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
|
||||
|
||||
if (localpool5 != nil) [localpool5 drain];
|
||||
localpool5 = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
window = cvGetWindow(window_name);
|
||||
if(window) {
|
||||
slider = [[window sliders] valueForKey:[NSString stringWithFormat:@"%s", trackbar_name]];
|
||||
if(slider) {
|
||||
if(minval >= 0) {
|
||||
int maxval = [[slider slider] maxValue];
|
||||
minval = (minval<maxval)?minval:maxval;
|
||||
[[slider slider] setMinValue:minval];
|
||||
}
|
||||
}
|
||||
}
|
||||
[localpool5 drain];
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
CV_IMPL void* cvGetWindowHandle( const char* name )
|
||||
{
|
||||
//cout << "cvGetWindowHandle" << endl;
|
||||
|
||||
@@ -246,7 +246,7 @@ cvImageWidget_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint
|
||||
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
|
||||
|
||||
if(image_widget->original_image != NULL) {
|
||||
*minimal_width = image_widget->flags & CV_WINDOW_AUTOSIZE ?
|
||||
*minimal_width = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ?
|
||||
gdk_window_get_width(gtk_widget_get_window(widget)) : image_widget->original_image->cols;
|
||||
}
|
||||
else {
|
||||
@@ -270,7 +270,7 @@ cvImageWidget_get_preferred_height (GtkWidget *widget, gint *minimal_height, gin
|
||||
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
|
||||
|
||||
if(image_widget->original_image != NULL) {
|
||||
*minimal_height = image_widget->flags & CV_WINDOW_AUTOSIZE ?
|
||||
*minimal_height = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ?
|
||||
gdk_window_get_height(gtk_widget_get_window(widget)) : image_widget->original_image->rows;
|
||||
}
|
||||
else {
|
||||
@@ -508,6 +508,7 @@ typedef struct CvTrackbar
|
||||
int* data;
|
||||
int pos;
|
||||
int maxval;
|
||||
int minval;
|
||||
CvTrackbarCallback notify;
|
||||
CvTrackbarCallback2 notify2;
|
||||
void* userdata;
|
||||
@@ -1607,7 +1608,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
trackbar = icvFindTrackbarByName(window, trackbar_name);
|
||||
if (trackbar)
|
||||
{
|
||||
trackbar->maxval = maxval;
|
||||
trackbar->maxval = (trackbar->minval>maxval)?trackbar->minval:maxval;
|
||||
|
||||
CV_LOCK_MUTEX();
|
||||
|
||||
@@ -1622,6 +1623,43 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
|
||||
{
|
||||
CV_FUNCNAME("cvSetTrackbarMin");
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
if (minval >= 0)
|
||||
{
|
||||
CvWindow* window = 0;
|
||||
CvTrackbar* trackbar = 0;
|
||||
|
||||
if (trackbar_name == 0 || window_name == 0)
|
||||
{
|
||||
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name");
|
||||
}
|
||||
|
||||
window = icvFindWindowByName( window_name );
|
||||
if (window)
|
||||
{
|
||||
trackbar = icvFindTrackbarByName(window, trackbar_name);
|
||||
if (trackbar)
|
||||
{
|
||||
trackbar->minval = (minval<trackbar->maxval)?minval:trackbar->maxval;
|
||||
|
||||
CV_LOCK_MUTEX();
|
||||
|
||||
gtk_range_set_range(GTK_RANGE(trackbar->widget), minval, trackbar->maxval);
|
||||
|
||||
CV_UNLOCK_MUTEX();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL void* cvGetWindowHandle( const char* window_name )
|
||||
{
|
||||
void* widget = 0;
|
||||
|
||||
@@ -138,6 +138,7 @@ typedef struct CvTrackbar
|
||||
int* data;
|
||||
int pos;
|
||||
int maxval;
|
||||
int minval;
|
||||
void (*notify)(int);
|
||||
void (*notify2)(int, void*);
|
||||
void* userdata;
|
||||
@@ -1909,7 +1910,8 @@ static void showSaveDialog(CvWindow* window)
|
||||
|
||||
if (GetSaveFileName(&ofn))
|
||||
{
|
||||
cv::Mat tmp; cv::flip(cv::Mat(sz.cy, sz.cx, CV_8UC(channels), data), tmp, 0);
|
||||
cv::Mat tmp;
|
||||
cv::flip(cv::Mat(sz.cy, sz.cx, CV_8UC(channels), data, (sz.cx * channels + 3) & -4), tmp, 0);
|
||||
cv::imwrite(szFileName, tmp);
|
||||
}
|
||||
}
|
||||
@@ -2324,7 +2326,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
if (trackbar)
|
||||
{
|
||||
// The position will be min(pos, maxval).
|
||||
trackbar->maxval = maxval;
|
||||
trackbar->maxval = (trackbar->minval>maxval)?trackbar->minval:maxval;
|
||||
SendMessage(trackbar->hwnd, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)maxval);
|
||||
}
|
||||
}
|
||||
@@ -2334,6 +2336,38 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
|
||||
{
|
||||
CV_FUNCNAME( "cvSetTrackbarMin" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
if (minval >= 0)
|
||||
{
|
||||
CvWindow* window = 0;
|
||||
CvTrackbar* trackbar = 0;
|
||||
if (trackbar_name == 0 || window_name == 0)
|
||||
{
|
||||
CV_ERROR(CV_StsNullPtr, "NULL trackbar or window name");
|
||||
}
|
||||
|
||||
window = icvFindWindowByName(window_name);
|
||||
if (window)
|
||||
{
|
||||
trackbar = icvFindTrackbarByName(window, trackbar_name);
|
||||
if (trackbar)
|
||||
{
|
||||
// The position will be min(pos, maxval).
|
||||
trackbar->minval = (minval<trackbar->maxval)?minval:trackbar->maxval;
|
||||
SendMessage(trackbar->hwnd, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)minval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
|
||||
CV_IMPL void* cvGetWindowHandle( const char* window_name )
|
||||
{
|
||||
void* hwnd = 0;
|
||||
|
||||
@@ -170,6 +170,22 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
||||
}
|
||||
}
|
||||
|
||||
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
|
||||
{
|
||||
CV_FUNCNAME("cvSetTrackbarMin");
|
||||
|
||||
if (minval >= 0)
|
||||
{
|
||||
if (trackbar_name == 0 || window_name == 0)
|
||||
CV_ERROR(CV_StsNullPtr, "NULL trackbar or window name");
|
||||
|
||||
CvTrackbar* trackbar = HighguiBridge::getInstance().findTrackbarByName(trackbar_name, window_name);
|
||||
|
||||
if (trackbar)
|
||||
trackbar->setMinPosition(minval);
|
||||
}
|
||||
}
|
||||
|
||||
CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
|
||||
{
|
||||
int pos = -1;
|
||||
|
||||
@@ -171,12 +171,23 @@ void CvTrackbar::setPosition(double pos)
|
||||
|
||||
void CvTrackbar::setMaxPosition(double pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
//slider->Minimum is initialized with 0
|
||||
if (pos < slider->Minimum)
|
||||
pos = slider->Minimum;
|
||||
|
||||
slider->Maximum = pos;
|
||||
}
|
||||
|
||||
void CvTrackbar::setMinPosition(double pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
//Min is always less than Max.
|
||||
if ((pos > slider->Maximum)
|
||||
pos = slider->Maximum;
|
||||
slider->Minimum = pos;
|
||||
}
|
||||
|
||||
void CvTrackbar::setSlider(Slider^ slider) {
|
||||
if (slider)
|
||||
this->slider = slider;
|
||||
@@ -192,6 +203,11 @@ double CvTrackbar::getMaxPosition()
|
||||
return slider->Maximum;
|
||||
}
|
||||
|
||||
double CvTrackbar::getMinPosition()
|
||||
{
|
||||
return slider->Minimum;
|
||||
}
|
||||
|
||||
Slider^ CvTrackbar::getSlider()
|
||||
{
|
||||
return slider;
|
||||
|
||||
@@ -151,6 +151,8 @@ public:
|
||||
void setPosition(double pos);
|
||||
double getMaxPosition();
|
||||
void setMaxPosition(double pos);
|
||||
double getMinPosition();
|
||||
void setMinPosition(double pos);
|
||||
Slider^ getSlider();
|
||||
void setSlider(Slider^ pos);
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp)
|
||||
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp)
|
||||
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp)
|
||||
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp)
|
||||
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/jpeg_exif.hpp)
|
||||
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/jpeg_exif.cpp)
|
||||
|
||||
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
||||
|
||||
|
||||
@@ -62,12 +62,18 @@ namespace cv
|
||||
|
||||
//! Imread flags
|
||||
enum ImreadModes {
|
||||
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
|
||||
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image.
|
||||
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
|
||||
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
|
||||
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
|
||||
IMREAD_LOAD_GDAL = 8 //!< If set, use the gdal driver for loading the image.
|
||||
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
|
||||
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image.
|
||||
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
|
||||
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
|
||||
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
|
||||
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
|
||||
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
|
||||
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
|
||||
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
|
||||
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
|
||||
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
|
||||
IMREAD_REDUCED_COLOR_8 = 65 //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
|
||||
};
|
||||
|
||||
//! Imwrite flags
|
||||
@@ -85,25 +91,31 @@ enum ImwriteFlags {
|
||||
IMWRITE_WEBP_QUALITY = 64 //!< For WEBP, it can be a 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.
|
||||
};
|
||||
|
||||
//! Imwrite PNG specific flags
|
||||
//! Imwrite PNG specific flags used to tune the compression algorithm.
|
||||
/** These flags will be modify the way of PNG image compression and will be passed to the underlying zlib processing stage.
|
||||
|
||||
- The effect of IMWRITE_PNG_STRATEGY_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between IMWRITE_PNG_STRATEGY_DEFAULT and IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY.
|
||||
- IMWRITE_PNG_STRATEGY_RLE is designed to be almost as fast as IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, but give better compression for PNG image data.
|
||||
- The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately.
|
||||
- IMWRITE_PNG_STRATEGY_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
|
||||
*/
|
||||
enum ImwritePNGFlags {
|
||||
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
|
||||
IMWRITE_PNG_STRATEGY_DEFAULT = 0, //!< Use this value for normal data.
|
||||
IMWRITE_PNG_STRATEGY_FILTERED = 1, //!< Use this value for data produced by a filter (or predictor).Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better.
|
||||
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2, //!< Use this value to force Huffman encoding only (no string match).
|
||||
IMWRITE_PNG_STRATEGY_RLE = 3, //!< Use this value to limit match distances to one (run-length encoding).
|
||||
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
|
||||
};
|
||||
|
||||
/** @brief Loads an image from a file.
|
||||
|
||||
@anchor imread
|
||||
|
||||
@param filename Name of file to be loaded.
|
||||
@param flags Flag that can take values of @ref cv::ImreadModes
|
||||
|
||||
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:
|
||||
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)
|
||||
@@ -120,6 +132,7 @@ returns an empty matrix ( Mat::data==NULL ). Currently, the following file forma
|
||||
@note
|
||||
|
||||
- The function determines the type of an image by the content, not by the file extension.
|
||||
- In the case of color images, the decoded images will have the channels stored in **B G R** order.
|
||||
- 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
|
||||
@@ -133,46 +146,35 @@ returns an empty matrix ( Mat::data==NULL ). Currently, the following file forma
|
||||
then [GDAL](http://www.gdal.org) driver will be used in order to decode the image by supporting
|
||||
the following formats: [Raster](http://www.gdal.org/formats_list.html),
|
||||
[Vector](http://www.gdal.org/ogr_formats.html).
|
||||
|
||||
@note In the case of color images, the decoded images will have the channels stored in B G R order.
|
||||
*/
|
||||
@param filename Name of file to be loaded.
|
||||
@param flags Flag that can take values of cv::ImreadModes
|
||||
*/
|
||||
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
|
||||
|
||||
/** @brief Loads and resizes down an image from a file.
|
||||
@anchor imread_reduced
|
||||
@param filename Name of file to be loaded.
|
||||
@param flags Flag that can take values of @ref cv::ImreadModes
|
||||
@param scale_denom
|
||||
*/
|
||||
CV_EXPORTS_W Mat imread_reduced( const String& filename, int flags = IMREAD_COLOR, int scale_denom=1 );
|
||||
|
||||
/** @brief Loads a multi-page image from a file. (see imread for details.)
|
||||
/** @brief Loads a multi-page image from a file.
|
||||
|
||||
The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
|
||||
@param filename Name of file to be loaded.
|
||||
@param flags Flag that can take values of @ref cv::ImreadModes, default with IMREAD_ANYCOLOR.
|
||||
@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
|
||||
@param mats A vector of Mat objects holding each page, if more than one.
|
||||
|
||||
@sa cv::imread
|
||||
*/
|
||||
CV_EXPORTS_W bool imreadmulti(const String& filename, std::vector<Mat>& mats, int flags = IMREAD_ANYCOLOR);
|
||||
|
||||
/** @brief Saves an image to a specified file.
|
||||
|
||||
@param filename Name of the file.
|
||||
@param img Image to be saved.
|
||||
@param params Format-specific save parameters encoded as pairs, see @ref cv::ImwriteFlags
|
||||
paramId_1, paramValue_1, paramId_2, paramValue_2, ... .
|
||||
|
||||
The function imwrite saves the image to the specified file. The image format is chosen based on the
|
||||
filename extension (see imread for the list of extensions). Only 8-bit (or 16-bit unsigned (CV_16U)
|
||||
filename extension (see cv::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
|
||||
Mat::convertTo , and cvtColor to convert it before saving. Or, use the universal FileStorage I/O
|
||||
Mat::convertTo , and cv::cvtColor to convert it before saving. Or, use the universal 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
|
||||
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 :
|
||||
@code
|
||||
#include <vector>
|
||||
@@ -218,42 +220,44 @@ compression parameters :
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
@param filename Name of the file.
|
||||
@param img Image to be saved.
|
||||
@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
|
||||
*/
|
||||
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
|
||||
|
||||
/** @brief Reads an image from a buffer in memory.
|
||||
|
||||
The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or
|
||||
contains invalid data, the function returns an empty matrix ( Mat::data==NULL ).
|
||||
|
||||
See cv::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.
|
||||
@param buf Input array or vector of bytes.
|
||||
@param flags The same flags as in imread, see @ref cv::ImreadModes.
|
||||
@param flags The same flags as in cv::imread, see cv::ImreadModes.
|
||||
*/
|
||||
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
|
||||
|
||||
/** @overload
|
||||
@param buf
|
||||
@param flags
|
||||
@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 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.
|
||||
*/
|
||||
*/
|
||||
CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst);
|
||||
|
||||
/** @brief Encodes an image into a memory buffer.
|
||||
|
||||
The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
|
||||
result. See cv::imwrite for the list of supported formats and flags description.
|
||||
|
||||
@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 imwrite and @ref cv::ImwriteFlags.
|
||||
|
||||
The function compresses the image and stores it in the memory buffer that is resized to fit the
|
||||
result. See 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.
|
||||
*/
|
||||
@param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
|
||||
*/
|
||||
CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
|
||||
CV_OUT std::vector<uchar>& buf,
|
||||
const std::vector<int>& params = std::vector<int>());
|
||||
@@ -262,4 +266,4 @@ CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
|
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_IMGCODECS_HPP__
|
||||
#endif //__OPENCV_IMGCODECS_HPP__
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_jpeg.hpp"
|
||||
#include "jpeg_exif.hpp"
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
|
||||
@@ -177,6 +178,7 @@ JpegDecoder::JpegDecoder()
|
||||
m_state = 0;
|
||||
m_f = 0;
|
||||
m_buf_supported = true;
|
||||
m_orientation = JPEG_ORIENTATION_TL;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,12 +255,64 @@ bool JpegDecoder::readHeader()
|
||||
}
|
||||
}
|
||||
|
||||
m_orientation = getOrientation();
|
||||
|
||||
if( !result )
|
||||
close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int JpegDecoder::getOrientation()
|
||||
{
|
||||
int orientation = JPEG_ORIENTATION_TL;
|
||||
|
||||
ExifReader reader( m_filename );
|
||||
if( reader.parse() )
|
||||
{
|
||||
orientation = reader.getTag( ORIENTATION ).field_u16;//orientation is unsigned short, so check field_u16
|
||||
}
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void JpegDecoder::setOrientation(Mat& img)
|
||||
{
|
||||
switch( m_orientation )
|
||||
{
|
||||
case JPEG_ORIENTATION_TL: //0th row == visual top, 0th column == visual left-hand side
|
||||
//do nothing, the image already has proper orientation
|
||||
break;
|
||||
case JPEG_ORIENTATION_TR: //0th row == visual top, 0th column == visual right-hand side
|
||||
flip(img, img, 1); //flip horizontally
|
||||
break;
|
||||
case JPEG_ORIENTATION_BR: //0th row == visual bottom, 0th column == visual right-hand side
|
||||
flip(img, img, -1);//flip both horizontally and vertically
|
||||
break;
|
||||
case JPEG_ORIENTATION_BL: //0th row == visual bottom, 0th column == visual left-hand side
|
||||
flip(img, img, 0); //flip vertically
|
||||
break;
|
||||
case JPEG_ORIENTATION_LT: //0th row == visual left-hand side, 0th column == visual top
|
||||
transpose(img, img);
|
||||
break;
|
||||
case JPEG_ORIENTATION_RT: //0th row == visual right-hand side, 0th column == visual top
|
||||
transpose(img, img);
|
||||
flip(img, img, 1); //flip horizontally
|
||||
break;
|
||||
case JPEG_ORIENTATION_RB: //0th row == visual right-hand side, 0th column == visual bottom
|
||||
transpose(img, img);
|
||||
flip(img, img, -1); //flip both horizontally and vertically
|
||||
break;
|
||||
case JPEG_ORIENTATION_LB: //0th row == visual left-hand side, 0th column == visual bottom
|
||||
transpose(img, img);
|
||||
flip(img, img, 0); //flip vertically
|
||||
break;
|
||||
default:
|
||||
//by default the image read has normal (JPEG_ORIENTATION_TL) orientation
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* following code is for supporting MJPEG image files
|
||||
* based on a message of Laurent Pinchart on the video4linux mailing list
|
||||
@@ -472,8 +526,10 @@ bool JpegDecoder::readData( Mat& img )
|
||||
icvCvt_CMYK2Gray_8u_C4C1R( buffer[0], 0, data, 0, cvSize(m_width,1) );
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
jpeg_finish_decompress( cinfo );
|
||||
setOrientation( img );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,12 @@ protected:
|
||||
|
||||
FILE* m_f;
|
||||
void* m_state;
|
||||
|
||||
private:
|
||||
//Support for handling exif orientation tag in Jpeg file
|
||||
int m_orientation;
|
||||
int getOrientation();
|
||||
void setOrientation(Mat& img);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
|
||||
{
|
||||
f = fopen( m_filename.c_str(), "wb" );
|
||||
if( f )
|
||||
png_init_io( png_ptr, f );
|
||||
png_init_io( png_ptr, (png_FILE_p)f );
|
||||
}
|
||||
|
||||
int compression_level = -1; // Invalid value to allow setting 0-9 as valid
|
||||
@@ -437,7 +437,7 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
|
||||
}
|
||||
|
||||
png_destroy_write_struct( &png_ptr, &info_ptr );
|
||||
if(f) fclose( f );
|
||||
if(f) fclose( (FILE*)f );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,582 @@
|
||||
/*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*/
|
||||
|
||||
#include "jpeg_exif.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief ExifReader constructor
|
||||
*/
|
||||
ExifReader::ExifReader(std::string filename) : m_filename(filename)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ExifReader destructor
|
||||
*/
|
||||
ExifReader::~ExifReader()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parsing the jpeg file and prepare (internally) exif directory structure
|
||||
* @return true if parsing was successful and exif information exists in JpegReader object
|
||||
* false in case of unsuccessful parsing
|
||||
*/
|
||||
bool ExifReader::parse()
|
||||
{
|
||||
m_exif = getExif();
|
||||
if( !m_exif.empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get tag value by tag number
|
||||
*
|
||||
* @param [in] tag The tag number
|
||||
*
|
||||
* @return ExifEntru_t structure. Caller has to know what tag it calls in order to extract proper field from the structure ExifEntry_t
|
||||
*
|
||||
*/
|
||||
ExifEntry_t ExifReader::getTag(const ExifTagName tag)
|
||||
{
|
||||
ExifEntry_t entry;
|
||||
std::map<int, ExifEntry_t>::iterator it = m_exif.find(tag);
|
||||
|
||||
if( it != m_exif.end() )
|
||||
{
|
||||
entry = it->second;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get exif directory structure contained in jpeg file (if any)
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return Map where key is tag number and value is ExifEntry_t structure
|
||||
*/
|
||||
std::map<int, ExifEntry_t > ExifReader::getExif()
|
||||
{
|
||||
const size_t markerSize = 2;
|
||||
const size_t offsetToTiffHeader = 6; //bytes from Exif size field to the first TIFF header
|
||||
unsigned char appMarker[markerSize];
|
||||
m_exif.erase( m_exif.begin(), m_exif.end() );
|
||||
|
||||
size_t count;
|
||||
|
||||
FILE* f = fopen( m_filename.c_str(), "rb" );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
return m_exif; //Until this moment the map is empty
|
||||
}
|
||||
|
||||
bool exifFound = false;
|
||||
while( ( !feof( f ) ) && !exifFound )
|
||||
{
|
||||
count = fread( appMarker, sizeof(unsigned char), markerSize, f );
|
||||
if( count < markerSize )
|
||||
{
|
||||
break;
|
||||
}
|
||||
unsigned char marker = appMarker[1];
|
||||
size_t bytesToSkip;
|
||||
size_t exifSize;
|
||||
switch( marker )
|
||||
{
|
||||
//For all the markers just skip bytes in file pointed by followed two bytes (field size)
|
||||
case SOF0: case SOF2: case DHT: case DQT: case DRI: case SOS:
|
||||
case RST0: case RST1: case RST2: case RST3: case RST4: case RST5: case RST6: case RST7:
|
||||
case APP0: case APP2: case APP3: case APP4: case APP5: case APP6: case APP7: case APP8:
|
||||
case APP9: case APP10: case APP11: case APP12: case APP13: case APP14: case APP15:
|
||||
case COM:
|
||||
bytesToSkip = getFieldSize( f );
|
||||
fseek( f, static_cast<long>( bytesToSkip - markerSize ), SEEK_CUR );
|
||||
break;
|
||||
|
||||
//SOI and EOI don't have the size field after the marker
|
||||
case SOI: case EOI:
|
||||
break;
|
||||
|
||||
case APP1: //actual Exif Marker
|
||||
exifSize = getFieldSize(f);
|
||||
m_data.resize( exifSize - offsetToTiffHeader );
|
||||
fseek(f, static_cast<long>( offsetToTiffHeader ), SEEK_CUR);
|
||||
count = fread( &m_data[0], sizeof( unsigned char ), exifSize - offsetToTiffHeader, f );
|
||||
exifFound = true;
|
||||
break;
|
||||
|
||||
default: //No other markers are expected according to standard. May be a signal of error
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
if( !exifFound )
|
||||
{
|
||||
return m_exif;
|
||||
}
|
||||
|
||||
parseExif();
|
||||
|
||||
return m_exif;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the size of exif field (required to properly ready whole exif from the file)
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return size of exif field in the file
|
||||
*/
|
||||
size_t ExifReader::getFieldSize (FILE* f) const
|
||||
{
|
||||
unsigned char fieldSize[2];
|
||||
size_t count = fread ( fieldSize, sizeof( char ), 2, f );
|
||||
if (count < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ( fieldSize[0] << 8 ) + fieldSize[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Filling m_exif member with exif directory elements
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return The function doesn't return any value. In case of unsiccessful parsing
|
||||
* the m_exif member is not filled up
|
||||
*/
|
||||
void ExifReader::parseExif()
|
||||
{
|
||||
m_format = getFormat();
|
||||
|
||||
if( !checkTagMark() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t offset = getStartOffset();
|
||||
|
||||
size_t numEntry = getNumDirEntry();
|
||||
|
||||
offset += 2; //go to start of tag fields
|
||||
|
||||
for( size_t entry = 0; entry < numEntry; entry++ )
|
||||
{
|
||||
ExifEntry_t exifEntry = parseExifEntry( offset );
|
||||
m_exif.insert( std::make_pair( exifEntry.tag, exifEntry ) );
|
||||
offset += tiffFieldSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get endianness of exif information
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return INTEL, MOTO or NONE
|
||||
*/
|
||||
Endianess_t ExifReader::getFormat() const
|
||||
{
|
||||
if( m_data[0] != m_data[1] )
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
|
||||
if( m_data[0] == 'I' )
|
||||
{
|
||||
return INTEL;
|
||||
}
|
||||
|
||||
if( m_data[0] == 'M' )
|
||||
{
|
||||
return MOTO;
|
||||
}
|
||||
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checking whether Tag Mark (0x002A) correspond to one contained in the Jpeg file
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return true if tag mark equals 0x002A, false otherwise
|
||||
*/
|
||||
bool ExifReader::checkTagMark() const
|
||||
{
|
||||
uint16_t tagMark = getU16( 2 );
|
||||
|
||||
if( tagMark != tagMarkRequired )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The utility function for extracting actual offset exif IFD0 info is started from
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* @return offset of IFD0 field
|
||||
*/
|
||||
uint32_t ExifReader::getStartOffset() const
|
||||
{
|
||||
return getU32( 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of Directory Entries in Jpeg file
|
||||
*
|
||||
* @return The number of directory entries
|
||||
*/
|
||||
size_t ExifReader::getNumDirEntry() const
|
||||
{
|
||||
return getU16( offsetNumDir );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parsing particular entry in exif directory
|
||||
* This is internal function and is not exposed to client
|
||||
*
|
||||
* Entries are divided into 12-bytes blocks each
|
||||
* Each block corresponds the following structure:
|
||||
*
|
||||
* +------+-------------+-------------------+------------------------+
|
||||
* | Type | Data format | Num of components | Data or offset to data |
|
||||
* +======+=============+===================+========================+
|
||||
* | TTTT | ffff | NNNNNNNN | DDDDDDDD |
|
||||
* +------+-------------+-------------------+------------------------+
|
||||
*
|
||||
* Details can be found here: http://www.media.mit.edu/pia/Research/deepview/exif.html
|
||||
*
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return ExifEntry_t structure which corresponds to particular entry
|
||||
*
|
||||
*/
|
||||
ExifEntry_t ExifReader::parseExifEntry(const size_t offset)
|
||||
{
|
||||
ExifEntry_t entry;
|
||||
uint16_t tagNum = getExifTag( offset );
|
||||
entry.tag = tagNum;
|
||||
|
||||
switch( tagNum )
|
||||
{
|
||||
case IMAGE_DESCRIPTION:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case MAKE:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case MODEL:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case ORIENTATION:
|
||||
entry.field_u16 = getOrientation( offset );
|
||||
break;
|
||||
case XRESOLUTION:
|
||||
entry.field_u_rational = getResolution( offset );
|
||||
break;
|
||||
case YRESOLUTION:
|
||||
entry.field_u_rational = getResolution( offset );
|
||||
break;
|
||||
case RESOLUTION_UNIT:
|
||||
entry.field_u16 = getResolutionUnit( offset );
|
||||
break;
|
||||
case SOFTWARE:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case DATE_TIME:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case WHITE_POINT:
|
||||
entry.field_u_rational = getWhitePoint( offset );
|
||||
break;
|
||||
case PRIMARY_CHROMATICIES:
|
||||
entry.field_u_rational = getPrimaryChromaticies( offset );
|
||||
break;
|
||||
case Y_CB_CR_COEFFICIENTS:
|
||||
entry.field_u_rational = getYCbCrCoeffs( offset );
|
||||
break;
|
||||
case Y_CB_CR_POSITIONING:
|
||||
entry.field_u16 = getYCbCrPos( offset );
|
||||
break;
|
||||
case REFERENCE_BLACK_WHITE:
|
||||
entry.field_u_rational = getRefBW( offset );
|
||||
break;
|
||||
case COPYRIGHT:
|
||||
entry.field_str = getString( offset );
|
||||
break;
|
||||
case EXIF_OFFSET:
|
||||
break;
|
||||
default:
|
||||
entry.tag = INVALID_TAG;
|
||||
break;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get tag number from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return tag number
|
||||
*/
|
||||
uint16_t ExifReader::getExifTag(const size_t offset) const
|
||||
{
|
||||
return getU16( offset );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get string information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return string value
|
||||
*/
|
||||
std::string ExifReader::getString(const size_t offset) const
|
||||
{
|
||||
size_t size = getU32( offset + 4 );
|
||||
size_t dataOffset = 8; // position of data in the field
|
||||
if( size > maxDataSize )
|
||||
{
|
||||
dataOffset = getU32( offset + 8 );
|
||||
}
|
||||
std::vector<uint8_t>::const_iterator it = m_data.begin() + dataOffset;
|
||||
std::string result( it, it + size ); //copy vector content into result
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get unsigned short data from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return Unsigned short data
|
||||
*/
|
||||
uint16_t ExifReader::getU16(const size_t offset) const
|
||||
{
|
||||
if( m_format == INTEL )
|
||||
{
|
||||
return m_data[offset] + ( m_data[offset + 1] << 8 );
|
||||
}
|
||||
return ( m_data[offset] << 8 ) + m_data[offset + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get unsigned 32-bit data from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return Unsigned 32-bit data
|
||||
*/
|
||||
uint32_t ExifReader::getU32(const size_t offset) const
|
||||
{
|
||||
if( m_format == INTEL )
|
||||
{
|
||||
return m_data[offset] +
|
||||
( m_data[offset + 1] << 8 ) +
|
||||
( m_data[offset + 2] << 16 ) +
|
||||
( m_data[offset + 3] << 24 );
|
||||
}
|
||||
|
||||
return ( m_data[offset] << 24 ) +
|
||||
( m_data[offset + 1] << 16 ) +
|
||||
( m_data[offset + 2] << 8 ) +
|
||||
m_data[offset + 3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get unsigned rational data from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return Unsigned rational data
|
||||
*
|
||||
* "rational" means a fractional value, it contains 2 signed/unsigned long integer value,
|
||||
* and the first represents the numerator, the second, the denominator.
|
||||
*/
|
||||
u_rational_t ExifReader::getURational(const size_t offset) const
|
||||
{
|
||||
u_rational_t result;
|
||||
uint32_t numerator = getU32( offset );
|
||||
uint32_t denominator = getU32( offset + 4 );
|
||||
|
||||
return std::make_pair( numerator, denominator );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get orientation information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return orientation number
|
||||
*/
|
||||
uint16_t ExifReader::getOrientation(const size_t offset) const
|
||||
{
|
||||
return getU16( offset + 8 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get resolution information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return resolution value
|
||||
*/
|
||||
std::vector<u_rational_t> ExifReader::getResolution(const size_t offset) const
|
||||
{
|
||||
std::vector<u_rational_t> result;
|
||||
uint32_t rationalOffset = getU32( offset + 8 );
|
||||
result.push_back( getURational( rationalOffset ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get resolution unit from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return resolution unit value
|
||||
*/
|
||||
uint16_t ExifReader::getResolutionUnit(const size_t offset) const
|
||||
{
|
||||
return getU16( offset + 8 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get White Point information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return White Point value
|
||||
*
|
||||
* If the image uses CIE Standard Illumination D65(known as international
|
||||
* standard of 'daylight'), the values are '3127/10000,3290/10000'.
|
||||
*/
|
||||
std::vector<u_rational_t> ExifReader::getWhitePoint(const size_t offset) const
|
||||
{
|
||||
std::vector<u_rational_t> result;
|
||||
uint32_t rationalOffset = getU32( offset + 8 );
|
||||
result.push_back( getURational( rationalOffset ) );
|
||||
result.push_back( getURational( rationalOffset + 8 ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Primary Chromaticies information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return vector with primary chromaticies values
|
||||
*
|
||||
*/
|
||||
std::vector<u_rational_t> ExifReader::getPrimaryChromaticies(const size_t offset) const
|
||||
{
|
||||
std::vector<u_rational_t> result;
|
||||
uint32_t rationalOffset = getU32( offset + 8 );
|
||||
for( size_t i = 0; i < primaryChromaticiesComponents; i++ )
|
||||
{
|
||||
result.push_back( getURational( rationalOffset ) );
|
||||
rationalOffset += 8;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get YCbCr Coefficients information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return vector with YCbCr coefficients values
|
||||
*
|
||||
*/
|
||||
std::vector<u_rational_t> ExifReader::getYCbCrCoeffs(const size_t offset) const
|
||||
{
|
||||
std::vector<u_rational_t> result;
|
||||
uint32_t rationalOffset = getU32( offset + 8 );
|
||||
for( size_t i = 0; i < ycbcrCoeffs; i++ )
|
||||
{
|
||||
result.push_back( getURational( rationalOffset ) );
|
||||
rationalOffset += 8;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get YCbCr Positioning information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return vector with YCbCr positioning value
|
||||
*
|
||||
*/
|
||||
uint16_t ExifReader::getYCbCrPos(const size_t offset) const
|
||||
{
|
||||
return getU16( offset + 8 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Reference Black&White point information from raw exif data
|
||||
* This is internal function and is not exposed to client
|
||||
* @param [in] offset Offset to entry in bytes inside raw exif data
|
||||
* @return vector with reference BW points
|
||||
*
|
||||
* In case of YCbCr format, first 2 show black/white of Y, next 2 are Cb,
|
||||
* last 2 are Cr. In case of RGB format, first 2 show black/white of R,
|
||||
* next 2 are G, last 2 are B.
|
||||
*
|
||||
*/
|
||||
std::vector<u_rational_t> ExifReader::getRefBW(const size_t offset) const
|
||||
{
|
||||
const size_t rationalFieldSize = 8;
|
||||
std::vector<u_rational_t> result;
|
||||
uint32_t rationalOffset = getU32( offset + rationalFieldSize );
|
||||
for( size_t i = 0; i < refBWComponents; i++ )
|
||||
{
|
||||
result.push_back( getURational( rationalOffset ) );
|
||||
rationalOffset += rationalFieldSize;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} //namespace cv
|
||||
@@ -0,0 +1,251 @@
|
||||
/*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_JPEG_EXIF_HPP_
|
||||
#define _OPENCV_JPEG_EXIF_HPP_
|
||||
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
/**
|
||||
* @brief Jpeg markers that can encounter in Jpeg file
|
||||
*/
|
||||
enum AppMarkerTypes
|
||||
{
|
||||
SOI = 0xD8, SOF0 = 0xC0, SOF2 = 0xC2, DHT = 0xC4,
|
||||
DQT = 0xDB, DRI = 0xDD, SOS = 0xDA,
|
||||
|
||||
RST0 = 0xD0, RST1 = 0xD1, RST2 = 0xD2, RST3 = 0xD3,
|
||||
RST4 = 0xD4, RST5 = 0xD5, RST6 = 0xD6, RST7 = 0xD7,
|
||||
|
||||
APP0 = 0xE0, APP1 = 0xE1, APP2 = 0xE2, APP3 = 0xE3,
|
||||
APP4 = 0xE4, APP5 = 0xE5, APP6 = 0xE6, APP7 = 0xE7,
|
||||
APP8 = 0xE8, APP9 = 0xE9, APP10 = 0xEA, APP11 = 0xEB,
|
||||
APP12 = 0xEC, APP13 = 0xED, APP14 = 0xEE, APP15 = 0xEF,
|
||||
|
||||
COM = 0xFE, EOI = 0xD9
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Base Exif tags used by IFD0 (main image)
|
||||
*/
|
||||
enum ExifTagName
|
||||
{
|
||||
IMAGE_DESCRIPTION = 0x010E, ///< Image Description: ASCII string
|
||||
MAKE = 0x010F, ///< Description of manufacturer: ASCII string
|
||||
MODEL = 0x0110, ///< Description of camera model: ASCII string
|
||||
ORIENTATION = 0x0112, ///< Orientation of the image: unsigned short
|
||||
XRESOLUTION = 0x011A, ///< Resolution of the image across X axis: unsigned rational
|
||||
YRESOLUTION = 0x011B, ///< Resolution of the image across Y axis: unsigned rational
|
||||
RESOLUTION_UNIT = 0x0128, ///< Resolution units. '1' no-unit, '2' inch, '3' centimeter
|
||||
SOFTWARE = 0x0131, ///< Shows firmware(internal software of digicam) version number
|
||||
DATE_TIME = 0x0132, ///< Date/Time of image was last modified
|
||||
WHITE_POINT = 0x013E, ///< Chromaticity of white point of the image
|
||||
PRIMARY_CHROMATICIES = 0x013F, ///< Chromaticity of the primaries of the image
|
||||
Y_CB_CR_COEFFICIENTS = 0x0211, ///< constant to translate an image from YCbCr to RGB format
|
||||
Y_CB_CR_POSITIONING = 0x0213, ///< Chroma sample point of subsampling pixel array
|
||||
REFERENCE_BLACK_WHITE = 0x0214, ///< Reference value of black point/white point
|
||||
COPYRIGHT = 0x8298, ///< Copyright information
|
||||
EXIF_OFFSET = 0x8769, ///< Offset to Exif Sub IFD
|
||||
INVALID_TAG = 0xFFFF ///< Shows that the tag was not recognized
|
||||
};
|
||||
|
||||
enum Endianess_t
|
||||
{
|
||||
INTEL = 0x49,
|
||||
MOTO = 0x4D,
|
||||
NONE = 0x00
|
||||
};
|
||||
|
||||
typedef std::pair<uint32_t, uint32_t> u_rational_t;
|
||||
|
||||
/**
|
||||
* @brief Entry which contains possible values for different exif tags
|
||||
*/
|
||||
struct ExifEntry_t
|
||||
{
|
||||
std::vector<u_rational_t> field_u_rational; ///< vector of rational fields
|
||||
std::string field_str; ///< any kind of textual information
|
||||
|
||||
float field_float; ///< Currently is not used
|
||||
double field_double; ///< Currently is not used
|
||||
|
||||
uint32_t field_u32; ///< Unsigned 32-bit value
|
||||
int32_t field_s32; ///< Signed 32-bit value
|
||||
|
||||
uint16_t tag; ///< Tag number
|
||||
|
||||
uint16_t field_u16; ///< Unsigned 16-bit value
|
||||
int16_t field_s16; ///< Signed 16-bit value
|
||||
uint8_t field_u8; ///< Unsigned 8-bit value
|
||||
int8_t field_s8; ///< Signed 8-bit value
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Picture orientation which may be taken from JPEG's EXIF
|
||||
* Orientation usually matters when the picture is taken by
|
||||
* smartphone or other camera with orientation sensor support
|
||||
* Corresponds to EXIF 2.3 Specification
|
||||
*/
|
||||
enum JpegOrientation
|
||||
{
|
||||
JPEG_ORIENTATION_TL = 1, ///< 0th row == visual top, 0th column == visual left-hand side
|
||||
JPEG_ORIENTATION_TR = 2, ///< 0th row == visual top, 0th column == visual right-hand side
|
||||
JPEG_ORIENTATION_BR = 3, ///< 0th row == visual bottom, 0th column == visual right-hand side
|
||||
JPEG_ORIENTATION_BL = 4, ///< 0th row == visual bottom, 0th column == visual left-hand side
|
||||
JPEG_ORIENTATION_LT = 5, ///< 0th row == visual left-hand side, 0th column == visual top
|
||||
JPEG_ORIENTATION_RT = 6, ///< 0th row == visual right-hand side, 0th column == visual top
|
||||
JPEG_ORIENTATION_RB = 7, ///< 0th row == visual right-hand side, 0th column == visual bottom
|
||||
JPEG_ORIENTATION_LB = 8 ///< 0th row == visual left-hand side, 0th column == visual bottom
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Reading exif information from Jpeg file
|
||||
*
|
||||
* Usage example for getting the orientation of the image:
|
||||
*
|
||||
* @code
|
||||
* ExifReader reader(fileName);
|
||||
* if( reader.parse() )
|
||||
* {
|
||||
* int orientation = reader.getTag(Orientation).field_u16;
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
class ExifReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief ExifReader constructor. Constructs an object of exif reader
|
||||
*
|
||||
* @param [in]filename The name of file to look exif info in
|
||||
*/
|
||||
explicit ExifReader( std::string filename );
|
||||
~ExifReader();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parse the file with exif info
|
||||
*
|
||||
* @return true if parsing was successful and exif information exists in JpegReader object
|
||||
*/
|
||||
bool parse();
|
||||
|
||||
/**
|
||||
* @brief Get tag info by tag number
|
||||
*
|
||||
* @param [in] tag The tag number
|
||||
* @return ExifEntru_t structure. Caller has to know what tag it calls in order to extract proper field from the structure ExifEntry_t
|
||||
*/
|
||||
ExifEntry_t getTag( const ExifTagName tag );
|
||||
|
||||
private:
|
||||
std::string m_filename;
|
||||
std::vector<unsigned char> m_data;
|
||||
std::map<int, ExifEntry_t > m_exif;
|
||||
Endianess_t m_format;
|
||||
|
||||
void parseExif();
|
||||
bool checkTagMark() const;
|
||||
|
||||
size_t getFieldSize ( FILE* f ) const;
|
||||
size_t getNumDirEntry() const;
|
||||
uint32_t getStartOffset() const;
|
||||
uint16_t getExifTag( const size_t offset ) const;
|
||||
uint16_t getU16( const size_t offset ) const;
|
||||
uint32_t getU32( const size_t offset ) const;
|
||||
uint16_t getOrientation( const size_t offset ) const;
|
||||
uint16_t getResolutionUnit( const size_t offset ) const;
|
||||
uint16_t getYCbCrPos( const size_t offset ) const;
|
||||
|
||||
Endianess_t getFormat() const;
|
||||
|
||||
ExifEntry_t parseExifEntry( const size_t offset );
|
||||
|
||||
u_rational_t getURational( const size_t offset ) const;
|
||||
|
||||
std::map<int, ExifEntry_t > getExif();
|
||||
std::string getString( const size_t offset ) const;
|
||||
std::vector<u_rational_t> getResolution( const size_t offset ) const;
|
||||
std::vector<u_rational_t> getWhitePoint( const size_t offset ) const;
|
||||
std::vector<u_rational_t> getPrimaryChromaticies( const size_t offset ) const;
|
||||
std::vector<u_rational_t> getYCbCrCoeffs( const size_t offset ) const;
|
||||
std::vector<u_rational_t> getRefBW( const size_t offset ) const;
|
||||
|
||||
private:
|
||||
static const uint16_t tagMarkRequired = 0x2A;
|
||||
|
||||
//offset to the _number-of-directory-entry_ field
|
||||
static const size_t offsetNumDir = 8;
|
||||
|
||||
//max size of data in tag.
|
||||
//'DDDDDDDD' contains the value of that Tag. If its size is over 4bytes,
|
||||
//'DDDDDDDD' contains the offset to data stored address.
|
||||
static const size_t maxDataSize = 4;
|
||||
|
||||
//bytes per tag field
|
||||
static const size_t tiffFieldSize = 12;
|
||||
|
||||
//number of primary chromaticies components
|
||||
static const size_t primaryChromaticiesComponents = 6;
|
||||
|
||||
//number of YCbCr coefficients in field
|
||||
static const size_t ycbcrCoeffs = 3;
|
||||
|
||||
//number of Reference Black&White components
|
||||
static const size_t refBWComponents = 6;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* JPEG_EXIF_HPP_ */
|
||||
@@ -238,7 +238,7 @@ enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 };
|
||||
*
|
||||
*/
|
||||
static void*
|
||||
imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_denom=1 )
|
||||
imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
|
||||
{
|
||||
IplImage* image = 0;
|
||||
CvMat *matrix = 0;
|
||||
@@ -252,7 +252,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
|
||||
decoder = GdalDecoder().newDecoder();
|
||||
}else{
|
||||
#endif
|
||||
decoder = findDecoder(filename);
|
||||
decoder = findDecoder( filename );
|
||||
#ifdef HAVE_GDAL
|
||||
}
|
||||
#endif
|
||||
@@ -262,11 +262,22 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scale_denom = 1;
|
||||
if( flags > IMREAD_LOAD_GDAL )
|
||||
{
|
||||
if( flags & IMREAD_REDUCED_GRAYSCALE_2 )
|
||||
scale_denom = 2;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_4 )
|
||||
scale_denom = 4;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_8 )
|
||||
scale_denom = 8;
|
||||
}
|
||||
|
||||
/// set the scale_denom in the driver
|
||||
decoder->setScale( scale_denom );
|
||||
|
||||
/// set the filename in the driver
|
||||
decoder->setSource(filename);
|
||||
decoder->setSource( filename );
|
||||
|
||||
// read the header to make sure it succeeds
|
||||
if( !decoder->readHeader() )
|
||||
@@ -296,7 +307,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
|
||||
if( hdrtype == LOAD_CVMAT )
|
||||
{
|
||||
matrix = cvCreateMat( size.height, size.width, type );
|
||||
temp = cvarrToMat(matrix);
|
||||
temp = cvarrToMat( matrix );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -307,7 +318,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
|
||||
else
|
||||
{
|
||||
image = cvCreateImage( size, cvIplDepth(type), CV_MAT_CN(type) );
|
||||
temp = cvarrToMat(image);
|
||||
temp = cvarrToMat( image );
|
||||
}
|
||||
|
||||
// read the image data
|
||||
@@ -320,10 +331,9 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testdecoder = decoder->setScale( scale_denom ); // if decoder is JpegDecoder then testdecoder will be 1
|
||||
if( (scale_denom > 1 ) & ( testdecoder > 1 ) )
|
||||
if( decoder->setScale( scale_denom ) > 1 ) // if decoder is JpegDecoder then decoder->setScale always returns 1
|
||||
{
|
||||
resize(*mat,*mat,Size(size.width/scale_denom,size.height/scale_denom));
|
||||
resize( *mat, *mat, Size( size.width / scale_denom, size.height / scale_denom ) );
|
||||
}
|
||||
|
||||
return hdrtype == LOAD_CVMAT ? (void*)matrix :
|
||||
@@ -421,27 +431,6 @@ Mat imread( const String& filename, int flags )
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an image and resize it
|
||||
*
|
||||
* This function merely calls the actual implementation above and returns itself.
|
||||
*
|
||||
* @param[in] filename File to load
|
||||
* @param[in] flags Flags you wish to set.
|
||||
* @param[in] scale_denom Scale value
|
||||
*/
|
||||
Mat imread_reduced( const String& filename, int flags, int scale_denom )
|
||||
{
|
||||
/// create the basic container
|
||||
Mat img;
|
||||
|
||||
/// load the data
|
||||
imread_( filename, flags, LOAD_MAT, &img, scale_denom );
|
||||
|
||||
/// return a reference to the data
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a multi-page image
|
||||
*
|
||||
@@ -736,4 +725,4 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
|
||||
return _buf;
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
/* End of file. */
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
@@ -118,6 +119,150 @@ TEST(Imgcodecs_imread, regression)
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
string to_string(T i)
|
||||
{
|
||||
stringstream ss;
|
||||
string s;
|
||||
ss << i;
|
||||
s = ss.str();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for check whether reading exif orientation tag was processed successfully or not
|
||||
* The test info is the set of 8 images named testExifRotate_{1 to 8}.jpg
|
||||
* The test image is the square 10x10 points divided by four sub-squares:
|
||||
* (R corresponds to Red, G to Green, B to Blue, W to white)
|
||||
* --------- ---------
|
||||
* | R | G | | G | R |
|
||||
* |-------| - (tag 1) |-------| - (tag 2)
|
||||
* | B | W | | W | B |
|
||||
* --------- ---------
|
||||
*
|
||||
* --------- ---------
|
||||
* | W | B | | B | W |
|
||||
* |-------| - (tag 3) |-------| - (tag 4)
|
||||
* | G | R | | R | G |
|
||||
* --------- ---------
|
||||
*
|
||||
* --------- ---------
|
||||
* | R | B | | G | W |
|
||||
* |-------| - (tag 5) |-------| - (tag 6)
|
||||
* | G | W | | R | B |
|
||||
* --------- ---------
|
||||
*
|
||||
* --------- ---------
|
||||
* | W | G | | B | R |
|
||||
* |-------| - (tag 7) |-------| - (tag 8)
|
||||
* | B | R | | W | G |
|
||||
* --------- ---------
|
||||
*
|
||||
*
|
||||
* Every image contains exif field with orientation tag (0x112)
|
||||
* After reading each image the corresponding matrix must be read as
|
||||
* ---------
|
||||
* | R | G |
|
||||
* |-------|
|
||||
* | B | W |
|
||||
* ---------
|
||||
*
|
||||
*/
|
||||
class CV_GrfmtJpegExifOrientationTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
void run(int)
|
||||
{
|
||||
try
|
||||
{
|
||||
for( int i = 1; i <= 8; ++i)
|
||||
{
|
||||
string fileName = "readwrite/testExifOrientation_" + to_string(i) + ".jpg";
|
||||
m_img = imread(string(ts->get_data_path()) + fileName);
|
||||
if( !m_img.data )
|
||||
{
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
|
||||
}
|
||||
ts->printf(cvtest::TS::LOG, "start reading image\t%s\n", fileName.c_str());
|
||||
if( !checkOrientation() )
|
||||
{
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
|
||||
}
|
||||
}
|
||||
private:
|
||||
bool checkOrientation();
|
||||
Mat m_img;
|
||||
};
|
||||
|
||||
|
||||
bool CV_GrfmtJpegExifOrientationTest::checkOrientation()
|
||||
{
|
||||
Vec3b vec;
|
||||
int red = 0;
|
||||
int green = 0;
|
||||
int blue = 0;
|
||||
|
||||
const int colorThresholdHigh = 250;
|
||||
const int colorThresholdLow = 5;
|
||||
|
||||
//Checking the first quadrant (with supposed red)
|
||||
vec = m_img.at<Vec3b>(2, 2); //some point inside the square
|
||||
red = vec.val[2];
|
||||
green = vec.val[1];
|
||||
blue = vec.val[0];
|
||||
|
||||
ts->printf(cvtest::TS::LOG, "RED QUADRANT:\n");
|
||||
ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
|
||||
ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
|
||||
ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
|
||||
if( red < colorThresholdHigh ) return false;
|
||||
if( blue > colorThresholdLow ) return false;
|
||||
if( green > colorThresholdLow ) return false;
|
||||
|
||||
//Checking the second quadrant (with supposed green)
|
||||
vec = m_img.at<Vec3b>(2, 7); //some point inside the square
|
||||
red = vec.val[2];
|
||||
green = vec.val[1];
|
||||
blue = vec.val[0];
|
||||
ts->printf(cvtest::TS::LOG, "GREEN QUADRANT:\n");
|
||||
ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
|
||||
ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
|
||||
ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
|
||||
if( green < colorThresholdHigh ) return false;
|
||||
if( red > colorThresholdLow ) return false;
|
||||
if( blue > colorThresholdLow ) return false;
|
||||
|
||||
//Checking the third quadrant (with supposed blue)
|
||||
vec = m_img.at<Vec3b>(7, 2); //some point inside the square
|
||||
red = vec.val[2];
|
||||
green = vec.val[1];
|
||||
blue = vec.val[0];
|
||||
ts->printf(cvtest::TS::LOG, "BLUE QUADRANT:\n");
|
||||
ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
|
||||
ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
|
||||
ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
|
||||
if( blue < colorThresholdHigh ) return false;
|
||||
if( red > colorThresholdLow ) return false;
|
||||
if( green > colorThresholdLow ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST(Imgcodecs_jpeg_exif, setOrientation)
|
||||
{
|
||||
CV_GrfmtJpegExifOrientationTest test;
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
#ifdef HAVE_JASPER
|
||||
TEST(Imgcodecs_jasper, regression)
|
||||
{
|
||||
|
||||
@@ -1922,7 +1922,7 @@ CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
|
||||
|
||||
/** @brief Performs advanced morphological transformations.
|
||||
|
||||
The function can perform advanced morphological transformations using an erosion and dilation as
|
||||
The function morphologyEx can perform advanced morphological transformations using an erosion and dilation as
|
||||
basic operations.
|
||||
|
||||
Any of the operations can be done in-place. In case of multi-channel images, each channel is
|
||||
@@ -1930,11 +1930,11 @@ processed independently.
|
||||
|
||||
@param src Source image. The number of channels can be arbitrary. The depth should be one of
|
||||
CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
|
||||
@param dst Destination image of the same size and type as src\` .
|
||||
@param kernel Structuring element. It can be created using getStructuringElement.
|
||||
@param dst Destination image of the same size and type as source image.
|
||||
@param op Type of a morphological operation, see cv::MorphTypes
|
||||
@param kernel Structuring element. It can be created using cv::getStructuringElement.
|
||||
@param anchor Anchor position with the kernel. Negative values mean that the anchor is at the
|
||||
kernel center.
|
||||
@param op Type of a morphological operation, see cv::MorphTypes
|
||||
@param iterations Number of times erosion and dilation are applied.
|
||||
@param borderType Pixel extrapolation method, see cv::BorderTypes
|
||||
@param borderValue Border value in case of a constant border. The default value has a special
|
||||
@@ -3404,8 +3404,9 @@ CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels,
|
||||
@param labels destination labeled image
|
||||
@param stats statistics output for each label, including the background label, see below for
|
||||
available statistics. Statistics are accessed via stats(label, COLUMN) where COLUMN is one of
|
||||
cv::ConnectedComponentsTypes
|
||||
@param centroids floating point centroid (x,y) output for each label, including the background label
|
||||
cv::ConnectedComponentsTypes. The data type is CV_32S.
|
||||
@param centroids centroid output for each label, including the background label. Centroids are
|
||||
accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.
|
||||
@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively
|
||||
@param ltype output image label type. Currently CV_32S and CV_16U are supported.
|
||||
*/
|
||||
|
||||
@@ -263,6 +263,11 @@ PERF_TEST_P(Size_CvtMode, cvtColor8u,
|
||||
|
||||
#if defined(__APPLE__) && defined(HAVE_IPP)
|
||||
SANITY_CHECK(dst, _mode == CX_BGRA2HLS_FULL ? 2 : 1);
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900 /* MSVC 14 */
|
||||
if (_mode == CX_Luv2BGRA)
|
||||
SANITY_CHECK_NOTHING();
|
||||
else
|
||||
SANITY_CHECK(dst, 1);
|
||||
#else
|
||||
SANITY_CHECK(dst, 1);
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
|
||||
TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold);
|
||||
|
||||
transpose(lines, lines);
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801)
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 810)
|
||||
SANITY_CHECK_NOTHING();
|
||||
#else
|
||||
SANITY_CHECK(lines);
|
||||
|
||||
@@ -835,7 +835,7 @@ static bool ocl_accumulate( InputArray _src, InputArray _src2, InputOutputArray
|
||||
if (haveMask)
|
||||
k.set(argidx, maskarg);
|
||||
|
||||
size_t globalsize[2] = { src.cols * cn / kercn, (src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
size_t globalsize[2] = { (size_t)src.cols * cn / kercn, ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ static bool ocl_blendLinear( InputArray _src1, InputArray _src2, InputArray _wei
|
||||
ocl::KernelArg::ReadOnlyNoSize(weights1), ocl::KernelArg::ReadOnlyNoSize(weights2),
|
||||
ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
size_t globalsize[2] = { dst.cols, dst.rows };
|
||||
size_t globalsize[2] = { (size_t)dst.cols, (size_t)dst.rows };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,26 +44,32 @@
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
|
||||
#define USE_IPP_CANNY 1
|
||||
#else
|
||||
#undef USE_IPP_CANNY
|
||||
#define USE_IPP_CANNY 0
|
||||
#endif
|
||||
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#ifdef USE_IPP_CANNY
|
||||
#ifdef HAVE_IPP
|
||||
static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
|
||||
{
|
||||
#if USE_IPP_CANNY
|
||||
int size = 0, size1 = 0;
|
||||
IppiSize roi = { _src.cols, _src.rows };
|
||||
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size) < 0)
|
||||
return false;
|
||||
if (ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1) < 0)
|
||||
return false;
|
||||
#else
|
||||
if(ippiFilterSobelGetBufferSize(roi, ippMskSize3x3, ippNormL2, ipp8u, ipp16s, 1, &size) < 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
size = std::max(size, size1);
|
||||
|
||||
if (ippiCannyGetSize(roi, &size1) < 0)
|
||||
@@ -90,6 +96,10 @@ static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
|
||||
_dst.ptr(), (int)_dst.step, roi, low, high, buffer) < 0 )
|
||||
return false;
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(low); CV_UNUSED(high);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -154,8 +164,8 @@ static bool ocl_Canny(InputArray _src, OutputArray _dst, float low_thresh, float
|
||||
ocl::KernelArg::WriteOnlyNoSize(map),
|
||||
(float) low, (float) high);
|
||||
|
||||
size_t globalsize[2] = { size.width, size.height },
|
||||
localsize[2] = { lSizeX, lSizeY };
|
||||
size_t globalsize[2] = { (size_t)size.width, (size_t)size.height },
|
||||
localsize[2] = { (size_t)lSizeX, (size_t)lSizeY };
|
||||
|
||||
if (!with_sobel.run(2, globalsize, localsize, false))
|
||||
return false;
|
||||
@@ -183,8 +193,8 @@ static bool ocl_Canny(InputArray _src, OutputArray _dst, float low_thresh, float
|
||||
ocl::KernelArg::WriteOnly(map),
|
||||
low, high);
|
||||
|
||||
size_t globalsize[2] = { size.width, size.height },
|
||||
localsize[2] = { lSizeX, lSizeY };
|
||||
size_t globalsize[2] = { (size_t)size.width, (size_t)size.height },
|
||||
localsize[2] = { (size_t)lSizeX, (size_t)lSizeY };
|
||||
|
||||
if (!without_sobel.run(2, globalsize, localsize, false))
|
||||
return false;
|
||||
@@ -200,7 +210,7 @@ static bool ocl_Canny(InputArray _src, OutputArray _dst, float low_thresh, float
|
||||
if (sizey == 0)
|
||||
sizey = 1;
|
||||
|
||||
size_t globalsize[2] = { size.width, (size.height + PIX_PER_WI - 1) / PIX_PER_WI }, localsize[2] = { lSizeX, sizey };
|
||||
size_t globalsize[2] = { (size_t)size.width, ((size_t)size.height + PIX_PER_WI - 1) / PIX_PER_WI }, localsize[2] = { (size_t)lSizeX, (size_t)sizey };
|
||||
|
||||
ocl::Kernel edgesHysteresis("stage2_hysteresis", ocl::imgproc::canny_oclsrc,
|
||||
format("-D STAGE2 -D PIX_PER_WI=%d -D LOCAL_X=%d -D LOCAL_Y=%d",
|
||||
@@ -610,20 +620,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef USE_IPP_CANNY
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if( aperture_size == 3 && !L2gradient && 1 == cn )
|
||||
{
|
||||
if (ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(USE_IPP_CANNY && (aperture_size == 3 && !L2gradient && 1 == cn), ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace clahe
|
||||
cv::UMat lut = _lut.getUMat();
|
||||
|
||||
size_t localThreads[3] = { 32, 8, 1 };
|
||||
size_t globalThreads[3] = { src.cols, src.rows, 1 };
|
||||
size_t globalThreads[3] = { (size_t)src.cols, (size_t)src.rows, 1 };
|
||||
|
||||
int idx = 0;
|
||||
idx = k.set(idx, cv::ocl::KernelArg::ReadOnlyNoSize(src));
|
||||
|
||||
@@ -96,11 +96,10 @@
|
||||
|
||||
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
|
||||
#define MAX_IPP8u 255
|
||||
#define MAX_IPP16u 65535
|
||||
#define MAX_IPP32f 1.0
|
||||
static IppStatus sts = ippInit();
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
@@ -200,7 +199,7 @@ void CvtColorLoop(const Mat& src, Mat& dst, const Cvt& cvt)
|
||||
parallel_for_(Range(0, src.rows), CvtColorLoop_Invoker<Cvt>(src, dst, cvt), src.total()/(double)(1<<16) );
|
||||
}
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiReorderFunc)(const void *, int, void *, int, IppiSize, const int *);
|
||||
typedef IppStatus (CV_STDCALL* ippiGeneralFunc)(const void *, int, void *, int, IppiSize);
|
||||
@@ -305,7 +304,7 @@ static ippiReorderFunc ippiSwapChannelsC3RTab[] =
|
||||
0, (ippiReorderFunc)ippiSwapChannels_32f_C3R, 0, 0
|
||||
};
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
static ippiReorderFunc ippiSwapChannelsC4RTab[] =
|
||||
{
|
||||
(ippiReorderFunc)ippiSwapChannels_8u_C4R, 0, (ippiReorderFunc)ippiSwapChannels_16u_C4R, 0,
|
||||
@@ -379,7 +378,7 @@ static ippiGeneralFunc ippiHLS2RGBTab[] =
|
||||
0, (ippiGeneralFunc)ippiHLSToRGB_32f_C3R, 0, 0
|
||||
};
|
||||
|
||||
#if !defined(HAVE_IPP_ICV_ONLY) && 0
|
||||
#if !defined(HAVE_IPP_ICV_ONLY) && IPP_DISABLE_BLOCK
|
||||
static ippiGeneralFunc ippiRGBToLUVTab[] =
|
||||
{
|
||||
(ippiGeneralFunc)ippiRGBToLUV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToLUV_16u_C3R, 0,
|
||||
@@ -6693,7 +6692,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
|
||||
int pxPerWIy = dev.isIntel() && (dev.type() & ocl::Device::TYPE_GPU) ? 4 : 1;
|
||||
int pxPerWIx = 1;
|
||||
|
||||
size_t globalsize[] = { src.cols, (src.rows + pxPerWIy - 1) / pxPerWIy };
|
||||
size_t globalsize[] = { (size_t)src.cols, ((size_t)src.rows + pxPerWIy - 1) / pxPerWIy };
|
||||
cv::String opts = format("-D depth=%d -D scn=%d -D PIX_PER_WI_Y=%d ",
|
||||
depth, scn, pxPerWIy);
|
||||
|
||||
@@ -7336,7 +7335,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
|
||||
switch( code )
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_BGR2BGRA: case CV_RGB2BGRA: case CV_BGRA2BGR:
|
||||
case CV_RGBA2BGR: case CV_RGB2BGR: case CV_BGRA2RGBA:
|
||||
CV_Assert( scn == 3 || scn == 4 );
|
||||
@@ -7369,7 +7368,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC3RTab[depth], 2, 1, 0)) )
|
||||
return true;
|
||||
}
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
else if( code == CV_RGBA2BGRA )
|
||||
{
|
||||
if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC4RTab[depth], 2, 1, 0)) )
|
||||
@@ -7379,7 +7378,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if 0 // breaks OCL accuracy tests
|
||||
#if IPP_DISABLE_BLOCK // breaks OCL accuracy tests
|
||||
case CV_BGR2BGR565: case CV_BGR2BGR555: case CV_RGB2BGR565: case CV_RGB2BGR555:
|
||||
case CV_BGRA2BGR565: case CV_BGRA2BGR555: case CV_RGBA2BGR565: case CV_RGBA2BGR555:
|
||||
CV_Assert( (scn == 3 || scn == 4) && depth == CV_8U );
|
||||
@@ -7416,6 +7415,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 < 900
|
||||
case CV_BGR5652BGR: case CV_BGR5552BGR: case CV_BGR5652RGB: case CV_BGR5552RGB:
|
||||
case CV_BGR5652BGRA: case CV_BGR5552BGRA: case CV_BGR5652RGBA: case CV_BGR5552RGBA:
|
||||
if(dcn <= 0) dcn = (code==CV_BGR5652BGRA || code==CV_BGR5552BGRA || code==CV_BGR5652RGBA || code==CV_BGR5552RGBA) ? 4 : 3;
|
||||
@@ -7449,8 +7449,9 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_BGR2GRAY: case CV_BGRA2GRAY: case CV_RGB2GRAY: case CV_RGBA2GRAY:
|
||||
CV_Assert( scn == 3 || scn == 4 );
|
||||
_dst.create(sz, CV_MAKETYPE(depth, 1));
|
||||
@@ -7497,7 +7498,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if IPP_DISABLE_BLOCK
|
||||
case CV_BGR2YCrCb: case CV_RGB2YCrCb:
|
||||
case CV_BGR2YUV: case CV_RGB2YUV:
|
||||
{
|
||||
@@ -7537,7 +7538,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if IPP_DISABLE_BLOCK
|
||||
case CV_YCrCb2BGR: case CV_YCrCb2RGB:
|
||||
case CV_YUV2BGR: case CV_YUV2RGB:
|
||||
{
|
||||
@@ -7578,7 +7579,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_BGR2XYZ: case CV_RGB2XYZ:
|
||||
CV_Assert( scn == 3 || scn == 4 );
|
||||
_dst.create(sz, CV_MAKETYPE(depth, 3));
|
||||
@@ -7607,7 +7608,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_XYZ2BGR: case CV_XYZ2RGB:
|
||||
if( dcn <= 0 ) dcn = 3;
|
||||
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) );
|
||||
@@ -7638,7 +7639,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_BGR2HSV: case CV_RGB2HSV: case CV_BGR2HSV_FULL: case CV_RGB2HSV_FULL:
|
||||
case CV_BGR2HLS: case CV_RGB2HLS: case CV_BGR2HLS_FULL: case CV_RGB2HLS_FULL:
|
||||
{
|
||||
@@ -7648,7 +7649,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
|
||||
if( depth == CV_8U || depth == CV_16U )
|
||||
{
|
||||
#if 0 // breaks OCL accuracy tests
|
||||
#if IPP_DISABLE_BLOCK // breaks OCL accuracy tests
|
||||
if( code == CV_BGR2HSV_FULL && scn == 3 )
|
||||
{
|
||||
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
|
||||
@@ -7695,7 +7696,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
case CV_HSV2BGR: case CV_HSV2RGB: case CV_HSV2BGR_FULL: case CV_HSV2RGB_FULL:
|
||||
case CV_HLS2BGR: case CV_HLS2RGB: case CV_HLS2BGR_FULL: case CV_HLS2RGB_FULL:
|
||||
{
|
||||
@@ -7751,7 +7752,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if IPP_DISABLE_BLOCK
|
||||
case CV_BGR2Lab: case CV_RGB2Lab: case CV_LBGR2Lab: case CV_LRGB2Lab:
|
||||
case CV_BGR2Luv: case CV_RGB2Luv: case CV_LBGR2Luv: case CV_LRGB2Luv:
|
||||
{
|
||||
@@ -7813,7 +7814,7 @@ static bool ipp_cvtColor( Mat &src, OutputArray _dst, int code, int dcn )
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if IPP_DISABLE_BLOCK
|
||||
case CV_Lab2BGR: case CV_Lab2RGB: case CV_Lab2LBGR: case CV_Lab2LRGB:
|
||||
case CV_Luv2BGR: case CV_Luv2RGB: case CV_Luv2LBGR: case CV_Luv2LRGB:
|
||||
{
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace colormap
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float g[] = { 0, 0.01587301587301587f, 0.03174603174603174f, 0.04761904761904762f, 0.06349206349206349f, 0.07936507936507936f, 0.09523809523809523f, 0.1111111111111111f, 0.126984126984127f, 0.1428571428571428f, 0.1587301587301587f, 0.1746031746031746f, 0.1904761904761905f, 0.2063492063492063f, 0.2222222222222222f, 0.2380952380952381f, 0.253968253968254f, 0.2698412698412698f, 0.2857142857142857f, 0.3015873015873016f, 0.3174603174603174f, 0.3333333333333333f, 0.3492063492063492f, 0.3650793650793651f, 0.3809523809523809f, 0.3968253968253968f, 0.4126984126984127f, 0.4285714285714285f, 0.4444444444444444f, 0.4603174603174603f, 0.4761904761904762f, 0.492063492063492f, 0.5079365079365079f, 0.5238095238095238f, 0.5396825396825397f, 0.5555555555555556f, 0.5714285714285714f, 0.5873015873015873f, 0.6031746031746031f, 0.6190476190476191f, 0.6349206349206349f, 0.6507936507936508f, 0.6666666666666666f, 0.6825396825396826f, 0.6984126984126984f, 0.7142857142857143f, 0.7301587301587301f, 0.746031746031746f, 0.7619047619047619f, 0.7777777777777778f, 0.7936507936507936f, 0.8095238095238095f, 0.8253968253968254f, 0.8412698412698413f, 0.8571428571428571f, 0.873015873015873f, 0.8888888888888888f, 0.9047619047619048f, 0.9206349206349206f, 0.9365079365079365f, 0.9523809523809523f, 0.9682539682539683f, 0.9841269841269841f, 1};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
@@ -211,9 +211,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3333333333333333, 0.3472222222222222, 0.3611111111111111, 0.375, 0.3888888888888888, 0.4027777777777777, 0.4166666666666666, 0.4305555555555555, 0.4444444444444444, 0.4583333333333333, 0.4722222222222222, 0.4861111111111112, 0.5, 0.5138888888888888, 0.5277777777777778, 0.5416666666666667, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.611111111111111, 0.6249999999999999, 0.6388888888888888, 0.6527777777777778, 0.6726190476190474, 0.6944444444444442, 0.7162698412698412, 0.7380952380952381, 0.7599206349206349, 0.7817460317460316, 0.8035714285714286, 0.8253968253968254, 0.8472222222222221, 0.8690476190476188, 0.8908730158730158, 0.9126984126984128, 0.9345238095238095, 0.9563492063492063, 0.978174603174603, 1};
|
||||
float g[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3353174603174602, 0.3544973544973544, 0.3736772486772486, 0.3928571428571428, 0.412037037037037, 0.4312169312169312, 0.4503968253968254, 0.4695767195767195, 0.4887566137566137, 0.5079365079365078, 0.5271164021164021, 0.5462962962962963, 0.5654761904761904, 0.5846560846560845, 0.6038359788359787, 0.623015873015873, 0.6421957671957671, 0.6613756613756612, 0.6805555555555555, 0.6997354497354497, 0.7189153439153438, 0.7380952380952379, 0.7572751322751322, 0.7764550264550264, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
|
||||
float b[] = { 0, 0.01917989417989418, 0.03835978835978836, 0.05753968253968253, 0.07671957671957672, 0.09589947089947089, 0.1150793650793651, 0.1342592592592592, 0.1534391534391534, 0.1726190476190476, 0.1917989417989418, 0.210978835978836, 0.2301587301587301, 0.2493386243386243, 0.2685185185185185, 0.2876984126984127, 0.3068783068783069, 0.326058201058201, 0.3452380952380952, 0.3644179894179894, 0.3835978835978835, 0.4027777777777777, 0.4219576719576719, 0.4411375661375661, 0.4583333333333333, 0.4722222222222222, 0.4861111111111111, 0.5, 0.5138888888888888, 0.5277777777777777, 0.5416666666666666, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.6111111111111112, 0.625, 0.6388888888888888, 0.6527777777777778, 0.6666666666666667, 0.6805555555555556, 0.6944444444444444, 0.7083333333333333, 0.7222222222222222, 0.736111111111111, 0.7499999999999999, 0.7638888888888888, 0.7777777777777778, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
|
||||
float r[] = { 0, 0.01388888888888889f, 0.02777777777777778f, 0.04166666666666666f, 0.05555555555555555f, 0.06944444444444445f, 0.08333333333333333f, 0.09722222222222221f, 0.1111111111111111f, 0.125f, 0.1388888888888889f, 0.1527777777777778f, 0.1666666666666667f, 0.1805555555555556f, 0.1944444444444444f, 0.2083333333333333f, 0.2222222222222222f, 0.2361111111111111f, 0.25f, 0.2638888888888889f, 0.2777777777777778f, 0.2916666666666666f, 0.3055555555555555f, 0.3194444444444444f, 0.3333333333333333f, 0.3472222222222222f, 0.3611111111111111f, 0.375f, 0.3888888888888888f, 0.4027777777777777f, 0.4166666666666666f, 0.4305555555555555f, 0.4444444444444444f, 0.4583333333333333f, 0.4722222222222222f, 0.4861111111111112f, 0.5f, 0.5138888888888888f, 0.5277777777777778f, 0.5416666666666667f, 0.5555555555555556f, 0.5694444444444444f, 0.5833333333333333f, 0.5972222222222222f, 0.611111111111111f, 0.6249999999999999f, 0.6388888888888888f, 0.6527777777777778f, 0.6726190476190474f, 0.6944444444444442f, 0.7162698412698412f, 0.7380952380952381f, 0.7599206349206349f, 0.7817460317460316f, 0.8035714285714286f, 0.8253968253968254f, 0.8472222222222221f, 0.8690476190476188f, 0.8908730158730158f, 0.9126984126984128f, 0.9345238095238095f, 0.9563492063492063f, 0.978174603174603f, 1};
|
||||
float g[] = { 0, 0.01388888888888889f, 0.02777777777777778f, 0.04166666666666666f, 0.05555555555555555f, 0.06944444444444445f, 0.08333333333333333f, 0.09722222222222221f, 0.1111111111111111f, 0.125f, 0.1388888888888889f, 0.1527777777777778f, 0.1666666666666667f, 0.1805555555555556f, 0.1944444444444444f, 0.2083333333333333f, 0.2222222222222222f, 0.2361111111111111f, 0.25f, 0.2638888888888889f, 0.2777777777777778f, 0.2916666666666666f, 0.3055555555555555f, 0.3194444444444444f, 0.3353174603174602f, 0.3544973544973544f, 0.3736772486772486f, 0.3928571428571428f, 0.412037037037037f, 0.4312169312169312f, 0.4503968253968254f, 0.4695767195767195f, 0.4887566137566137f, 0.5079365079365078f, 0.5271164021164021f, 0.5462962962962963f, 0.5654761904761904f, 0.5846560846560845f, 0.6038359788359787f, 0.623015873015873f, 0.6421957671957671f, 0.6613756613756612f, 0.6805555555555555f, 0.6997354497354497f, 0.7189153439153438f, 0.7380952380952379f, 0.7572751322751322f, 0.7764550264550264f, 0.7916666666666666f, 0.8055555555555555f, 0.8194444444444444f, 0.8333333333333334f, 0.8472222222222222f, 0.861111111111111f, 0.875f, 0.8888888888888888f, 0.9027777777777777f, 0.9166666666666665f, 0.9305555555555555f, 0.9444444444444444f, 0.9583333333333333f, 0.9722222222222221f, 0.986111111111111f, 1};
|
||||
float b[] = { 0, 0.01917989417989418f, 0.03835978835978836f, 0.05753968253968253f, 0.07671957671957672f, 0.09589947089947089f, 0.1150793650793651f, 0.1342592592592592f, 0.1534391534391534f, 0.1726190476190476f, 0.1917989417989418f, 0.210978835978836f, 0.2301587301587301f, 0.2493386243386243f, 0.2685185185185185f, 0.2876984126984127f, 0.3068783068783069f, 0.326058201058201f, 0.3452380952380952f, 0.3644179894179894f, 0.3835978835978835f, 0.4027777777777777f, 0.4219576719576719f, 0.4411375661375661f, 0.4583333333333333f, 0.4722222222222222f, 0.4861111111111111f, 0.5f, 0.5138888888888888f, 0.5277777777777777f, 0.5416666666666666f, 0.5555555555555556f, 0.5694444444444444f, 0.5833333333333333f, 0.5972222222222222f, 0.6111111111111112f, 0.625f, 0.6388888888888888f, 0.6527777777777778f, 0.6666666666666667f, 0.6805555555555556f, 0.6944444444444444f, 0.7083333333333333f, 0.7222222222222222f, 0.736111111111111f, 0.7499999999999999f, 0.7638888888888888f, 0.7777777777777778f, 0.7916666666666666f, 0.8055555555555555f, 0.8194444444444444f, 0.8333333333333334f, 0.8472222222222222f, 0.861111111111111f, 0.875f, 0.8888888888888888f, 0.9027777777777777f, 0.9166666666666665f, 0.9305555555555555f, 0.9444444444444444f, 0.9583333333333333f, 0.9722222222222221f, 0.986111111111111f, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -241,9 +241,9 @@ namespace colormap
|
||||
// breakpoints
|
||||
Mat X = linspace(0,1,256);
|
||||
// define the basemap
|
||||
float r[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00588235294117645,0.02156862745098032,0.03725490196078418,0.05294117647058827,0.06862745098039214,0.084313725490196,0.1000000000000001,0.115686274509804,0.1313725490196078,0.1470588235294117,0.1627450980392156,0.1784313725490196,0.1941176470588235,0.2098039215686274,0.2254901960784315,0.2411764705882353,0.2568627450980392,0.2725490196078431,0.2882352941176469,0.303921568627451,0.3196078431372549,0.3352941176470587,0.3509803921568628,0.3666666666666667,0.3823529411764706,0.3980392156862744,0.4137254901960783,0.4294117647058824,0.4450980392156862,0.4607843137254901,0.4764705882352942,0.4921568627450981,0.5078431372549019,0.5235294117647058,0.5392156862745097,0.5549019607843135,0.5705882352941174,0.5862745098039217,0.6019607843137256,0.6176470588235294,0.6333333333333333,0.6490196078431372,0.664705882352941,0.6803921568627449,0.6960784313725492,0.7117647058823531,0.7274509803921569,0.7431372549019608,0.7588235294117647,0.7745098039215685,0.7901960784313724,0.8058823529411763,0.8215686274509801,0.8372549019607844,0.8529411764705883,0.8686274509803922,0.884313725490196,0.8999999999999999,0.9156862745098038,0.9313725490196076,0.947058823529412,0.9627450980392158,0.9784313725490197,0.9941176470588236,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9862745098039216,0.9705882352941178,0.9549019607843139,0.93921568627451,0.9235294117647062,0.9078431372549018,0.892156862745098,0.8764705882352941,0.8607843137254902,0.8450980392156864,0.8294117647058825,0.8137254901960786,0.7980392156862743,0.7823529411764705,0.7666666666666666,0.7509803921568627,0.7352941176470589,0.719607843137255,0.7039215686274511,0.6882352941176473,0.6725490196078434,0.6568627450980391,0.6411764705882352,0.6254901960784314,0.6098039215686275,0.5941176470588236,0.5784313725490198,0.5627450980392159,0.5470588235294116,0.5313725490196077,0.5156862745098039,0.5};
|
||||
float g[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.001960784313725483,0.01764705882352935,0.03333333333333333,0.0490196078431373,0.06470588235294117,0.08039215686274503,0.09607843137254901,0.111764705882353,0.1274509803921569,0.1431372549019607,0.1588235294117647,0.1745098039215687,0.1901960784313725,0.2058823529411764,0.2215686274509804,0.2372549019607844,0.2529411764705882,0.2686274509803921,0.2843137254901961,0.3,0.3156862745098039,0.3313725490196078,0.3470588235294118,0.3627450980392157,0.3784313725490196,0.3941176470588235,0.4098039215686274,0.4254901960784314,0.4411764705882353,0.4568627450980391,0.4725490196078431,0.4882352941176471,0.503921568627451,0.5196078431372548,0.5352941176470587,0.5509803921568628,0.5666666666666667,0.5823529411764705,0.5980392156862746,0.6137254901960785,0.6294117647058823,0.6450980392156862,0.6607843137254901,0.6764705882352942,0.692156862745098,0.7078431372549019,0.723529411764706,0.7392156862745098,0.7549019607843137,0.7705882352941176,0.7862745098039214,0.8019607843137255,0.8176470588235294,0.8333333333333333,0.8490196078431373,0.8647058823529412,0.8803921568627451,0.8960784313725489,0.9117647058823528,0.9274509803921569,0.9431372549019608,0.9588235294117646,0.9745098039215687,0.9901960784313726,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9901960784313726,0.9745098039215687,0.9588235294117649,0.943137254901961,0.9274509803921571,0.9117647058823528,0.8960784313725489,0.8803921568627451,0.8647058823529412,0.8490196078431373,0.8333333333333335,0.8176470588235296,0.8019607843137253,0.7862745098039214,0.7705882352941176,0.7549019607843137,0.7392156862745098,0.723529411764706,0.7078431372549021,0.6921568627450982,0.6764705882352944,0.6607843137254901,0.6450980392156862,0.6294117647058823,0.6137254901960785,0.5980392156862746,0.5823529411764707,0.5666666666666669,0.5509803921568626,0.5352941176470587,0.5196078431372548,0.503921568627451,0.4882352941176471,0.4725490196078432,0.4568627450980394,0.4411764705882355,0.4254901960784316,0.4098039215686273,0.3941176470588235,0.3784313725490196,0.3627450980392157,0.3470588235294119,0.331372549019608,0.3156862745098041,0.2999999999999998,0.284313725490196,0.2686274509803921,0.2529411764705882,0.2372549019607844,0.2215686274509805,0.2058823529411766,0.1901960784313728,0.1745098039215689,0.1588235294117646,0.1431372549019607,0.1274509803921569,0.111764705882353,0.09607843137254912,0.08039215686274526,0.06470588235294139,0.04901960784313708,0.03333333333333321,0.01764705882352935,0.001960784313725483,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
float b[] = {0.5,0.5156862745098039,0.5313725490196078,0.5470588235294118,0.5627450980392157,0.5784313725490196,0.5941176470588235,0.6098039215686275,0.6254901960784314,0.6411764705882352,0.6568627450980392,0.6725490196078432,0.6882352941176471,0.7039215686274509,0.7196078431372549,0.7352941176470589,0.7509803921568627,0.7666666666666666,0.7823529411764706,0.7980392156862746,0.8137254901960784,0.8294117647058823,0.8450980392156863,0.8607843137254902,0.8764705882352941,0.892156862745098,0.907843137254902,0.9235294117647059,0.9392156862745098,0.9549019607843137,0.9705882352941176,0.9862745098039216,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9941176470588236,0.9784313725490197,0.9627450980392158,0.9470588235294117,0.9313725490196079,0.915686274509804,0.8999999999999999,0.884313725490196,0.8686274509803922,0.8529411764705883,0.8372549019607844,0.8215686274509804,0.8058823529411765,0.7901960784313726,0.7745098039215685,0.7588235294117647,0.7431372549019608,0.7274509803921569,0.7117647058823531,0.696078431372549,0.6803921568627451,0.6647058823529413,0.6490196078431372,0.6333333333333333,0.6176470588235294,0.6019607843137256,0.5862745098039217,0.5705882352941176,0.5549019607843138,0.5392156862745099,0.5235294117647058,0.5078431372549019,0.4921568627450981,0.4764705882352942,0.4607843137254903,0.4450980392156865,0.4294117647058826,0.4137254901960783,0.3980392156862744,0.3823529411764706,0.3666666666666667,0.3509803921568628,0.335294117647059,0.3196078431372551,0.3039215686274508,0.2882352941176469,0.2725490196078431,0.2568627450980392,0.2411764705882353,0.2254901960784315,0.2098039215686276,0.1941176470588237,0.1784313725490199,0.1627450980392156,0.1470588235294117,0.1313725490196078,0.115686274509804,0.1000000000000001,0.08431372549019622,0.06862745098039236,0.05294117647058805,0.03725490196078418,0.02156862745098032,0.00588235294117645,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
float r[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00588235294117645f,0.02156862745098032f,0.03725490196078418f,0.05294117647058827f,0.06862745098039214f,0.084313725490196f,0.1000000000000001f,0.115686274509804f,0.1313725490196078f,0.1470588235294117f,0.1627450980392156f,0.1784313725490196f,0.1941176470588235f,0.2098039215686274f,0.2254901960784315f,0.2411764705882353f,0.2568627450980392f,0.2725490196078431f,0.2882352941176469f,0.303921568627451f,0.3196078431372549f,0.3352941176470587f,0.3509803921568628f,0.3666666666666667f,0.3823529411764706f,0.3980392156862744f,0.4137254901960783f,0.4294117647058824f,0.4450980392156862f,0.4607843137254901f,0.4764705882352942f,0.4921568627450981f,0.5078431372549019f,0.5235294117647058f,0.5392156862745097f,0.5549019607843135f,0.5705882352941174f,0.5862745098039217f,0.6019607843137256f,0.6176470588235294f,0.6333333333333333f,0.6490196078431372f,0.664705882352941f,0.6803921568627449f,0.6960784313725492f,0.7117647058823531f,0.7274509803921569f,0.7431372549019608f,0.7588235294117647f,0.7745098039215685f,0.7901960784313724f,0.8058823529411763f,0.8215686274509801f,0.8372549019607844f,0.8529411764705883f,0.8686274509803922f,0.884313725490196f,0.8999999999999999f,0.9156862745098038f,0.9313725490196076f,0.947058823529412f,0.9627450980392158f,0.9784313725490197f,0.9941176470588236f,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9862745098039216f,0.9705882352941178f,0.9549019607843139f,0.93921568627451f,0.9235294117647062f,0.9078431372549018f,0.892156862745098f,0.8764705882352941f,0.8607843137254902f,0.8450980392156864f,0.8294117647058825f,0.8137254901960786f,0.7980392156862743f,0.7823529411764705f,0.7666666666666666f,0.7509803921568627f,0.7352941176470589f,0.719607843137255f,0.7039215686274511f,0.6882352941176473f,0.6725490196078434f,0.6568627450980391f,0.6411764705882352f,0.6254901960784314f,0.6098039215686275f,0.5941176470588236f,0.5784313725490198f,0.5627450980392159f,0.5470588235294116f,0.5313725490196077f,0.5156862745098039f,0.5f};
|
||||
float g[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.001960784313725483f,0.01764705882352935f,0.03333333333333333f,0.0490196078431373f,0.06470588235294117f,0.08039215686274503f,0.09607843137254901f,0.111764705882353f,0.1274509803921569f,0.1431372549019607f,0.1588235294117647f,0.1745098039215687f,0.1901960784313725f,0.2058823529411764f,0.2215686274509804f,0.2372549019607844f,0.2529411764705882f,0.2686274509803921f,0.2843137254901961f,0.3f,0.3156862745098039f,0.3313725490196078f,0.3470588235294118f,0.3627450980392157f,0.3784313725490196f,0.3941176470588235f,0.4098039215686274f,0.4254901960784314f,0.4411764705882353f,0.4568627450980391f,0.4725490196078431f,0.4882352941176471f,0.503921568627451f,0.5196078431372548f,0.5352941176470587f,0.5509803921568628f,0.5666666666666667f,0.5823529411764705f,0.5980392156862746f,0.6137254901960785f,0.6294117647058823f,0.6450980392156862f,0.6607843137254901f,0.6764705882352942f,0.692156862745098f,0.7078431372549019f,0.723529411764706f,0.7392156862745098f,0.7549019607843137f,0.7705882352941176f,0.7862745098039214f,0.8019607843137255f,0.8176470588235294f,0.8333333333333333f,0.8490196078431373f,0.8647058823529412f,0.8803921568627451f,0.8960784313725489f,0.9117647058823528f,0.9274509803921569f,0.9431372549019608f,0.9588235294117646f,0.9745098039215687f,0.9901960784313726f,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9901960784313726f,0.9745098039215687f,0.9588235294117649f,0.943137254901961f,0.9274509803921571f,0.9117647058823528f,0.8960784313725489f,0.8803921568627451f,0.8647058823529412f,0.8490196078431373f,0.8333333333333335f,0.8176470588235296f,0.8019607843137253f,0.7862745098039214f,0.7705882352941176f,0.7549019607843137f,0.7392156862745098f,0.723529411764706f,0.7078431372549021f,0.6921568627450982f,0.6764705882352944f,0.6607843137254901f,0.6450980392156862f,0.6294117647058823f,0.6137254901960785f,0.5980392156862746f,0.5823529411764707f,0.5666666666666669f,0.5509803921568626f,0.5352941176470587f,0.5196078431372548f,0.503921568627451f,0.4882352941176471f,0.4725490196078432f,0.4568627450980394f,0.4411764705882355f,0.4254901960784316f,0.4098039215686273f,0.3941176470588235f,0.3784313725490196f,0.3627450980392157f,0.3470588235294119f,0.331372549019608f,0.3156862745098041f,0.2999999999999998f,0.284313725490196f,0.2686274509803921f,0.2529411764705882f,0.2372549019607844f,0.2215686274509805f,0.2058823529411766f,0.1901960784313728f,0.1745098039215689f,0.1588235294117646f,0.1431372549019607f,0.1274509803921569f,0.111764705882353f,0.09607843137254912f,0.08039215686274526f,0.06470588235294139f,0.04901960784313708f,0.03333333333333321f,0.01764705882352935f,0.001960784313725483f,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
float b[] = {0.5f,0.5156862745098039f,0.5313725490196078f,0.5470588235294118f,0.5627450980392157f,0.5784313725490196f,0.5941176470588235f,0.6098039215686275f,0.6254901960784314f,0.6411764705882352f,0.6568627450980392f,0.6725490196078432f,0.6882352941176471f,0.7039215686274509f,0.7196078431372549f,0.7352941176470589f,0.7509803921568627f,0.7666666666666666f,0.7823529411764706f,0.7980392156862746f,0.8137254901960784f,0.8294117647058823f,0.8450980392156863f,0.8607843137254902f,0.8764705882352941f,0.892156862745098f,0.907843137254902f,0.9235294117647059f,0.9392156862745098f,0.9549019607843137f,0.9705882352941176f,0.9862745098039216f,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9941176470588236f,0.9784313725490197f,0.9627450980392158f,0.9470588235294117f,0.9313725490196079f,0.915686274509804f,0.8999999999999999f,0.884313725490196f,0.8686274509803922f,0.8529411764705883f,0.8372549019607844f,0.8215686274509804f,0.8058823529411765f,0.7901960784313726f,0.7745098039215685f,0.7588235294117647f,0.7431372549019608f,0.7274509803921569f,0.7117647058823531f,0.696078431372549f,0.6803921568627451f,0.6647058823529413f,0.6490196078431372f,0.6333333333333333f,0.6176470588235294f,0.6019607843137256f,0.5862745098039217f,0.5705882352941176f,0.5549019607843138f,0.5392156862745099f,0.5235294117647058f,0.5078431372549019f,0.4921568627450981f,0.4764705882352942f,0.4607843137254903f,0.4450980392156865f,0.4294117647058826f,0.4137254901960783f,0.3980392156862744f,0.3823529411764706f,0.3666666666666667f,0.3509803921568628f,0.335294117647059f,0.3196078431372551f,0.3039215686274508f,0.2882352941176469f,0.2725490196078431f,0.2568627450980392f,0.2411764705882353f,0.2254901960784315f,0.2098039215686276f,0.1941176470588237f,0.1784313725490199f,0.1627450980392156f,0.1470588235294117f,0.1313725490196078f,0.115686274509804f,0.1000000000000001f,0.08431372549019622f,0.06862745098039236f,0.05294117647058805f,0.03725490196078418f,0.02156862745098032f,0.00588235294117645f,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
// now build lookup table
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(256,1, CV_32FC1, r).clone(), // red
|
||||
@@ -265,9 +265,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
float g[] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
|
||||
float b[] = {1.0, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5};
|
||||
float r[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float g[] = {0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f,};
|
||||
float b[] = {1.0, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f, 0.5f};
|
||||
Mat X = linspace(0,1,11);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(11,1, CV_32FC1, r).clone(), // red
|
||||
@@ -289,9 +289,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367, 0.8571428571428572, 0.7777777777777777, 0.6984126984126986, 0.6190476190476191, 0.53968253968254, 0.4603174603174605, 0.3809523809523814, 0.3015873015873018, 0.2222222222222223, 0.1428571428571432, 0.06349206349206415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208, 0.08465608465608465, 0.1375661375661377, 0.1904761904761907, 0.2433862433862437, 0.2962962962962963, 0.3492063492063493, 0.4021164021164023, 0.4550264550264553, 0.5079365079365079, 0.5608465608465609, 0.6137566137566139, 0.666666666666667};
|
||||
float g[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842, 0.9047619047619047, 0.8253968253968256, 0.7460317460317465, 0.666666666666667, 0.587301587301587, 0.5079365079365079, 0.4285714285714288, 0.3492063492063493, 0.2698412698412698, 0.1904761904761907, 0.1111111111111116, 0.03174603174603208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582, 0.09523809523809534, 0.1746031746031744, 0.2539682539682535, 0.333333333333333, 0.412698412698413, 0.4920634920634921, 0.5714285714285712, 0.6507936507936507, 0.7301587301587302, 0.8095238095238093, 0.8888888888888884, 0.9682539682539679, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367f, 0.8571428571428572f, 0.7777777777777777f, 0.6984126984126986f, 0.6190476190476191f, 0.53968253968254f, 0.4603174603174605f, 0.3809523809523814f, 0.3015873015873018f, 0.2222222222222223f, 0.1428571428571432f, 0.06349206349206415f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208f, 0.08465608465608465f, 0.1375661375661377f, 0.1904761904761907f, 0.2433862433862437f, 0.2962962962962963f, 0.3492063492063493f, 0.4021164021164023f, 0.4550264550264553f, 0.5079365079365079f, 0.5608465608465609f, 0.6137566137566139f, 0.666666666666667f};
|
||||
float g[] = { 0, 0.03968253968253968f, 0.07936507936507936f, 0.119047619047619f, 0.1587301587301587f, 0.1984126984126984f, 0.2380952380952381f, 0.2777777777777778f, 0.3174603174603174f, 0.3571428571428571f, 0.3968253968253968f, 0.4365079365079365f, 0.4761904761904762f, 0.5158730158730158f, 0.5555555555555556f, 0.5952380952380952f, 0.6349206349206349f, 0.6746031746031745f, 0.7142857142857142f, 0.753968253968254f, 0.7936507936507936f, 0.8333333333333333f, 0.873015873015873f, 0.9126984126984127f, 0.9523809523809523f, 0.992063492063492f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842f, 0.9047619047619047f, 0.8253968253968256f, 0.7460317460317465f, 0.666666666666667f, 0.587301587301587f, 0.5079365079365079f, 0.4285714285714288f, 0.3492063492063493f, 0.2698412698412698f, 0.1904761904761907f, 0.1111111111111116f, 0.03174603174603208f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582f, 0.09523809523809534f, 0.1746031746031744f, 0.2539682539682535f, 0.333333333333333f, 0.412698412698413f, 0.4920634920634921f, 0.5714285714285712f, 0.6507936507936507f, 0.7301587301587302f, 0.8095238095238093f, 0.8888888888888884f, 0.9682539682539679f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -313,9 +313,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904762, 0.09523809523809523, 0.1428571428571428, 0.1904761904761905, 0.2380952380952381, 0.2857142857142857, 0.3333333333333333, 0.3809523809523809, 0.4285714285714285, 0.4761904761904762, 0.5238095238095238, 0.5714285714285714, 0.6190476190476191, 0.6666666666666666, 0.7142857142857143, 0.7619047619047619, 0.8095238095238095, 0.8571428571428571, 0.9047619047619048, 0.9523809523809523, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02380952380952381, 0.04761904761904762, 0.07142857142857142, 0.09523809523809523, 0.119047619047619, 0.1428571428571428, 0.1666666666666667, 0.1904761904761905, 0.2142857142857143, 0.2380952380952381, 0.2619047619047619, 0.2857142857142857, 0.3095238095238095, 0.3333333333333333, 0.3571428571428572, 0.3809523809523809, 0.4047619047619048, 0.4285714285714285, 0.4523809523809524, 0.4761904761904762, 0.5, 0.5238095238095238, 0.5476190476190477, 0.5714285714285714, 0.5952380952380952, 0.6190476190476191, 0.6428571428571429, 0.6666666666666666, 0.6904761904761905, 0.7142857142857143, 0.7380952380952381, 0.7619047619047619, 0.7857142857142857, 0.8095238095238095, 0.8333333333333334, 0.8571428571428571, 0.8809523809523809, 0.9047619047619048, 0.9285714285714286, 0.9523809523809523, 0.9761904761904762, 1};
|
||||
float b[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float r[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904762f, 0.09523809523809523f, 0.1428571428571428f, 0.1904761904761905f, 0.2380952380952381f, 0.2857142857142857f, 0.3333333333333333f, 0.3809523809523809f, 0.4285714285714285f, 0.4761904761904762f, 0.5238095238095238f, 0.5714285714285714f, 0.6190476190476191f, 0.6666666666666666f, 0.7142857142857143f, 0.7619047619047619f, 0.8095238095238095f, 0.8571428571428571f, 0.9047619047619048f, 0.9523809523809523f, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02380952380952381f, 0.04761904761904762f, 0.07142857142857142f, 0.09523809523809523f, 0.119047619047619f, 0.1428571428571428f, 0.1666666666666667f, 0.1904761904761905f, 0.2142857142857143f, 0.2380952380952381f, 0.2619047619047619f, 0.2857142857142857f, 0.3095238095238095f, 0.3333333333333333f, 0.3571428571428572f, 0.3809523809523809f, 0.4047619047619048f, 0.4285714285714285f, 0.4523809523809524f, 0.4761904761904762f, 0.5f, 0.5238095238095238f, 0.5476190476190477f, 0.5714285714285714f, 0.5952380952380952f, 0.6190476190476191f, 0.6428571428571429f, 0.6666666666666666f, 0.6904761904761905f, 0.7142857142857143f, 0.7380952380952381f, 0.7619047619047619f, 0.7857142857142857f, 0.8095238095238095f, 0.8333333333333334f, 0.8571428571428571f, 0.8809523809523809f, 0.9047619047619048f, 0.9285714285714286f, 0.9523809523809523f, 0.9761904761904762f, 1};
|
||||
float b[] = { 0, 0.01587301587301587f, 0.03174603174603174f, 0.04761904761904762f, 0.06349206349206349f, 0.07936507936507936f, 0.09523809523809523f, 0.1111111111111111f, 0.126984126984127f, 0.1428571428571428f, 0.1587301587301587f, 0.1746031746031746f, 0.1904761904761905f, 0.2063492063492063f, 0.2222222222222222f, 0.2380952380952381f, 0.253968253968254f, 0.2698412698412698f, 0.2857142857142857f, 0.3015873015873016f, 0.3174603174603174f, 0.3333333333333333f, 0.3492063492063492f, 0.3650793650793651f, 0.3809523809523809f, 0.3968253968253968f, 0.4126984126984127f, 0.4285714285714285f, 0.4444444444444444f, 0.4603174603174603f, 0.4761904761904762f, 0.492063492063492f, 0.5079365079365079f, 0.5238095238095238f, 0.5396825396825397f, 0.5555555555555556f, 0.5714285714285714f, 0.5873015873015873f, 0.6031746031746031f, 0.6190476190476191f, 0.6349206349206349f, 0.6507936507936508f, 0.6666666666666666f, 0.6825396825396826f, 0.6984126984126984f, 0.7142857142857143f, 0.7301587301587301f, 0.746031746031746f, 0.7619047619047619f, 0.7777777777777778f, 0.7936507936507936f, 0.8095238095238095f, 0.8253968253968254f, 0.8412698412698413f, 0.8571428571428571f, 0.873015873015873f, 0.8888888888888888f, 0.9047619047619048f, 0.9206349206349206f, 0.9365079365079365f, 0.9523809523809523f, 0.9682539682539683f, 0.9841269841269841f, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -337,9 +337,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float g[] = { 0.5, 0.5079365079365079, 0.5158730158730158, 0.5238095238095238, 0.5317460317460317, 0.5396825396825397, 0.5476190476190477, 0.5555555555555556, 0.5634920634920635, 0.5714285714285714, 0.5793650793650793, 0.5873015873015873, 0.5952380952380952, 0.6031746031746031, 0.6111111111111112, 0.6190476190476191, 0.626984126984127, 0.6349206349206349, 0.6428571428571428, 0.6507936507936508, 0.6587301587301587, 0.6666666666666666, 0.6746031746031746, 0.6825396825396826, 0.6904761904761905, 0.6984126984126984, 0.7063492063492063, 0.7142857142857143, 0.7222222222222222, 0.7301587301587301, 0.7380952380952381, 0.746031746031746, 0.753968253968254, 0.7619047619047619, 0.7698412698412698, 0.7777777777777778, 0.7857142857142857, 0.7936507936507937, 0.8015873015873016, 0.8095238095238095, 0.8174603174603174, 0.8253968253968254, 0.8333333333333333, 0.8412698412698413, 0.8492063492063492, 0.8571428571428572, 0.8650793650793651, 0.873015873015873, 0.8809523809523809, 0.8888888888888888, 0.8968253968253967, 0.9047619047619048, 0.9126984126984127, 0.9206349206349207, 0.9285714285714286, 0.9365079365079365, 0.9444444444444444, 0.9523809523809523, 0.9603174603174602, 0.9682539682539683, 0.9761904761904762, 0.9841269841269842, 0.9920634920634921, 1};
|
||||
float b[] = { 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4};
|
||||
float r[] = { 0, 0.01587301587301587f, 0.03174603174603174f, 0.04761904761904762f, 0.06349206349206349f, 0.07936507936507936f, 0.09523809523809523f, 0.1111111111111111f, 0.126984126984127f, 0.1428571428571428f, 0.1587301587301587f, 0.1746031746031746f, 0.1904761904761905f, 0.2063492063492063f, 0.2222222222222222f, 0.2380952380952381f, 0.253968253968254f, 0.2698412698412698f, 0.2857142857142857f, 0.3015873015873016f, 0.3174603174603174f, 0.3333333333333333f, 0.3492063492063492f, 0.3650793650793651f, 0.3809523809523809f, 0.3968253968253968f, 0.4126984126984127f, 0.4285714285714285f, 0.4444444444444444f, 0.4603174603174603f, 0.4761904761904762f, 0.492063492063492f, 0.5079365079365079f, 0.5238095238095238f, 0.5396825396825397f, 0.5555555555555556f, 0.5714285714285714f, 0.5873015873015873f, 0.6031746031746031f, 0.6190476190476191f, 0.6349206349206349f, 0.6507936507936508f, 0.6666666666666666f, 0.6825396825396826f, 0.6984126984126984f, 0.7142857142857143f, 0.7301587301587301f, 0.746031746031746f, 0.7619047619047619f, 0.7777777777777778f, 0.7936507936507936f, 0.8095238095238095f, 0.8253968253968254f, 0.8412698412698413f, 0.8571428571428571f, 0.873015873015873f, 0.8888888888888888f, 0.9047619047619048f, 0.9206349206349206f, 0.9365079365079365f, 0.9523809523809523f, 0.9682539682539683f, 0.9841269841269841f, 1};
|
||||
float g[] = { 0.5f, 0.5079365079365079f, 0.5158730158730158f, 0.5238095238095238f, 0.5317460317460317f, 0.5396825396825397f, 0.5476190476190477f, 0.5555555555555556f, 0.5634920634920635f, 0.5714285714285714f, 0.5793650793650793f, 0.5873015873015873f, 0.5952380952380952f, 0.6031746031746031f, 0.6111111111111112f, 0.6190476190476191f, 0.626984126984127f, 0.6349206349206349f, 0.6428571428571428f, 0.6507936507936508f, 0.6587301587301587f, 0.6666666666666666f, 0.6746031746031746f, 0.6825396825396826f, 0.6904761904761905f, 0.6984126984126984f, 0.7063492063492063f, 0.7142857142857143f, 0.7222222222222222f, 0.7301587301587301f, 0.7380952380952381f, 0.746031746031746f, 0.753968253968254f, 0.7619047619047619f, 0.7698412698412698f, 0.7777777777777778f, 0.7857142857142857f, 0.7936507936507937f, 0.8015873015873016f, 0.8095238095238095f, 0.8174603174603174f, 0.8253968253968254f, 0.8333333333333333f, 0.8412698412698413f, 0.8492063492063492f, 0.8571428571428572f, 0.8650793650793651f, 0.873015873015873f, 0.8809523809523809f, 0.8888888888888888f, 0.8968253968253967f, 0.9047619047619048f, 0.9126984126984127f, 0.9206349206349207f, 0.9285714285714286f, 0.9365079365079365f, 0.9444444444444444f, 0.9523809523809523f, 0.9603174603174602f, 0.9682539682539683f, 0.9761904761904762f, 0.9841269841269842f, 0.9920634920634921f, 1};
|
||||
float b[] = { 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -362,8 +362,8 @@ namespace colormap
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float b[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
|
||||
float g[] = { 0, 0.01587301587301587f, 0.03174603174603174f, 0.04761904761904762f, 0.06349206349206349f, 0.07936507936507936f, 0.09523809523809523f, 0.1111111111111111f, 0.126984126984127f, 0.1428571428571428f, 0.1587301587301587f, 0.1746031746031746f, 0.1904761904761905f, 0.2063492063492063f, 0.2222222222222222f, 0.2380952380952381f, 0.253968253968254f, 0.2698412698412698f, 0.2857142857142857f, 0.3015873015873016f, 0.3174603174603174f, 0.3333333333333333f, 0.3492063492063492f, 0.3650793650793651f, 0.3809523809523809f, 0.3968253968253968f, 0.4126984126984127f, 0.4285714285714285f, 0.4444444444444444f, 0.4603174603174603f, 0.4761904761904762f, 0.492063492063492f, 0.5079365079365079f, 0.5238095238095238f, 0.5396825396825397f, 0.5555555555555556f, 0.5714285714285714f, 0.5873015873015873f, 0.6031746031746031f, 0.6190476190476191f, 0.6349206349206349f, 0.6507936507936508f, 0.6666666666666666f, 0.6825396825396826f, 0.6984126984126984f, 0.7142857142857143f, 0.7301587301587301f, 0.746031746031746f, 0.7619047619047619f, 0.7777777777777778f, 0.7936507936507936f, 0.8095238095238095f, 0.8253968253968254f, 0.8412698412698413f, 0.8571428571428571f, 0.873015873015873f, 0.8888888888888888f, 0.9047619047619048f, 0.9206349206349206f, 0.9365079365079365f, 0.9523809523809523f, 0.9682539682539683f, 0.9841269841269841f, 1};
|
||||
float b[] = { 1, 0.9841269841269842f, 0.9682539682539683f, 0.9523809523809523f, 0.9365079365079365f, 0.9206349206349207f, 0.9047619047619048f, 0.8888888888888888f, 0.873015873015873f, 0.8571428571428572f, 0.8412698412698413f, 0.8253968253968254f, 0.8095238095238095f, 0.7936507936507937f, 0.7777777777777778f, 0.7619047619047619f, 0.746031746031746f, 0.7301587301587302f, 0.7142857142857143f, 0.6984126984126984f, 0.6825396825396826f, 0.6666666666666667f, 0.6507936507936508f, 0.6349206349206349f, 0.6190476190476191f, 0.6031746031746033f, 0.5873015873015873f, 0.5714285714285714f, 0.5555555555555556f, 0.5396825396825398f, 0.5238095238095238f, 0.5079365079365079f, 0.4920634920634921f, 0.4761904761904762f, 0.4603174603174603f, 0.4444444444444444f, 0.4285714285714286f, 0.4126984126984127f, 0.3968253968253969f, 0.3809523809523809f, 0.3650793650793651f, 0.3492063492063492f, 0.3333333333333334f, 0.3174603174603174f, 0.3015873015873016f, 0.2857142857142857f, 0.2698412698412699f, 0.253968253968254f, 0.2380952380952381f, 0.2222222222222222f, 0.2063492063492064f, 0.1904761904761905f, 0.1746031746031746f, 0.1587301587301587f, 0.1428571428571429f, 0.126984126984127f, 0.1111111111111112f, 0.09523809523809523f, 0.07936507936507942f, 0.06349206349206349f, 0.04761904761904767f, 0.03174603174603174f, 0.01587301587301593f, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -385,8 +385,8 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float g[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
|
||||
float r[] = { 0, 0.01587301587301587f, 0.03174603174603174f, 0.04761904761904762f, 0.06349206349206349f, 0.07936507936507936f, 0.09523809523809523f, 0.1111111111111111f, 0.126984126984127f, 0.1428571428571428f, 0.1587301587301587f, 0.1746031746031746f, 0.1904761904761905f, 0.2063492063492063f, 0.2222222222222222f, 0.2380952380952381f, 0.253968253968254f, 0.2698412698412698f, 0.2857142857142857f, 0.3015873015873016f, 0.3174603174603174f, 0.3333333333333333f, 0.3492063492063492f, 0.3650793650793651f, 0.3809523809523809f, 0.3968253968253968f, 0.4126984126984127f, 0.4285714285714285f, 0.4444444444444444f, 0.4603174603174603f, 0.4761904761904762f, 0.492063492063492f, 0.5079365079365079f, 0.5238095238095238f, 0.5396825396825397f, 0.5555555555555556f, 0.5714285714285714f, 0.5873015873015873f, 0.6031746031746031f, 0.6190476190476191f, 0.6349206349206349f, 0.6507936507936508f, 0.6666666666666666f, 0.6825396825396826f, 0.6984126984126984f, 0.7142857142857143f, 0.7301587301587301f, 0.746031746031746f, 0.7619047619047619f, 0.7777777777777778f, 0.7936507936507936f, 0.8095238095238095f, 0.8253968253968254f, 0.8412698412698413f, 0.8571428571428571f, 0.873015873015873f, 0.8888888888888888f, 0.9047619047619048f, 0.9206349206349206f, 0.9365079365079365f, 0.9523809523809523f, 0.9682539682539683f, 0.9841269841269841f, 1};
|
||||
float g[] = { 1, 0.9841269841269842f, 0.9682539682539683f, 0.9523809523809523f, 0.9365079365079365f, 0.9206349206349207f, 0.9047619047619048f, 0.8888888888888888f, 0.873015873015873f, 0.8571428571428572f, 0.8412698412698413f, 0.8253968253968254f, 0.8095238095238095f, 0.7936507936507937f, 0.7777777777777778f, 0.7619047619047619f, 0.746031746031746f, 0.7301587301587302f, 0.7142857142857143f, 0.6984126984126984f, 0.6825396825396826f, 0.6666666666666667f, 0.6507936507936508f, 0.6349206349206349f, 0.6190476190476191f, 0.6031746031746033f, 0.5873015873015873f, 0.5714285714285714f, 0.5555555555555556f, 0.5396825396825398f, 0.5238095238095238f, 0.5079365079365079f, 0.4920634920634921f, 0.4761904761904762f, 0.4603174603174603f, 0.4444444444444444f, 0.4285714285714286f, 0.4126984126984127f, 0.3968253968253969f, 0.3809523809523809f, 0.3650793650793651f, 0.3492063492063492f, 0.3333333333333334f, 0.3174603174603174f, 0.3015873015873016f, 0.2857142857142857f, 0.2698412698412699f, 0.253968253968254f, 0.2380952380952381f, 0.2222222222222222f, 0.2063492063492064f, 0.1904761904761905f, 0.1746031746031746f, 0.1587301587301587f, 0.1428571428571429f, 0.126984126984127f, 0.1111111111111112f, 0.09523809523809523f, 0.07936507936507942f, 0.06349206349206349f, 0.04761904761904767f, 0.03174603174603174f, 0.01587301587301593f, 0};
|
||||
float b[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
@@ -409,9 +409,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428568, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904763, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.0952380952380949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809557, 0.1904761904761905, 0.2857142857142854, 0.3809523809523809, 0.4761904761904765, 0.5714285714285714, 0.6666666666666663, 0.7619047619047619, 0.8571428571428574, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047619, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523814, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0};
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526f, 0.8571428571428568f, 0.7619047619047614f, 0.6666666666666665f, 0.5714285714285716f, 0.4761904761904763f, 0.3809523809523805f, 0.2857142857142856f, 0.1904761904761907f, 0.0952380952380949f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809557f, 0.1904761904761905f, 0.2857142857142854f, 0.3809523809523809f, 0.4761904761904765f, 0.5714285714285714f, 0.6666666666666663f, 0.7619047619047619f, 0.8571428571428574f, 0.9523809523809523f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.09523809523809523f, 0.1904761904761905f, 0.2857142857142857f, 0.3809523809523809f, 0.4761904761904762f, 0.5714285714285714f, 0.6666666666666666f, 0.7619047619047619f, 0.8571428571428571f, 0.9523809523809523f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526f, 0.8571428571428577f, 0.7619047619047619f, 0.6666666666666665f, 0.5714285714285716f, 0.4761904761904767f, 0.3809523809523814f, 0.2857142857142856f, 0.1904761904761907f, 0.09523809523809579f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809523f, 0.1904761904761905f, 0.2857142857142857f, 0.3809523809523809f, 0.4761904761904762f, 0.5714285714285714f, 0.6666666666666666f, 0.7619047619047619f, 0.8571428571428571f, 0.9523809523809523f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526f, 0.8571428571428577f, 0.7619047619047614f, 0.6666666666666665f, 0.5714285714285716f, 0.4761904761904767f, 0.3809523809523805f, 0.2857142857142856f, 0.1904761904761907f, 0.09523809523809579f, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -433,9 +433,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.1571348402636772, 0.2222222222222222, 0.2721655269759087, 0.3142696805273544, 0.3513641844631533, 0.3849001794597505, 0.415739709641549, 0.4444444444444444, 0.4714045207910317, 0.4969039949999532, 0.5211573066470477, 0.5443310539518174, 0.5665577237325317, 0.5879447357921312, 0.6085806194501846, 0.6285393610547089, 0.6478835438717, 0.6666666666666666, 0.6849348892187751, 0.7027283689263065, 0.7200822998230956, 0.7370277311900888, 0.753592220347252, 0.7663560447348133, 0.7732293307186413, 0.7800420555749596, 0.7867957924694432, 0.7934920476158722, 0.8001322641986387, 0.8067178260046388, 0.8132500607904444, 0.8197302434079591, 0.8261595987094034, 0.8325393042503717, 0.8388704928078611, 0.8451542547285166, 0.8513916401208816, 0.8575836609041332, 0.8637312927246217, 0.8698354767504924, 0.8758971213537393, 0.8819171036881968, 0.8878962711712378, 0.8938354428762595, 0.8997354108424372, 0.9055969413076769, 0.9114207758701963, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
|
||||
float g[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5091750772173156, 0.5328701692569688, 0.5555555555555556, 0.5773502691896257, 0.5983516452371671, 0.6186404847588913, 0.6382847385042254, 0.6573421981221795, 0.6758625033664688, 0.6938886664887108, 0.7114582486036499, 0.7286042804780002, 0.7453559924999299, 0.7617394000445604, 0.7777777777777778, 0.7934920476158723, 0.8089010988089465, 0.8240220541217402, 0.8388704928078611, 0.8534606386520677, 0.8678055195451838, 0.8819171036881968, 0.8958064164776166, 0.9094836413191612, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
|
||||
float b[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5039526306789697, 0.5143444998736397, 0.5245305283129621, 0.5345224838248488, 0.5443310539518174, 0.5539659798925444, 0.563436169819011, 0.5727497953228163, 0.5819143739626463, 0.5909368402852788, 0.5998236072282915, 0.6085806194501846, 0.6172133998483676, 0.6257270902992705, 0.6341264874742278, 0.642416074439621, 0.6506000486323554, 0.6586823467062358, 0.6666666666666666, 0.6745564876468501, 0.6823550876255453, 0.6900655593423541, 0.6976908246297114, 0.7052336473499384, 0.7237468644557459, 0.7453559924999298, 0.7663560447348133, 0.7867957924694432, 0.8067178260046388, 0.8261595987094034, 0.8451542547285166, 0.8637312927246217, 0.8819171036881968, 0.8997354108424372, 0.9172076325837248, 0.9343531843023135, 0.9511897312113418, 0.9677334015667416, 0.9839989676081821, 1};
|
||||
float r[] = { 0, 0.1571348402636772f, 0.2222222222222222f, 0.2721655269759087f, 0.3142696805273544f, 0.3513641844631533f, 0.3849001794597505f, 0.415739709641549f, 0.4444444444444444f, 0.4714045207910317f, 0.4969039949999532f, 0.5211573066470477f, 0.5443310539518174f, 0.5665577237325317f, 0.5879447357921312f, 0.6085806194501846f, 0.6285393610547089f, 0.6478835438717f, 0.6666666666666666f, 0.6849348892187751f, 0.7027283689263065f, 0.7200822998230956f, 0.7370277311900888f, 0.753592220347252f, 0.7663560447348133f, 0.7732293307186413f, 0.7800420555749596f, 0.7867957924694432f, 0.7934920476158722f, 0.8001322641986387f, 0.8067178260046388f, 0.8132500607904444f, 0.8197302434079591f, 0.8261595987094034f, 0.8325393042503717f, 0.8388704928078611f, 0.8451542547285166f, 0.8513916401208816f, 0.8575836609041332f, 0.8637312927246217f, 0.8698354767504924f, 0.8758971213537393f, 0.8819171036881968f, 0.8878962711712378f, 0.8938354428762595f, 0.8997354108424372f, 0.9055969413076769f, 0.9114207758701963f, 0.9172076325837248f, 0.9229582069908971f, 0.9286731730990523f, 0.9343531843023135f, 0.9399988742535192f, 0.9456108576893002f, 0.9511897312113418f, 0.9567360740266436f, 0.9622504486493763f, 0.9677334015667416f, 0.9731854638710686f, 0.9786071518602129f, 0.9839989676081821f, 0.9893613995077727f, 0.9946949227868761f, 1};
|
||||
float g[] = { 0, 0.1028688999747279f, 0.1454785934906616f, 0.1781741612749496f, 0.2057377999494559f, 0.2300218531141181f, 0.2519763153394848f, 0.2721655269759087f, 0.2909571869813232f, 0.3086066999241838f, 0.3253000243161777f, 0.3411775438127727f, 0.3563483225498992f, 0.3708990935094579f, 0.3849001794597505f, 0.3984095364447979f, 0.4114755998989117f, 0.4241393401869012f, 0.4364357804719847f, 0.4483951394230328f, 0.4600437062282361f, 0.4714045207910317f, 0.4824979096371639f, 0.4933419132673033f, 0.5091750772173156f, 0.5328701692569688f, 0.5555555555555556f, 0.5773502691896257f, 0.5983516452371671f, 0.6186404847588913f, 0.6382847385042254f, 0.6573421981221795f, 0.6758625033664688f, 0.6938886664887108f, 0.7114582486036499f, 0.7286042804780002f, 0.7453559924999299f, 0.7617394000445604f, 0.7777777777777778f, 0.7934920476158723f, 0.8089010988089465f, 0.8240220541217402f, 0.8388704928078611f, 0.8534606386520677f, 0.8678055195451838f, 0.8819171036881968f, 0.8958064164776166f, 0.9094836413191612f, 0.9172076325837248f, 0.9229582069908971f, 0.9286731730990523f, 0.9343531843023135f, 0.9399988742535192f, 0.9456108576893002f, 0.9511897312113418f, 0.9567360740266436f, 0.9622504486493763f, 0.9677334015667416f, 0.9731854638710686f, 0.9786071518602129f, 0.9839989676081821f, 0.9893613995077727f, 0.9946949227868761f, 1};
|
||||
float b[] = { 0, 0.1028688999747279f, 0.1454785934906616f, 0.1781741612749496f, 0.2057377999494559f, 0.2300218531141181f, 0.2519763153394848f, 0.2721655269759087f, 0.2909571869813232f, 0.3086066999241838f, 0.3253000243161777f, 0.3411775438127727f, 0.3563483225498992f, 0.3708990935094579f, 0.3849001794597505f, 0.3984095364447979f, 0.4114755998989117f, 0.4241393401869012f, 0.4364357804719847f, 0.4483951394230328f, 0.4600437062282361f, 0.4714045207910317f, 0.4824979096371639f, 0.4933419132673033f, 0.5039526306789697f, 0.5143444998736397f, 0.5245305283129621f, 0.5345224838248488f, 0.5443310539518174f, 0.5539659798925444f, 0.563436169819011f, 0.5727497953228163f, 0.5819143739626463f, 0.5909368402852788f, 0.5998236072282915f, 0.6085806194501846f, 0.6172133998483676f, 0.6257270902992705f, 0.6341264874742278f, 0.642416074439621f, 0.6506000486323554f, 0.6586823467062358f, 0.6666666666666666f, 0.6745564876468501f, 0.6823550876255453f, 0.6900655593423541f, 0.6976908246297114f, 0.7052336473499384f, 0.7237468644557459f, 0.7453559924999298f, 0.7663560447348133f, 0.7867957924694432f, 0.8067178260046388f, 0.8261595987094034f, 0.8451542547285166f, 0.8637312927246217f, 0.8819171036881968f, 0.8997354108424372f, 0.9172076325837248f, 0.9343531843023135f, 0.9511897312113418f, 0.9677334015667416f, 0.9839989676081821f, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -457,9 +457,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163, 0.0714285714285714, 0.1111111111111112, 0.1507936507936507, 0.1904761904761905, 0.23015873015873, 0.2698412698412698, 0.3095238095238093, 0.3492063492063491, 0.3888888888888888, 0.4285714285714284, 0.4682539682539679, 0.5079365079365079, 0.5476190476190477, 0.5873015873015872, 0.6269841269841268, 0.6666666666666665, 0.7063492063492065, 0.746031746031746, 0.7857142857142856, 0.8253968253968254, 0.8650793650793651, 0.9047619047619047, 0.9444444444444442, 0.984126984126984, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745, 0.1269841269841265, 0.2063492063492056, 0.2857142857142856, 0.3650793650793656, 0.4444444444444446, 0.5238095238095237, 0.6031746031746028, 0.6825396825396828, 0.7619047619047619, 0.8412698412698409, 0.92063492063492, 1};
|
||||
float r[] = { 0, 0.03968253968253968f, 0.07936507936507936f, 0.119047619047619f, 0.1587301587301587f, 0.1984126984126984f, 0.2380952380952381f, 0.2777777777777778f, 0.3174603174603174f, 0.3571428571428571f, 0.3968253968253968f, 0.4365079365079365f, 0.4761904761904762f, 0.5158730158730158f, 0.5555555555555556f, 0.5952380952380952f, 0.6349206349206349f, 0.6746031746031745f, 0.7142857142857142f, 0.753968253968254f, 0.7936507936507936f, 0.8333333333333333f, 0.873015873015873f, 0.9126984126984127f, 0.9523809523809523f, 0.992063492063492f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163f, 0.0714285714285714f, 0.1111111111111112f, 0.1507936507936507f, 0.1904761904761905f, 0.23015873015873f, 0.2698412698412698f, 0.3095238095238093f, 0.3492063492063491f, 0.3888888888888888f, 0.4285714285714284f, 0.4682539682539679f, 0.5079365079365079f, 0.5476190476190477f, 0.5873015873015872f, 0.6269841269841268f, 0.6666666666666665f, 0.7063492063492065f, 0.746031746031746f, 0.7857142857142856f, 0.8253968253968254f, 0.8650793650793651f, 0.9047619047619047f, 0.9444444444444442f, 0.984126984126984f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745f, 0.1269841269841265f, 0.2063492063492056f, 0.2857142857142856f, 0.3650793650793656f, 0.4444444444444446f, 0.5238095238095237f, 0.6031746031746028f, 0.6825396825396828f, 0.7619047619047619f, 0.8412698412698409f, 0.92063492063492f, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
@@ -481,9 +481,9 @@ namespace colormap
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0.2078, 0.0118, 0.0784, 0.0235, 0.2196, 0.5725, 0.8510, 0.9882, 0.9765 };
|
||||
float g[] = { 0.1647, 0.3882, 0.5216, 0.6549, 0.7255, 0.7490, 0.7294, 0.8078, 0.9843 };
|
||||
float b[] = { 0.5294, 0.8824, 0.8314, 0.7765, 0.6196, 0.4510, 0.3373, 0.1804, 0.0549 };
|
||||
float r[] = { 0.2078f, 0.0118f, 0.0784f, 0.0235f, 0.2196f, 0.5725f, 0.8510f, 0.9882f, 0.9765f };
|
||||
float g[] = { 0.1647f, 0.3882f, 0.5216f, 0.6549f, 0.7255f, 0.7490f, 0.7294f, 0.8078f, 0.9843f };
|
||||
float b[] = { 0.5294f, 0.8824f, 0.8314f, 0.7765f, 0.6196f, 0.4510f, 0.3373f, 0.1804f, 0.0549f };
|
||||
Mat X = linspace(0, 1, 9);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(9, 1, CV_32FC1, r).clone(), // red
|
||||
|
||||
@@ -222,7 +222,6 @@ cvStartFindContours( void* _img, CvMemStorage* storage,
|
||||
scanner->lnbd.x = 0;
|
||||
scanner->lnbd.y = 1;
|
||||
scanner->nbd = 2;
|
||||
scanner->mode = (int) mode;
|
||||
scanner->frame_info.contour = &(scanner->frame);
|
||||
scanner->frame_info.is_hole = 1;
|
||||
scanner->frame_info.next = 0;
|
||||
|
||||
@@ -394,7 +394,7 @@ static bool extractCovData(InputArray _src, UMat & Dx, UMat & Dy, int depth,
|
||||
Dx.create(src.size(), CV_32FC1);
|
||||
Dy.create(src.size(), CV_32FC1);
|
||||
|
||||
size_t localsize[2] = { sobel_lsz, sobel_lsz };
|
||||
size_t localsize[2] = { (size_t)sobel_lsz, (size_t)sobel_lsz };
|
||||
size_t globalsize[2] = { localsize[0] * (1 + (src.cols - 1) / localsize[0]),
|
||||
localsize[1] * (1 + (src.rows - 1) / localsize[1]) };
|
||||
|
||||
@@ -515,7 +515,7 @@ static bool ocl_preCornerDetect( InputArray _src, OutputArray _dst, int ksize, i
|
||||
ocl::KernelArg::ReadOnlyNoSize(D2x), ocl::KernelArg::ReadOnlyNoSize(D2y),
|
||||
ocl::KernelArg::ReadOnlyNoSize(Dxy), ocl::KernelArg::WriteOnly(dst), (float)factor);
|
||||
|
||||
size_t globalsize[2] = { dst.cols, dst.rows };
|
||||
size_t globalsize[2] = { (size_t)dst.cols, (size_t)dst.rows };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ namespace cv
|
||||
{
|
||||
static bool ipp_cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, int ksize, int borderType )
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 8
|
||||
#if IPP_VERSION_X100 >= 800
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), CV_32FC1 );
|
||||
Mat dst = _dst.getMat();
|
||||
@@ -603,16 +603,12 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in
|
||||
ocl_cornerMinEigenValVecs(_src, _dst, blockSize, ksize, 0.0, borderType, MINEIGENVAL))
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
int kerSize = ksize;
|
||||
if (ksize < 0)
|
||||
{
|
||||
kerSize = 3;
|
||||
}
|
||||
int kerSize = (ksize < 0)?3:ksize;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
#endif
|
||||
CV_IPP_RUN(((borderTypeNI == BORDER_REPLICATE && (!_src.isSubmatrix() || isolated)) &&
|
||||
(kerSize == 3 || kerSize == 5) && (blockSize == 3 || blockSize == 5)) && IPP_VERSION_MAJOR >= 8,
|
||||
(kerSize == 3 || kerSize == 5) && (blockSize == 3 || blockSize == 5)) && IPP_VERSION_X100 >= 800,
|
||||
ipp_cornerMinEigenVal( _src, _dst, blockSize, ksize, borderType ));
|
||||
|
||||
|
||||
@@ -629,7 +625,7 @@ namespace cv
|
||||
{
|
||||
static bool ipp_cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksize, double k, int borderType )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), CV_32FC1 );
|
||||
Mat dst = _dst.getMat();
|
||||
@@ -696,7 +692,7 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi
|
||||
#endif
|
||||
CV_IPP_RUN(((ksize == 3 || ksize == 5) && (_src.type() == CV_8UC1 || _src.type() == CV_32FC1) &&
|
||||
(borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE) && CV_MAT_CN(_src.type()) == 1 &&
|
||||
(!_src.isSubmatrix() || isolated)) && IPP_VERSION_X100 >= 801 && 0, ipp_cornerHarris( _src, _dst, blockSize, ksize, k, borderType ));
|
||||
(!_src.isSubmatrix() || isolated)) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK, ipp_cornerHarris( _src, _dst, blockSize, ksize, k, borderType ));
|
||||
|
||||
|
||||
Mat src = _src.getMat();
|
||||
|
||||
+87
-185
@@ -43,10 +43,6 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
static IppStatus sts = ippInit();
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
Sobel & Scharr Derivative Filters
|
||||
\****************************************************************************************/
|
||||
@@ -183,15 +179,12 @@ cv::Ptr<cv::FilterEngine> cv::createDerivFilter(int srcType, int dstType,
|
||||
kx, ky, Point(-1,-1), 0, borderType );
|
||||
}
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
|
||||
#define IPP_RETURN_ERROR {setIppErrorStatus(); return false;}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
if ((0 > dx) || (0 > dy) || (1 != dx + dy))
|
||||
return false;
|
||||
if (fabs(delta) > FLT_EPSILON)
|
||||
@@ -233,19 +226,19 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_8u16s_C1R(src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_8u16s_C1R(src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
@@ -256,19 +249,19 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_16s_C1R(src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_16s_C1R(src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
@@ -279,134 +272,34 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
if (sts < 0)
|
||||
IPP_RETURN_ERROR;
|
||||
return false;;
|
||||
|
||||
if (FLT_EPSILON < fabs(scale - 1.0))
|
||||
sts = ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roiSize);
|
||||
}
|
||||
return (0 <= sts);
|
||||
}
|
||||
#elif IPP_VERSION_X100 >= 700
|
||||
static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
if (BORDER_REPLICATE != borderType)
|
||||
return false;
|
||||
if ((0 > dx) || (0 > dy) || (1 != dx + dy))
|
||||
return false;
|
||||
if (fabs(delta) > FLT_EPSILON)
|
||||
return false;
|
||||
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
|
||||
int bufSize = 0;
|
||||
cv::AutoBuffer<char> buffer;
|
||||
IppiSize roi = ippiSize(src.cols, src.rows);
|
||||
|
||||
if( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
|
||||
dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
|
||||
switch(src.type())
|
||||
{
|
||||
case CV_8UC1:
|
||||
{
|
||||
if(scale != 1)
|
||||
return false;
|
||||
|
||||
switch(dst.type())
|
||||
{
|
||||
case CV_16S:
|
||||
{
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterScharrVertGetBufferSize_8u16s_C1R(roi,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
return (0 <= ippiFilterScharrVertBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
|
||||
}
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizGetBufferSize_8u16s_C1R(roi,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
return (0 <= ippiFilterScharrHorizBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case CV_32FC1:
|
||||
{
|
||||
switch(dst.type())
|
||||
{
|
||||
case CV_32FC1:
|
||||
{
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterScharrVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterScharrVertBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows),
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scale != 1)
|
||||
/* IPP is fast, so MulC produce very little perf degradation.*/
|
||||
//ippiMulC_32f_C1IR((Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
}
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterScharrHorizBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows),
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
return false;
|
||||
|
||||
if (scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ddepth); CV_UNUSED(dx); CV_UNUSED(dy); CV_UNUSED(scale); CV_UNUSED(delta); CV_UNUSED(borderType);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
|
||||
{
|
||||
@@ -423,58 +316,75 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
if ( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
|
||||
IppiSize roi = {src.cols, src.rows};
|
||||
IppiMaskSize kernel = (IppiMaskSize)(ksize*10+ksize);
|
||||
|
||||
if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
if(ippiFilterSobelGetBufferSize(roi, kernel, ippNormL2, ipp8u, ipp16s, 1, &bufSize) < 0)
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelNegVertBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelHorizBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_IPP_ICV_ONLY)
|
||||
if ((dx == 2) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelVertSecondBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx == 0) && (dy == 2))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelHorizSecondBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -482,17 +392,25 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
|
||||
if (src.type() == CV_32F && dst.type() == CV_32F)
|
||||
{
|
||||
#if 0
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
if(ippiFilterSobelGetBufferSize(roi, kernel, ippNormL2, ipp32f, ipp32f, 1, &bufSize) < 0)
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
#if IPP_DISABLE_BLOCK
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(roi, kernel, &bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelNegVertBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@@ -500,13 +418,16 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelHorizBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@@ -515,14 +436,16 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
#if !defined(HAVE_IPP_ICV_ONLY)
|
||||
if((dx == 2) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelVertSecondBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@@ -530,14 +453,16 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
|
||||
if((dx == 0) && (dy == 2))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
#if IPP_VERSION_X100 < 900
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
#endif
|
||||
|
||||
if (0 > ippiFilterSobelHorizSecondBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
@@ -547,41 +472,22 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_IPP
|
||||
|
||||
static bool ipp_sobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
|
||||
{
|
||||
if (ksize < 0)
|
||||
{
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (0 < ksize)
|
||||
{
|
||||
if (IPPDerivSobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool ipp_scharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
@@ -604,10 +510,8 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CV_IPP_RUN(true, ipp_sobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType));
|
||||
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
|
||||
Mat kx, ky;
|
||||
@@ -643,9 +547,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CV_IPP_RUN(true, ipp_scharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType));
|
||||
|
||||
CV_IPP_RUN(true, IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType));
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
|
||||
@@ -800,7 +702,7 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst,
|
||||
else
|
||||
k.args(d2xarg, d2yarg, dstarg, iscale, idelta);
|
||||
|
||||
size_t globalsize[] = { dst.cols * cn / kercn, dst.rows };
|
||||
size_t globalsize[] = { (size_t)dst.cols * cn / kercn, (size_t)dst.rows };
|
||||
return k.run(2, globalsize, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -785,7 +785,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
|
||||
{
|
||||
if( maskSize == CV_DIST_MASK_3 )
|
||||
{
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
@@ -802,7 +802,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
|
||||
@@ -610,12 +610,12 @@ LineAA( Mat& img, Point pt1, Point pt2, const void* color )
|
||||
ICV_PUT_POINT();
|
||||
ICV_PUT_POINT();
|
||||
|
||||
tptr += step;
|
||||
tptr += 4;
|
||||
a = (ep_corr * FilterTable[dist] >> 8) & 0xff;
|
||||
ICV_PUT_POINT();
|
||||
ICV_PUT_POINT();
|
||||
|
||||
tptr += step;
|
||||
tptr += 4;
|
||||
a = (ep_corr * FilterTable[63 - dist] >> 8) & 0xff;
|
||||
ICV_PUT_POINT();
|
||||
ICV_PUT_POINT();
|
||||
@@ -2090,6 +2090,10 @@ void putText( InputOutputArray _img, const String& text, Point org,
|
||||
int thickness, int line_type, bool bottomLeftOrigin )
|
||||
|
||||
{
|
||||
if ( text.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Mat img = _img.getMat();
|
||||
const int* ascii = getFontData(fontFace);
|
||||
|
||||
@@ -2111,7 +2115,7 @@ void putText( InputOutputArray _img, const String& text, Point org,
|
||||
pts.reserve(1 << 10);
|
||||
const char **faces = cv::g_HersheyGlyphs;
|
||||
|
||||
for( int i = 0; text[i] != '\0'; i++ )
|
||||
for( int i = 0; i < (int)text.size(); i++ )
|
||||
{
|
||||
int c = (uchar)text[i];
|
||||
Point p;
|
||||
@@ -2158,7 +2162,7 @@ Size getTextSize( const String& text, int fontFace, double fontScale, int thickn
|
||||
int cap_line = (ascii[0] >> 4) & 15;
|
||||
size.height = cvRound((cap_line + base_line)*fontScale + (thickness+1)/2);
|
||||
|
||||
for( int i = 0; text[i] != '\0'; i++ )
|
||||
for( int i = 0; i < (int)text.size(); i++ )
|
||||
{
|
||||
int c = (uchar)text[i];
|
||||
Point p;
|
||||
@@ -2232,6 +2236,7 @@ void cv::polylines(InputOutputArray _img, InputArrayOfArrays pts,
|
||||
Mat p = pts.getMat(manyContours ? i : -1);
|
||||
if( p.total() == 0 )
|
||||
{
|
||||
ptsptr[i] = NULL;
|
||||
npts[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
thresholdarg, (int)possibleCornersCount);
|
||||
}
|
||||
|
||||
size_t globalsize[2] = { eig.cols - 2, eig.rows - 2 };
|
||||
size_t globalsize[2] = { (size_t)eig.cols - 2, (size_t)eig.rows - 2 };
|
||||
if (!k.run(2, globalsize, NULL, false))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
Base Image Filter
|
||||
\****************************************************************************************/
|
||||
|
||||
#if IPP_VERSION_X100 >= 701
|
||||
#if IPP_VERSION_X100 >= 710
|
||||
#define USE_IPP_SEP_FILTERS 1
|
||||
#else
|
||||
#undef USE_IPP_SEP_FILTERS
|
||||
@@ -1415,14 +1415,14 @@ struct RowVec_32f
|
||||
{
|
||||
kernel = _kernel;
|
||||
haveSSE = checkHardwareSupport(CV_CPU_SSE);
|
||||
#if defined USE_IPP_SEP_FILTERS && 0
|
||||
#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
|
||||
bufsz = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
|
||||
{
|
||||
#if defined USE_IPP_SEP_FILTERS && 0
|
||||
#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
int ret = ippiOperator(_src, _dst, width, cn);
|
||||
@@ -1463,7 +1463,7 @@ struct RowVec_32f
|
||||
|
||||
Mat kernel;
|
||||
bool haveSSE;
|
||||
#if defined USE_IPP_SEP_FILTERS && 0
|
||||
#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
|
||||
private:
|
||||
mutable int bufsz;
|
||||
int ippiOperator(const uchar* _src, uchar* _dst, int width, int cn) const
|
||||
@@ -4031,7 +4031,7 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
|
||||
cv::Mat kernelMat = _kernel.getMat();
|
||||
cv::Size sz = _src.size(), wholeSize;
|
||||
size_t globalsize[2] = { sz.width, sz.height };
|
||||
size_t globalsize[2] = { (size_t)sz.width, (size_t)sz.height };
|
||||
size_t localsize_general[2] = {0, 1};
|
||||
size_t* localsize = NULL;
|
||||
|
||||
@@ -4579,7 +4579,11 @@ static bool ipp_filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype),
|
||||
ktype = kernel.type(), kdepth = CV_MAT_DEPTH(ktype);
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
Point ippAnchor((kernel.cols-1)/2, (kernel.rows-1)/2);
|
||||
#else
|
||||
Point ippAnchor(kernel.cols >> 1, kernel.rows >> 1);
|
||||
#endif
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
IppiBorderType ippBorderType = ippiGetBorderType(borderTypeNI);
|
||||
|
||||
@@ -4610,24 +4614,64 @@ static bool ipp_filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
|
||||
if ((status = ippiFilterBorderGetSize(kernelSize, dstRoiSize, dataType, kernelType, cn, &specSize, &bufsize)) >= 0)
|
||||
{
|
||||
IppiFilterBorderSpec * spec = (IppiFilterBorderSpec *)ippMalloc(specSize);
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
IppAutoBuffer<IppiFilterBorderSpec> spec(specSize);
|
||||
IppAutoBuffer<Ipp8u> buffer(bufsize);
|
||||
Ipp32f borderValue[4] = { 0, 0, 0, 0 };
|
||||
|
||||
Mat reversedKernel;
|
||||
flip(kernel, reversedKernel, -1);
|
||||
|
||||
if ((kdepth == CV_32F && (status = ippiFilterBorderInit_32f((const Ipp32f *)reversedKernel.data, kernelSize,
|
||||
dataType, cn, ippRndFinancial, spec)) >= 0 ) ||
|
||||
(kdepth == CV_16S && (status = ippiFilterBorderInit_16s((const Ipp16s *)reversedKernel.data,
|
||||
kernelSize, 0, dataType, cn, ippRndFinancial, spec)) >= 0))
|
||||
if(kdepth == CV_32F)
|
||||
{
|
||||
status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, dstRoiSize,
|
||||
ippBorderType, borderValue, spec, buffer);
|
||||
}
|
||||
Ipp32f *pKerBuffer = (Ipp32f*)kernel.data;
|
||||
IppAutoBuffer<Ipp32f> kerTmp;
|
||||
int kerStep = sizeof(Ipp32f)*kernelSize.width;
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
if(kernel.step != kerStep)
|
||||
{
|
||||
kerTmp.Alloc(kerStep*kernelSize.height);
|
||||
if(ippiCopy_32f_C1R((Ipp32f*)kernel.data, (int)kernel.step, kerTmp, kerStep, kernelSize) < 0)
|
||||
return false;
|
||||
pKerBuffer = kerTmp;
|
||||
}
|
||||
#else
|
||||
kerTmp.Alloc(kerStep*kernelSize.height);
|
||||
Mat kerFlip(Size(kernelSize.width, kernelSize.height), CV_32FC1, kerTmp, kerStep);
|
||||
flip(kernel, kerFlip, -1);
|
||||
pKerBuffer = kerTmp;
|
||||
#endif
|
||||
|
||||
ippsFree(buffer);
|
||||
ippsFree(spec);
|
||||
if((status = ippiFilterBorderInit_32f(pKerBuffer, kernelSize,
|
||||
dataType, cn, ippRndFinancial, spec)) >= 0 )
|
||||
{
|
||||
status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, dstRoiSize,
|
||||
ippBorderType, borderValue, spec, buffer);
|
||||
}
|
||||
}
|
||||
else if(kdepth == CV_16S)
|
||||
{
|
||||
Ipp16s *pKerBuffer = (Ipp16s*)kernel.data;
|
||||
IppAutoBuffer<Ipp16s> kerTmp;
|
||||
int kerStep = sizeof(Ipp16s)*kernelSize.width;
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
if(kernel.step != kerStep)
|
||||
{
|
||||
kerTmp.Alloc(kerStep*kernelSize.height);
|
||||
if(ippiCopy_16s_C1R((Ipp16s*)kernel.data, (int)kernel.step, kerTmp, kerStep, kernelSize) < 0)
|
||||
return false;
|
||||
pKerBuffer = kerTmp;
|
||||
}
|
||||
#else
|
||||
kerTmp.Alloc(kerStep*kernelSize.height);
|
||||
Mat kerFlip(Size(kernelSize.width, kernelSize.height), CV_16SC1, kerTmp, kerStep);
|
||||
flip(kernel, kerFlip, -1);
|
||||
pKerBuffer = kerTmp;
|
||||
#endif
|
||||
|
||||
if((status = ippiFilterBorderInit_16s(pKerBuffer, kernelSize,
|
||||
0, dataType, cn, ippRndFinancial, spec)) >= 0)
|
||||
{
|
||||
status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, dstRoiSize,
|
||||
ippBorderType, borderValue, spec, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
|
||||
@@ -537,7 +537,7 @@ void cv::grabCut( InputArray _img, InputOutputArray _mask, Rect rect,
|
||||
if( img.empty() )
|
||||
CV_Error( CV_StsBadArg, "image is empty" );
|
||||
if( img.type() != CV_8UC3 )
|
||||
CV_Error( CV_StsBadArg, "image mush have CV_8UC3 type" );
|
||||
CV_Error( CV_StsBadArg, "image must have CV_8UC3 type" );
|
||||
|
||||
GMM bgdGMM( bgdModel ), fgdGMM( fgdModel );
|
||||
Mat compIdxs( img.size(), CV_32SC1 );
|
||||
|
||||
@@ -1176,12 +1176,11 @@ calcHist_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
|
||||
class IPPCalcHistInvoker :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
IPPCalcHistInvoker(const Mat & _src, Mat & _hist, AutoBuffer<Ipp32s> & _levels, Ipp32s _histSize, Ipp32s _low, Ipp32s _high, bool * _ok) :
|
||||
IPPCalcHistInvoker(const Mat & _src, Mat & _hist, AutoBuffer<Ipp32f> & _levels, Ipp32s _histSize, Ipp32f _low, Ipp32f _high, bool * _ok) :
|
||||
ParallelLoopBody(), src(&_src), hist(&_hist), levels(&_levels), histSize(_histSize), low(_low), high(_high), ok(_ok)
|
||||
{
|
||||
*ok = true;
|
||||
@@ -1190,17 +1189,58 @@ public:
|
||||
virtual void operator() (const Range & range) const
|
||||
{
|
||||
Mat phist(hist->size(), hist->type(), Scalar::all(0));
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
IppiSize roi = {src->cols, range.end - range.start};
|
||||
int bufferSize = 0;
|
||||
int specSize = 0;
|
||||
IppiHistogramSpec *pSpec = NULL;
|
||||
Ipp8u *pBuffer = NULL;
|
||||
|
||||
IppStatus status = ippiHistogramEven_8u_C1R(
|
||||
src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
|
||||
phist.ptr<Ipp32s>(), (Ipp32s *)*levels, histSize, low, high);
|
||||
|
||||
if (status < 0)
|
||||
if(ippiHistogramGetBufferSize(ipp8u, roi, &histSize, 1, 1, &specSize, &bufferSize) < 0)
|
||||
{
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufferSize);
|
||||
if(!pBuffer && bufferSize)
|
||||
{
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
pSpec = (IppiHistogramSpec*)ippMalloc(specSize);
|
||||
if(!pSpec && specSize)
|
||||
{
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(ippiHistogramUniformInit(ipp8u, (Ipp32f*)&low, (Ipp32f*)&high, (Ipp32s*)&histSize, 1, pSpec) < 0)
|
||||
{
|
||||
if(pSpec) ippFree(pSpec);
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IppStatus status = ippiHistogram_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
|
||||
phist.ptr<Ipp32u>(), pSpec, pBuffer);
|
||||
|
||||
if(pSpec) ippFree(pSpec);
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
#else
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus status = ippiHistogramEven_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
|
||||
phist.ptr<Ipp32s>(), (Ipp32s*)(Ipp32f*)*levels, histSize, (Ipp32s)low, (Ipp32s)high);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
#endif
|
||||
if(status < 0)
|
||||
{
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
|
||||
for (int i = 0; i < histSize; ++i)
|
||||
CV_XADD((int *)(hist->data + i * hist->step), *(int *)(phist.data + i * phist.step));
|
||||
@@ -1209,8 +1249,9 @@ public:
|
||||
private:
|
||||
const Mat * src;
|
||||
Mat * hist;
|
||||
AutoBuffer<Ipp32s> * levels;
|
||||
Ipp32s histSize, low, high;
|
||||
AutoBuffer<Ipp32f> * levels;
|
||||
Ipp32s histSize;
|
||||
Ipp32f low, high;
|
||||
bool * ok;
|
||||
|
||||
const IPPCalcHistInvoker & operator = (const IPPCalcHistInvoker & );
|
||||
@@ -1241,7 +1282,7 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
|
||||
!accumulate && uniform)
|
||||
{
|
||||
ihist.setTo(Scalar::all(0));
|
||||
AutoBuffer<Ipp32s> levels(histSize[0] + 1);
|
||||
AutoBuffer<Ipp32f> levels(histSize[0] + 1);
|
||||
|
||||
bool ok = true;
|
||||
const Mat & src = images[0];
|
||||
@@ -1249,14 +1290,13 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
nstripes = 1;
|
||||
#endif
|
||||
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, (Ipp32s)ranges[0][0], (Ipp32s)ranges[0][1], &ok);
|
||||
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, ranges[0][0], ranges[0][1], &ok);
|
||||
Range range(0, src.rows);
|
||||
parallel_for_(range, invoker, nstripes);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
ihist.convertTo(hist, CV_32F);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2180,7 +2220,7 @@ static bool ocl_calcBackProject( InputArrayOfArrays _images, std::vector<int> ch
|
||||
mapk.args(ocl::KernelArg::ReadOnlyNoSize(im), ocl::KernelArg::PtrReadOnly(lut),
|
||||
ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
size_t globalsize[2] = { size.width, size.height };
|
||||
size_t globalsize[2] = { (size_t)size.width, (size_t)size.height };
|
||||
return mapk.run(2, globalsize, NULL, false);
|
||||
}
|
||||
else if (histdims == 2)
|
||||
@@ -2227,7 +2267,7 @@ static bool ocl_calcBackProject( InputArrayOfArrays _images, std::vector<int> ch
|
||||
mapk.args(ocl::KernelArg::ReadOnlyNoSize(im0), ocl::KernelArg::ReadOnlyNoSize(im1),
|
||||
ocl::KernelArg::ReadOnlyNoSize(hist), ocl::KernelArg::PtrReadOnly(lut), scale, ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
size_t globalsize[2] = { size.width, size.height };
|
||||
size_t globalsize[2] = { (size_t)size.width, (size_t)size.height };
|
||||
return mapk.run(2, globalsize, NULL, false);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -96,7 +96,7 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
|
||||
int numangle = cvRound((max_theta - min_theta) / theta);
|
||||
int numrho = cvRound(((width + height) * 2 + 1) / rho);
|
||||
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801)
|
||||
#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 810 && IPP_DISABLED_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize srcSize = { width, height };
|
||||
@@ -429,7 +429,7 @@ HoughLinesProbabilistic( Mat& image,
|
||||
int numangle = cvRound(CV_PI / theta);
|
||||
int numrho = cvRound(((width + height) * 2 + 1) / rho);
|
||||
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801)
|
||||
#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 810 && IPP_DISABLED_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize srcSize = { width, height };
|
||||
@@ -680,8 +680,8 @@ static bool ocl_makePointsList(InputArray _src, OutputArray _pointsList, InputOu
|
||||
pointListKernel.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnlyNoSize(pointsList),
|
||||
ocl::KernelArg::PtrWriteOnly(counters));
|
||||
|
||||
size_t localThreads[2] = { workgroup_size, 1 };
|
||||
size_t globalThreads[2] = { workgroup_size, src.rows };
|
||||
size_t localThreads[2] = { (size_t)workgroup_size, 1 };
|
||||
size_t globalThreads[2] = { (size_t)workgroup_size, (size_t)src.rows };
|
||||
|
||||
return pointListKernel.run(2, globalThreads, localThreads, false);
|
||||
}
|
||||
@@ -775,7 +775,7 @@ static bool ocl_HoughLines(InputArray _src, OutputArray _lines, double rho, doub
|
||||
getLinesKernel.args(ocl::KernelArg::ReadOnly(accum), ocl::KernelArg::WriteOnlyNoSize(lines),
|
||||
ocl::KernelArg::PtrWriteOnly(counters), linesMax, threshold, (float) rho, (float) theta);
|
||||
|
||||
size_t globalThreads[2] = { (numrho + pixPerWI - 1)/pixPerWI, numangle };
|
||||
size_t globalThreads[2] = { ((size_t)numrho + pixPerWI - 1)/pixPerWI, (size_t)numangle };
|
||||
if (!getLinesKernel.run(2, globalThreads, NULL, false))
|
||||
return false;
|
||||
|
||||
@@ -829,7 +829,7 @@ static bool ocl_HoughLinesP(InputArray _src, OutputArray _lines, double rho, dou
|
||||
ocl::KernelArg::WriteOnlyNoSize(lines), ocl::KernelArg::PtrWriteOnly(counters),
|
||||
linesMax, threshold, (int) minLineLength, (int) maxGap, (float) rho, (float) theta);
|
||||
|
||||
size_t globalThreads[2] = { numrho, numangle };
|
||||
size_t globalThreads[2] = { (size_t)numrho, (size_t)numangle };
|
||||
if (!getLinesKernel.run(2, globalThreads, NULL, false))
|
||||
return false;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user