Merge pull request #9580 from mshabunin:fix-static-6

This commit is contained in:
Alexander Alekhin 2017-09-09 19:31:21 +00:00
commit 597b3f4456
41 changed files with 252 additions and 218 deletions

View File

@ -67,7 +67,7 @@
size_t src2_step;
#define DST_ARG1 DT * dst1_data_, size_t dst1_step_,
#define DST_STORE1 dst1_data(dst1_data_), dst1_step(dst1_step_),
#define DST_STORE1 dst1_data(dst1_data_), dst1_step(dst1_step_),
#define DST_VAR1 DT * dst1_data; \
size_t dst1_step;
@ -1073,7 +1073,7 @@ struct FilterCtx
inline int TEGRA_FILTERINIT(cvhalFilter2D **context, uchar *kernel_data, size_t kernel_step, int kernel_type, int kernel_width, int kernel_height,
int max_width, int max_height, int src_type, int dst_type, int borderType, double delta, int anchor_x, int anchor_y, bool allowSubmatrix, bool allowInplace)
{
if(!context || !kernel_data || allowSubmatrix || allowInplace ||
if(!context || !kernel_data || allowSubmatrix || allowInplace ||
src_type != CV_8UC1 || dst_type != CV_8UC1 ||
delta != 0 || anchor_x != kernel_width / 2 || anchor_y != kernel_height / 2 )
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -1105,7 +1105,7 @@ inline int TEGRA_FILTERINIT(cvhalFilter2D **context, uchar *kernel_data, size_t
return CV_HAL_ERROR_NOT_IMPLEMENTED;
}
if(!CAROTENE_NS::isConvolutionSupported(CAROTENE_NS::Size2D(max_width, max_height), ctx->ksize, ctx->border))
if(!CAROTENE_NS::isConvolutionSupported(CAROTENE_NS::Size2D(max_width, max_height), ctx->ksize, ctx->border))
{
delete ctx;
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -1212,7 +1212,7 @@ inline int TEGRA_SEPFILTERINIT(cvhalFilter2D **context, int src_type, int dst_ty
return CV_HAL_ERROR_NOT_IMPLEMENTED;
}
if(!CAROTENE_NS::isSeparableFilter3x3Supported(CAROTENE_NS::Size2D(16, 16), ctx->border, 3, 3))
if(!CAROTENE_NS::isSeparableFilter3x3Supported(CAROTENE_NS::Size2D(16, 16), ctx->border, 3, 3))
{
delete ctx;
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -1341,8 +1341,8 @@ inline int TEGRA_MORPHINIT(cvhalFilter2D **context, int operation, int src_type,
ctx->anchor_y = anchor_y;
switch(operation)
{
case MORPH_ERODE:
case MORPH_DILATE:
case CV_HAL_MORPH_ERODE:
case CV_HAL_MORPH_DILATE:
ctx->operation = operation;
break;
default:
@ -1355,7 +1355,7 @@ inline int TEGRA_MORPHINIT(cvhalFilter2D **context, int operation, int src_type,
ctx->border = CAROTENE_NS::BORDER_MODE_CONSTANT;
if( borderValue[0] == DBL_MAX && borderValue[1] == DBL_MAX && borderValue[2] == DBL_MAX && borderValue[3] == DBL_MAX )
{
if( operation == MORPH_ERODE )
if( operation == CV_HAL_MORPH_ERODE )
for(int i = 0; i < ctx->channels; ++i)
ctx->borderValues[i] = (CAROTENE_NS::u8)UCHAR_MAX;
else
@ -1404,14 +1404,14 @@ inline int TEGRA_MORPHFREE(cvhalFilter2D *context)
( \
(void)dst_full_width, (void)dst_full_height, (void)dst_roi_x, (void)dst_roi_y, \
context && CAROTENE_NS::isSupportedConfiguration() ? \
((MorphCtx*)context)->operation == MORPH_ERODE ? \
((MorphCtx*)context)->operation == CV_HAL_MORPH_ERODE ? \
CAROTENE_NS::erode(CAROTENE_NS::Size2D(width, height), ((MorphCtx*)context)->channels, \
src_data, src_step, dst_data, dst_step, \
((MorphCtx*)context)->ksize, ((MorphCtx*)context)->anchor_x, ((MorphCtx*)context)->anchor_y, \
((MorphCtx*)context)->border, ((MorphCtx*)context)->border, ((MorphCtx*)context)->borderValues, \
CAROTENE_NS::Margin(src_roi_x, src_full_width - width - src_roi_x, src_roi_y, src_full_height - height - src_roi_y)), \
CV_HAL_ERROR_OK : \
((MorphCtx*)context)->operation == MORPH_DILATE ? \
((MorphCtx*)context)->operation == CV_HAL_MORPH_DILATE ? \
CAROTENE_NS::dilate(CAROTENE_NS::Size2D(width, height), ((MorphCtx*)context)->channels, \
src_data, src_step, dst_data, dst_step, \
((MorphCtx*)context)->ksize, ((MorphCtx*)context)->anchor_x, ((MorphCtx*)context)->anchor_y, \

View File

@ -702,7 +702,7 @@ int ovx_hal_morphInit(cvhalFilter2D **filter_context, int operation, int src_typ
case CV_HAL_BORDER_CONSTANT:
if (borderValue[0] == DBL_MAX && borderValue[1] == DBL_MAX && borderValue[2] == DBL_MAX && borderValue[3] == DBL_MAX)
{
if (operation == MORPH_ERODE)
if (operation == CV_HAL_MORPH_ERODE)
setConstantBorder(border, UCHAR_MAX);
else
setConstantBorder(border, 0);
@ -779,10 +779,10 @@ int ovx_hal_morphInit(cvhalFilter2D **filter_context, int operation, int src_typ
MorphCtx* mat;
switch (operation)
{
case MORPH_ERODE:
case CV_HAL_MORPH_ERODE:
mat = new MorphCtx(ctx, kernel_mat, kernel_width, kernel_height, VX_NONLINEAR_FILTER_MIN, border);
break;
case MORPH_DILATE:
case CV_HAL_MORPH_DILATE:
mat = new MorphCtx(ctx, kernel_mat, kernel_width, kernel_height, VX_NONLINEAR_FILTER_MAX, border);
break;
default:

View File

@ -467,11 +467,10 @@ void Graph::removeEdge(size_t id1, size_t id2)
bool Graph::areVerticesAdjacent(size_t id1, size_t id2) const
{
CV_Assert( doesVertexExist( id1 ) );
CV_Assert( doesVertexExist( id2 ) );
Vertices::const_iterator it = vertices.find(id1);
return it->second.neighbors.find(id2) != it->second.neighbors.end();
CV_Assert(it != vertices.end());
const Neighbors & neighbors = it->second.neighbors;
return neighbors.find(id2) != neighbors.end();
}
size_t Graph::getVerticesCount() const
@ -481,9 +480,8 @@ size_t Graph::getVerticesCount() const
size_t Graph::getDegree(size_t id) const
{
CV_Assert( doesVertexExist(id) );
Vertices::const_iterator it = vertices.find(id);
CV_Assert( it != vertices.end() );
return it->second.neighbors.size();
}
@ -528,9 +526,8 @@ void Graph::floydWarshall(cv::Mat &distanceMatrix, int infinity) const
const Graph::Neighbors& Graph::getNeighbors(size_t id) const
{
CV_Assert( doesVertexExist(id) );
Vertices::const_iterator it = vertices.find(id);
CV_Assert( it != vertices.end() );
return it->second.neighbors;
}

View File

@ -17,6 +17,8 @@ class epnp {
void compute_pose(cv::Mat& R, cv::Mat& t);
private:
epnp(const epnp &); // copy disabled
epnp& operator=(const epnp &); // assign disabled
template <typename T>
void init_camera_parameters(const cv::Mat& cameraMatrix)
{

View File

@ -115,7 +115,8 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
float* rotation, float* translation )
{
int i, j, k;
int count = 0, converged = 0;
int count = 0;
bool converged = false;
float scale = 0, inv_Z = 0;
float diff = (float)criteria.epsilon;
@ -233,8 +234,8 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
inv_Z = scale * inv_focalLength;
count++;
converged = ((criteria.type & CV_TERMCRIT_EPS) && (diff < criteria.epsilon));
converged |= ((criteria.type & CV_TERMCRIT_ITER) && (count == criteria.max_iter));
converged = ((criteria.type & CV_TERMCRIT_EPS) && (diff < criteria.epsilon))
|| ((criteria.type & CV_TERMCRIT_ITER) && (count == criteria.max_iter));
}
const float invScale = 1 / scale;
translation[0] = imagePoints[0].x * invScale;

View File

@ -60,6 +60,8 @@ public:
double compute_pose(cv::Mat& R, cv::Mat& t);
private:
upnp(const upnp &); // copy disabled
upnp& operator=(const upnp &); // assign disabled
template <typename T>
void init_camera_parameters(const cv::Mat& cameraMatrix)
{

View File

@ -374,7 +374,7 @@ cvGetMatND( const CvArr* arr, CvMatND* matnd, int* coi )
// returns number of dimensions to iterate.
/*
Checks whether <count> arrays have equal type, sizes (mask is optional array
that needs to have the same size, but 8uC1 or 8sC1 type).
that needs to have the same size, but 8uC1 or 8sC1 type - feature has been disabled).
Returns number of dimensions to iterate through:
0 means that all arrays are continuous,
1 means that all arrays are vectors of continuous arrays etc.
@ -399,17 +399,16 @@ cvInitNArrayIterator( int count, CvArr** arrs,
if( !iterator )
CV_Error( CV_StsNullPtr, "Iterator pointer is NULL" );
for( i = 0; i <= count; i++ )
if (mask)
CV_Error( CV_StsBadArg, "Iterator with mask is not supported" );
for( i = 0; i < count; i++ )
{
const CvArr* arr = i < count ? arrs[i] : mask;
const CvArr* arr = arrs[i];
CvMatND* hdr;
if( !arr )
{
if( i < count )
CV_Error( CV_StsNullPtr, "Some of required array pointers is NULL" );
break;
}
CV_Error( CV_StsNullPtr, "Some of required array pointers is NULL" );
if( CV_IS_MATND( arr ))
hdr = (CvMatND*)arr;
@ -429,31 +428,23 @@ cvInitNArrayIterator( int count, CvArr** arrs,
CV_Error( CV_StsUnmatchedSizes,
"Number of dimensions is the same for all arrays" );
if( i < count )
switch( flags & (CV_NO_DEPTH_CHECK|CV_NO_CN_CHECK))
{
switch( flags & (CV_NO_DEPTH_CHECK|CV_NO_CN_CHECK))
{
case 0:
if( !CV_ARE_TYPES_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Data type is not the same for all arrays" );
break;
case CV_NO_DEPTH_CHECK:
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Number of channels is not the same for all arrays" );
break;
case CV_NO_CN_CHECK:
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Depth is not the same for all arrays" );
break;
}
}
else
{
if( !CV_IS_MASK_ARR( hdr ))
CV_Error( CV_StsBadMask, "Mask should have 8uC1 or 8sC1 data type" );
case 0:
if( !CV_ARE_TYPES_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Data type is not the same for all arrays" );
break;
case CV_NO_DEPTH_CHECK:
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Number of channels is not the same for all arrays" );
break;
case CV_NO_CN_CHECK:
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
CV_Error( CV_StsUnmatchedFormats,
"Depth is not the same for all arrays" );
break;
}
if( !(flags & CV_NO_SIZE_CHECK) )

View File

@ -2165,7 +2165,7 @@ bool _InputArray::isContinuous(int i) const
if( k == STD_ARRAY_MAT )
{
const Mat* vv = (const Mat*)obj;
CV_Assert(i < sz.height);
CV_Assert(i > 0 && i < sz.height);
return vv[i].isContinuous();
}

View File

@ -675,7 +675,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
const Mat* arrays[] = {&mat, 0};
uchar* ptr;
NAryMatIterator it(arrays, &ptr);
NAryMatIterator it(arrays, &ptr, 1);
int total = (int)it.size, blockSize = std::min((BLOCK_SIZE + cn - 1)/cn, total);
size_t esz = mat.elemSize();
AutoBuffer<double> buf;

View File

@ -1976,7 +1976,7 @@ public:
// Disable AVX1 since we don't track regressions for it. SSE42 will be used instead
if(cpuFeatures&ippCPUID_AVX && !(cpuFeatures&ippCPUID_AVX2))
ippFeatures &= ~ippCPUID_AVX;
ippFeatures &= ~((Ipp64u)ippCPUID_AVX);
// IPP integrations in OpenCV support only SSE4.2, AVX2 and AVX-512 optimizations.
if(!(

View File

@ -1333,7 +1333,7 @@ struct Net::Impl
//forward parents
MapIdToLayerData::iterator it;
for (it = layers.begin(); it->second.id < ld.id; it++)
for (it = layers.begin(); it != layers.end() && (it->second.id < ld.id); ++it)
{
LayerData &ld = it->second;
if (ld.flag)
@ -1349,7 +1349,9 @@ struct Net::Impl
{
CV_TRACE_FUNCTION();
forwardToLayer(layers.rbegin()->second, true);
MapIdToLayerData::reverse_iterator last_layer = layers.rbegin();
CV_Assert(last_layer != layers.rend());
forwardToLayer(last_layer->second, true);
}
void getLayerShapesRecursively(int id, LayersShapesMap& inOutShapes)

View File

@ -141,7 +141,7 @@ public:
parallel_for_(Range(0, nstripes), cc, nstripes);
}
ChannelConcatInvoker() {}
ChannelConcatInvoker() : inputs(0), output(0), nstripes(0) {}
void operator()(const Range& r) const
{

View File

@ -162,7 +162,7 @@ void printTensor(const tensorflow::TensorProto &tensor)
switch (tensor.dtype())
{
case 1: // float
case tensorflow::DT_FLOAT:
{
const float *data = reinterpret_cast<const float*>(tensor.tensor_content().c_str());
int size = tensor.tensor_content().size() / sizeof(float);
@ -172,7 +172,7 @@ void printTensor(const tensorflow::TensorProto &tensor)
std::cout << " ... " << size - 10 << " more";
break;
}
case 3: // int32
case tensorflow::DT_INT32:
{
const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
int size = tensor.tensor_content().size() / sizeof(int);

View File

@ -12,7 +12,6 @@ typedef struct THDiskFile__
THFile file;
FILE *handle;
char *name;
int isNativeEncoding;
int longSize;
@ -24,12 +23,6 @@ static int THDiskFile_isOpened(THFile *self)
return (dfself->handle != NULL);
}
const char *THDiskFile_name(THFile *self)
{
THDiskFile *dfself = (THDiskFile*)self;
return dfself->name;
}
/* workaround mac osx lion ***insane*** fread bug */
#ifdef __APPLE__
static size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
@ -265,7 +258,6 @@ static void THDiskFile_free(THFile *self)
THDiskFile *dfself = (THDiskFile*)(self);
if(dfself->handle)
fclose(dfself->handle);
THFree(dfself->name);
THFree(dfself);
}
@ -460,8 +452,7 @@ static long THDiskFile_readString(THFile *self, const char *format, char **str_)
return 0;
}
THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
THFile *THDiskFile_new(const std::string &name, const char *mode, int isQuiet)
{
static struct THFileVTable vtable = {
THDiskFile_isOpened,
@ -490,11 +481,12 @@ THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
THArgCheck(THDiskFile_mode(mode, &isReadable, &isWritable), 2, "file mode should be 'r','w' or 'rw'");
CV_Assert(isReadable && !isWritable);
#ifdef _MSC_VER
if (fopen_s(&handle, name, "rb") != 0)
if (fopen_s(&handle, name.c_str(), "rb") != 0)
handle = NULL;
#else
handle = fopen(name,"rb");
handle = fopen(name.c_str(),"rb");
#endif
if(!handle)
@ -502,7 +494,7 @@ THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
if(isQuiet)
return 0;
else
THError("cannot open <%s> in mode %c%c", name, (isReadable ? 'r' : ' '), (isWritable ? 'w' : ' '));
THError("cannot open <%s> in mode %c%c", name.c_str(), (isReadable ? 'r' : ' '), (isWritable ? 'w' : ' '));
}
self = (THDiskFile*)THAlloc(sizeof(THDiskFile));
@ -510,10 +502,6 @@ THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
THError("cannot allocate memory for self");
self->handle = handle;
self->name = (char*)THAlloc(strlen(name)+1);
if (!self->name)
THError("cannot allocate memory for self->name");
strcpy(self->name, name);
self->isNativeEncoding = 1;
self->longSize = 0;

View File

@ -2,13 +2,12 @@
#define TH_DISK_FILE_INC
#include "THFile.h"
#include <string>
namespace TH
{
TH_API THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet);
TH_API const char *THDiskFile_name(THFile *self);
TH_API THFile *THDiskFile_new(const std::string &name, const char *mode, int isQuiet);
TH_API int THDiskFile_isLittleEndianCPU(void);
TH_API int THDiskFile_isBigEndianCPU(void);

View File

@ -126,7 +126,7 @@ struct TorchImporter : public ::cv::dnn::Importer
rootModule = curModule = NULL;
moduleCounter = 0;
file = cv::Ptr<THFile>(THDiskFile_new(filename.c_str(), "r", 0), THFile_free);
file = cv::Ptr<THFile>(THDiskFile_new(filename, "r", 0), THFile_free);
CV_Assert(file && THFile_isOpened(file));
if (isBinary)

View File

@ -143,6 +143,10 @@ protected:
// general
static const float basicSize_;
private:
BRISK_Impl(const BRISK_Impl &); // copy disabled
BRISK_Impl& operator=(const BRISK_Impl &); // assign disabled
};

View File

@ -218,7 +218,7 @@ void EllipticKeyPoint::calcProjection( const std::vector<EllipticKeyPoint>& src,
dst.resize(src.size());
std::vector<EllipticKeyPoint>::const_iterator srcIt = src.begin();
std::vector<EllipticKeyPoint>::iterator dstIt = dst.begin();
for( ; srcIt != src.end(); ++srcIt, ++dstIt )
for( ; srcIt != src.end() && dstIt != dst.end(); ++srcIt, ++dstIt )
srcIt->calcProjection(H, *dstIt);
}
}

View File

@ -103,7 +103,7 @@ public:
keypoints.resize(corners.size());
std::vector<Point2f>::const_iterator corner_it = corners.begin();
std::vector<KeyPoint>::iterator keypoint_it = keypoints.begin();
for( ; corner_it != corners.end(); ++corner_it, ++keypoint_it )
for( ; corner_it != corners.end() && keypoint_it != keypoints.end(); ++corner_it, ++keypoint_it )
*keypoint_it = KeyPoint( *corner_it, (float)blockSize );
}

View File

@ -284,6 +284,7 @@ public:
history->parent_ = h;
}
}
CV_Assert(h != NULL);
h->val = gray_level;
h->size = size;
h->head = head;

View File

@ -182,6 +182,9 @@ public:
return mem;
}
private:
PooledAllocator(const PooledAllocator &); // copy disabled
PooledAllocator& operator=(const PooledAllocator &); // assign disabled
};
}

View File

@ -264,6 +264,9 @@ private:
bool loaded_;
/** Parameters passed to the index */
IndexParams index_params_;
Index(const Index &); // copy disabled
Index& operator=(const Index &); // assign disabled
};
/**

View File

@ -74,6 +74,10 @@ struct CV_EXPORTS IndexParams
std::vector<double>& numValues) const;
void* params;
private:
IndexParams(const IndexParams &); // copy disabled
IndexParams& operator=(const IndexParams &); // assign disabled
};
struct CV_EXPORTS KDTreeIndexParams : public IndexParams

View File

@ -96,6 +96,10 @@ protected:
bool m_native_depth;
bool m_iscolor;
bool m_isfloat;
private:
ExrDecoder(const ExrDecoder &); // copy disabled
ExrDecoder& operator=(const ExrDecoder &); // assign disabled
};

View File

@ -70,6 +70,10 @@ protected:
FILE* m_f;
void* m_state;
private:
JpegDecoder(const JpegDecoder &); // copy disabled
JpegDecoder& operator=(const JpegDecoder &); // assign disabled
};

View File

@ -117,6 +117,10 @@ protected:
bool readHdrData(Mat& img);
bool m_hdr;
size_t m_buf_pos;
private:
TiffDecoder(const TiffDecoder &); // copy disabled
TiffDecoder& operator=(const TiffDecoder &); // assign disabled
};
#endif

View File

@ -17,8 +17,8 @@
//! @name Morphology operations
//! @sa cv::MorphTypes
//! @{
#define MORPH_ERODE 0
#define MORPH_DILATE 1
#define CV_HAL_MORPH_ERODE 0
#define CV_HAL_MORPH_DILATE 1
//! @}
//! @}

View File

@ -9368,14 +9368,14 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
opts + "-D dcn=4 -D bidx=3");
break;
}
case CV_BGR2Lab: case CV_RGB2Lab: case CV_LBGR2Lab: case CV_LRGB2Lab:
case CV_BGR2Luv: case CV_RGB2Luv: case CV_LBGR2Luv: case CV_LRGB2Luv:
case COLOR_BGR2Lab: case COLOR_RGB2Lab: case COLOR_LBGR2Lab: case COLOR_LRGB2Lab:
case COLOR_BGR2Luv: case COLOR_RGB2Luv: case COLOR_LBGR2Luv: case COLOR_LRGB2Luv:
{
CV_Assert( (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) );
bidx = code == CV_BGR2Lab || code == CV_LBGR2Lab || code == CV_BGR2Luv || code == CV_LBGR2Luv ? 0 : 2;
bool srgb = code == CV_BGR2Lab || code == CV_RGB2Lab || code == CV_RGB2Luv || code == CV_BGR2Luv;
bool lab = code == CV_BGR2Lab || code == CV_RGB2Lab || code == CV_LBGR2Lab || code == CV_LRGB2Lab;
bidx = code == COLOR_BGR2Lab || code == COLOR_LBGR2Lab || code == COLOR_BGR2Luv || code == COLOR_LBGR2Luv ? 0 : 2;
bool srgb = code == COLOR_BGR2Lab || code == COLOR_RGB2Lab || code == COLOR_RGB2Luv || code == COLOR_BGR2Luv;
bool lab = code == COLOR_BGR2Lab || code == COLOR_RGB2Lab || code == COLOR_LBGR2Lab || code == COLOR_LRGB2Lab;
float un, vn;
dcn = 3;
@ -9497,16 +9497,16 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
return k.run(dims, globalsize, NULL, false);
}
case CV_Lab2BGR: case CV_Lab2RGB: case CV_Lab2LBGR: case CV_Lab2LRGB:
case CV_Luv2BGR: case CV_Luv2RGB: case CV_Luv2LBGR: case CV_Luv2LRGB:
case COLOR_Lab2BGR: case COLOR_Lab2RGB: case COLOR_Lab2LBGR: case COLOR_Lab2LRGB:
case COLOR_Luv2BGR: case COLOR_Luv2RGB: case COLOR_Luv2LBGR: case COLOR_Luv2LRGB:
{
if( dcn <= 0 )
dcn = 3;
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F) );
bidx = code == CV_Lab2BGR || code == CV_Lab2LBGR || code == CV_Luv2BGR || code == CV_Luv2LBGR ? 0 : 2;
bool srgb = code == CV_Lab2BGR || code == CV_Lab2RGB || code == CV_Luv2BGR || code == CV_Luv2RGB;
bool lab = code == CV_Lab2BGR || code == CV_Lab2RGB || code == CV_Lab2LBGR || code == CV_Lab2LRGB;
bidx = code == COLOR_Lab2BGR || code == COLOR_Lab2LBGR || code == COLOR_Luv2BGR || code == COLOR_Luv2LBGR ? 0 : 2;
bool srgb = code == COLOR_Lab2BGR || code == COLOR_Lab2RGB || code == COLOR_Luv2BGR || code == COLOR_Luv2RGB;
bool lab = code == COLOR_Lab2BGR || code == COLOR_Lab2RGB || code == COLOR_Lab2LBGR || code == COLOR_Lab2LRGB;
float un, vn;
k.create(format("%s2BGR", lab ? "Lab" : "Luv").c_str(),
@ -10515,13 +10515,15 @@ void cvtMultipliedRGBAtoRGBA(const uchar * src_data, size_t src_step,
//
// Helper functions
//
namespace {
using namespace cv;
inline bool isHSV(int code)
{
switch(code)
{
case CV_HSV2BGR: case CV_HSV2RGB: case CV_HSV2BGR_FULL: case CV_HSV2RGB_FULL:
case CV_BGR2HSV: case CV_RGB2HSV: case CV_BGR2HSV_FULL: case CV_RGB2HSV_FULL:
case COLOR_HSV2BGR: case COLOR_HSV2RGB: case COLOR_HSV2BGR_FULL: case COLOR_HSV2RGB_FULL:
case COLOR_BGR2HSV: case COLOR_RGB2HSV: case COLOR_BGR2HSV_FULL: case COLOR_RGB2HSV_FULL:
return true;
default:
return false;
@ -10532,8 +10534,8 @@ inline bool isLab(int code)
{
switch (code)
{
case CV_Lab2BGR: case CV_Lab2RGB: case CV_Lab2LBGR: case CV_Lab2LRGB:
case CV_BGR2Lab: case CV_RGB2Lab: case CV_LBGR2Lab: case CV_LRGB2Lab:
case COLOR_Lab2BGR: case COLOR_Lab2RGB: case COLOR_Lab2LBGR: case COLOR_Lab2LRGB:
case COLOR_BGR2Lab: case COLOR_RGB2Lab: case COLOR_LBGR2Lab: case COLOR_LRGB2Lab:
return true;
default:
return false;
@ -10544,8 +10546,8 @@ inline bool issRGB(int code)
{
switch (code)
{
case CV_BGR2Lab: case CV_RGB2Lab: case CV_BGR2Luv: case CV_RGB2Luv:
case CV_Lab2BGR: case CV_Lab2RGB: case CV_Luv2BGR: case CV_Luv2RGB:
case COLOR_BGR2Lab: case COLOR_RGB2Lab: case COLOR_BGR2Luv: case COLOR_RGB2Luv:
case COLOR_Lab2BGR: case COLOR_Lab2RGB: case COLOR_Luv2BGR: case COLOR_Luv2RGB:
return true;
default:
return false;
@ -10556,22 +10558,22 @@ inline bool swapBlue(int code)
{
switch (code)
{
case CV_BGR2BGRA: case CV_BGRA2BGR:
case CV_BGR2BGR565: case CV_BGR2BGR555: case CV_BGRA2BGR565: case CV_BGRA2BGR555:
case CV_BGR5652BGR: case CV_BGR5552BGR: case CV_BGR5652BGRA: case CV_BGR5552BGRA:
case CV_BGR2GRAY: case CV_BGRA2GRAY:
case CV_BGR2YCrCb: case CV_BGR2YUV:
case CV_YCrCb2BGR: case CV_YUV2BGR:
case CV_BGR2XYZ: case CV_XYZ2BGR:
case CV_BGR2HSV: case CV_BGR2HLS: case CV_BGR2HSV_FULL: case CV_BGR2HLS_FULL:
case CV_YUV2BGR_YV12: case CV_YUV2BGRA_YV12: case CV_YUV2BGR_IYUV: case CV_YUV2BGRA_IYUV:
case CV_YUV2BGR_NV21: case CV_YUV2BGRA_NV21: case CV_YUV2BGR_NV12: case CV_YUV2BGRA_NV12:
case CV_Lab2BGR: case CV_Luv2BGR: case CV_Lab2LBGR: case CV_Luv2LBGR:
case CV_BGR2Lab: case CV_BGR2Luv: case CV_LBGR2Lab: case CV_LBGR2Luv:
case CV_HSV2BGR: case CV_HLS2BGR: case CV_HSV2BGR_FULL: case CV_HLS2BGR_FULL:
case CV_YUV2BGR_UYVY: case CV_YUV2BGRA_UYVY: case CV_YUV2BGR_YUY2:
case CV_YUV2BGRA_YUY2: case CV_YUV2BGR_YVYU: case CV_YUV2BGRA_YVYU:
case CV_BGR2YUV_IYUV: case CV_BGRA2YUV_IYUV: case CV_BGR2YUV_YV12: case CV_BGRA2YUV_YV12:
case COLOR_BGR2BGRA: case COLOR_BGRA2BGR:
case COLOR_BGR2BGR565: case COLOR_BGR2BGR555: case COLOR_BGRA2BGR565: case COLOR_BGRA2BGR555:
case COLOR_BGR5652BGR: case COLOR_BGR5552BGR: case COLOR_BGR5652BGRA: case COLOR_BGR5552BGRA:
case COLOR_BGR2GRAY: case COLOR_BGRA2GRAY:
case COLOR_BGR2YCrCb: case COLOR_BGR2YUV:
case COLOR_YCrCb2BGR: case COLOR_YUV2BGR:
case COLOR_BGR2XYZ: case COLOR_XYZ2BGR:
case COLOR_BGR2HSV: case COLOR_BGR2HLS: case COLOR_BGR2HSV_FULL: case COLOR_BGR2HLS_FULL:
case COLOR_YUV2BGR_YV12: case COLOR_YUV2BGRA_YV12: case COLOR_YUV2BGR_IYUV: case COLOR_YUV2BGRA_IYUV:
case COLOR_YUV2BGR_NV21: case COLOR_YUV2BGRA_NV21: case COLOR_YUV2BGR_NV12: case COLOR_YUV2BGRA_NV12:
case COLOR_Lab2BGR: case COLOR_Luv2BGR: case COLOR_Lab2LBGR: case COLOR_Luv2LBGR:
case COLOR_BGR2Lab: case COLOR_BGR2Luv: case COLOR_LBGR2Lab: case COLOR_LBGR2Luv:
case COLOR_HSV2BGR: case COLOR_HLS2BGR: case COLOR_HSV2BGR_FULL: case COLOR_HLS2BGR_FULL:
case COLOR_YUV2BGR_UYVY: case COLOR_YUV2BGRA_UYVY: case COLOR_YUV2BGR_YUY2:
case COLOR_YUV2BGRA_YUY2: case COLOR_YUV2BGR_YVYU: case COLOR_YUV2BGRA_YVYU:
case COLOR_BGR2YUV_IYUV: case COLOR_BGRA2YUV_IYUV: case COLOR_BGR2YUV_YV12: case COLOR_BGRA2YUV_YV12:
return false;
default:
return true;
@ -10582,14 +10584,16 @@ inline bool isFullRange(int code)
{
switch (code)
{
case CV_BGR2HSV_FULL: case CV_RGB2HSV_FULL: case CV_BGR2HLS_FULL: case CV_RGB2HLS_FULL:
case CV_HSV2BGR_FULL: case CV_HSV2RGB_FULL: case CV_HLS2BGR_FULL: case CV_HLS2RGB_FULL:
case COLOR_BGR2HSV_FULL: case COLOR_RGB2HSV_FULL: case COLOR_BGR2HLS_FULL: case COLOR_RGB2HLS_FULL:
case COLOR_HSV2BGR_FULL: case COLOR_HSV2RGB_FULL: case COLOR_HLS2BGR_FULL: case COLOR_HLS2RGB_FULL:
return true;
default:
return false;
}
}
} // namespace::
//////////////////////////////////////////////////////////////////////////////////////////
// The main function //
//////////////////////////////////////////////////////////////////////////////////////////
@ -10601,7 +10605,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
int stype = _src.type();
int scn = CV_MAT_CN(stype), depth = CV_MAT_DEPTH(stype), uidx, gbits, ycn;
CV_OCL_RUN( _src.dims() <= 2 && _dst.isUMat() && !(depth == CV_8U && (code == CV_Luv2BGR || code == CV_Luv2RGB)),
CV_OCL_RUN( _src.dims() <= 2 && _dst.isUMat() && !(depth == CV_8U && (code == COLOR_Luv2BGR || code == COLOR_Luv2RGB)),
ocl_cvtColor(_src, _dst, code, dcn) )
Mat src, dst;
@ -10614,40 +10618,40 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
switch( code )
{
case CV_BGR2BGRA: case CV_RGB2BGRA: case CV_BGRA2BGR:
case CV_RGBA2BGR: case CV_RGB2BGR: case CV_BGRA2RGBA:
case COLOR_BGR2BGRA: case COLOR_RGB2BGRA: case COLOR_BGRA2BGR:
case COLOR_RGBA2BGR: case COLOR_RGB2BGR: case COLOR_BGRA2RGBA:
CV_Assert( scn == 3 || scn == 4 );
dcn = code == CV_BGR2BGRA || code == CV_RGB2BGRA || code == CV_BGRA2RGBA ? 4 : 3;
dcn = code == COLOR_BGR2BGRA || code == COLOR_RGB2BGRA || code == COLOR_BGRA2RGBA ? 4 : 3;
_dst.create( sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtBGRtoBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
depth, scn, dcn, swapBlue(code));
break;
case CV_BGR2BGR565: case CV_BGR2BGR555: case CV_RGB2BGR565: case CV_RGB2BGR555:
case CV_BGRA2BGR565: case CV_BGRA2BGR555: case CV_RGBA2BGR565: case CV_RGBA2BGR555:
case COLOR_BGR2BGR565: case COLOR_BGR2BGR555: case COLOR_RGB2BGR565: case COLOR_RGB2BGR555:
case COLOR_BGRA2BGR565: case COLOR_BGRA2BGR555: case COLOR_RGBA2BGR565: case COLOR_RGBA2BGR555:
CV_Assert( (scn == 3 || scn == 4) && depth == CV_8U );
gbits = code == CV_BGR2BGR565 || code == CV_RGB2BGR565 ||
code == CV_BGRA2BGR565 || code == CV_RGBA2BGR565 ? 6 : 5;
gbits = code == COLOR_BGR2BGR565 || code == COLOR_RGB2BGR565 ||
code == COLOR_BGRA2BGR565 || code == COLOR_RGBA2BGR565 ? 6 : 5;
_dst.create(sz, CV_8UC2);
dst = _dst.getMat();
hal::cvtBGRtoBGR5x5(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
scn, swapBlue(code), gbits);
break;
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;
case COLOR_BGR5652BGR: case COLOR_BGR5552BGR: case COLOR_BGR5652RGB: case COLOR_BGR5552RGB:
case COLOR_BGR5652BGRA: case COLOR_BGR5552BGRA: case COLOR_BGR5652RGBA: case COLOR_BGR5552RGBA:
if(dcn <= 0) dcn = (code==COLOR_BGR5652BGRA || code==COLOR_BGR5552BGRA || code==COLOR_BGR5652RGBA || code==COLOR_BGR5552RGBA) ? 4 : 3;
CV_Assert( (dcn == 3 || dcn == 4) && scn == 2 && depth == CV_8U );
gbits = code == CV_BGR5652BGR || code == CV_BGR5652RGB ||
code == CV_BGR5652BGRA || code == CV_BGR5652RGBA ? 6 : 5;
gbits = code == COLOR_BGR5652BGR || code == COLOR_BGR5652RGB ||
code == COLOR_BGR5652BGRA || code == COLOR_BGR5652RGBA ? 6 : 5;
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtBGR5x5toBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
dcn, swapBlue(code), gbits);
break;
case CV_BGR2GRAY: case CV_BGRA2GRAY: case CV_RGB2GRAY: case CV_RGBA2GRAY:
case COLOR_BGR2GRAY: case COLOR_BGRA2GRAY: case COLOR_RGB2GRAY: case COLOR_RGBA2GRAY:
CV_Assert( scn == 3 || scn == 4 );
_dst.create(sz, CV_MAKETYPE(depth, 1));
dst = _dst.getMat();
@ -10655,57 +10659,57 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth, scn, swapBlue(code));
break;
case CV_BGR5652GRAY: case CV_BGR5552GRAY:
case COLOR_BGR5652GRAY: case COLOR_BGR5552GRAY:
CV_Assert( scn == 2 && depth == CV_8U );
gbits = code == CV_BGR5652GRAY ? 6 : 5;
gbits = code == COLOR_BGR5652GRAY ? 6 : 5;
_dst.create(sz, CV_8UC1);
dst = _dst.getMat();
hal::cvtBGR5x5toGray(src.data, src.step, dst.data, dst.step, src.cols, src.rows, gbits);
break;
case CV_GRAY2BGR: case CV_GRAY2BGRA:
if( dcn <= 0 ) dcn = (code==CV_GRAY2BGRA) ? 4 : 3;
case COLOR_GRAY2BGR: case COLOR_GRAY2BGRA:
if( dcn <= 0 ) dcn = (code==COLOR_GRAY2BGRA) ? 4 : 3;
CV_Assert( scn == 1 && (dcn == 3 || dcn == 4));
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtGraytoBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows, depth, dcn);
break;
case CV_GRAY2BGR565: case CV_GRAY2BGR555:
case COLOR_GRAY2BGR565: case COLOR_GRAY2BGR555:
CV_Assert( scn == 1 && depth == CV_8U );
gbits = code == CV_GRAY2BGR565 ? 6 : 5;
gbits = code == COLOR_GRAY2BGR565 ? 6 : 5;
_dst.create(sz, CV_8UC2);
dst = _dst.getMat();
hal::cvtGraytoBGR5x5(src.data, src.step, dst.data, dst.step, src.cols, src.rows, gbits);
break;
case CV_BGR2YCrCb: case CV_RGB2YCrCb:
case CV_BGR2YUV: case CV_RGB2YUV:
case COLOR_BGR2YCrCb: case COLOR_RGB2YCrCb:
case COLOR_BGR2YUV: case COLOR_RGB2YUV:
CV_Assert( scn == 3 || scn == 4 );
_dst.create(sz, CV_MAKETYPE(depth, 3));
dst = _dst.getMat();
hal::cvtBGRtoYUV(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
depth, scn, swapBlue(code), code == CV_BGR2YCrCb || code == CV_RGB2YCrCb);
depth, scn, swapBlue(code), code == COLOR_BGR2YCrCb || code == COLOR_RGB2YCrCb);
break;
case CV_YCrCb2BGR: case CV_YCrCb2RGB:
case CV_YUV2BGR: case CV_YUV2RGB:
case COLOR_YCrCb2BGR: case COLOR_YCrCb2RGB:
case COLOR_YUV2BGR: case COLOR_YUV2RGB:
if( dcn <= 0 ) dcn = 3;
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtYUVtoBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
depth, dcn, swapBlue(code), code == CV_YCrCb2BGR || code == CV_YCrCb2RGB);
depth, dcn, swapBlue(code), code == COLOR_YCrCb2BGR || code == COLOR_YCrCb2RGB);
break;
case CV_BGR2XYZ: case CV_RGB2XYZ:
case COLOR_BGR2XYZ: case COLOR_RGB2XYZ:
CV_Assert( scn == 3 || scn == 4 );
_dst.create(sz, CV_MAKETYPE(depth, 3));
dst = _dst.getMat();
hal::cvtBGRtoXYZ(src.data, src.step, dst.data, dst.step, src.cols, src.rows, depth, scn, swapBlue(code));
break;
case CV_XYZ2BGR: case CV_XYZ2RGB:
case COLOR_XYZ2BGR: case COLOR_XYZ2RGB:
if( dcn <= 0 ) dcn = 3;
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
@ -10713,8 +10717,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
hal::cvtXYZtoBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows, depth, dcn, swapBlue(code));
break;
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:
case COLOR_BGR2HSV: case COLOR_RGB2HSV: case COLOR_BGR2HSV_FULL: case COLOR_RGB2HSV_FULL:
case COLOR_BGR2HLS: case COLOR_RGB2HLS: case COLOR_BGR2HLS_FULL: case COLOR_RGB2HLS_FULL:
CV_Assert( (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) );
_dst.create(sz, CV_MAKETYPE(depth, 3));
dst = _dst.getMat();
@ -10722,8 +10726,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth, scn, swapBlue(code), isFullRange(code), isHSV(code));
break;
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:
case COLOR_HSV2BGR: case COLOR_HSV2RGB: case COLOR_HSV2BGR_FULL: case COLOR_HSV2RGB_FULL:
case COLOR_HLS2BGR: case COLOR_HLS2RGB: case COLOR_HLS2BGR_FULL: case COLOR_HLS2RGB_FULL:
if( dcn <= 0 ) dcn = 3;
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F) );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
@ -10732,8 +10736,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth, dcn, swapBlue(code), isFullRange(code), isHSV(code));
break;
case CV_BGR2Lab: case CV_RGB2Lab: case CV_LBGR2Lab: case CV_LRGB2Lab:
case CV_BGR2Luv: case CV_RGB2Luv: case CV_LBGR2Luv: case CV_LRGB2Luv:
case COLOR_BGR2Lab: case COLOR_RGB2Lab: case COLOR_LBGR2Lab: case COLOR_LRGB2Lab:
case COLOR_BGR2Luv: case COLOR_RGB2Luv: case COLOR_LBGR2Luv: case COLOR_LRGB2Luv:
CV_Assert( (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) );
_dst.create(sz, CV_MAKETYPE(depth, 3));
dst = _dst.getMat();
@ -10741,8 +10745,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth, scn, swapBlue(code), isLab(code), issRGB(code));
break;
case CV_Lab2BGR: case CV_Lab2RGB: case CV_Lab2LBGR: case CV_Lab2LRGB:
case CV_Luv2BGR: case CV_Luv2RGB: case CV_Luv2LBGR: case CV_Luv2LRGB:
case COLOR_Lab2BGR: case COLOR_Lab2RGB: case COLOR_Lab2LBGR: case COLOR_Lab2LRGB:
case COLOR_Luv2BGR: case COLOR_Luv2RGB: case COLOR_Luv2LBGR: case COLOR_Luv2LRGB:
if( dcn <= 0 ) dcn = 3;
CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F) );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
@ -10751,20 +10755,20 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth, dcn, swapBlue(code), isLab(code), issRGB(code));
break;
case CV_BayerBG2GRAY: case CV_BayerGB2GRAY: case CV_BayerRG2GRAY: case CV_BayerGR2GRAY:
case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:
case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG:
case CV_BayerBG2BGR_EA: case CV_BayerGB2BGR_EA: case CV_BayerRG2BGR_EA: case CV_BayerGR2BGR_EA:
case CV_BayerBG2BGRA: case CV_BayerGB2BGRA: case CV_BayerRG2BGRA: case CV_BayerGR2BGRA:
case COLOR_BayerBG2GRAY: case COLOR_BayerGB2GRAY: case COLOR_BayerRG2GRAY: case COLOR_BayerGR2GRAY:
case COLOR_BayerBG2BGR: case COLOR_BayerGB2BGR: case COLOR_BayerRG2BGR: case COLOR_BayerGR2BGR:
case COLOR_BayerBG2BGR_VNG: case COLOR_BayerGB2BGR_VNG: case COLOR_BayerRG2BGR_VNG: case COLOR_BayerGR2BGR_VNG:
case COLOR_BayerBG2BGR_EA: case COLOR_BayerGB2BGR_EA: case COLOR_BayerRG2BGR_EA: case COLOR_BayerGR2BGR_EA:
case COLOR_BayerBG2BGRA: case COLOR_BayerGB2BGRA: case COLOR_BayerRG2BGRA: case COLOR_BayerGR2BGRA:
demosaicing(src, _dst, code, dcn);
break;
case CV_YUV2BGR_NV21: case CV_YUV2RGB_NV21: case CV_YUV2BGR_NV12: case CV_YUV2RGB_NV12:
case CV_YUV2BGRA_NV21: case CV_YUV2RGBA_NV21: case CV_YUV2BGRA_NV12: case CV_YUV2RGBA_NV12:
case COLOR_YUV2BGR_NV21: case COLOR_YUV2RGB_NV21: case COLOR_YUV2BGR_NV12: case COLOR_YUV2RGB_NV12:
case COLOR_YUV2BGRA_NV21: case COLOR_YUV2RGBA_NV21: case COLOR_YUV2BGRA_NV12: case COLOR_YUV2RGBA_NV12:
// http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples
// http://www.fourcc.org/yuv.php#NV12 -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
if (dcn <= 0) dcn = (code==CV_YUV420sp2BGRA || code==CV_YUV420sp2RGBA || code==CV_YUV2BGRA_NV12 || code==CV_YUV2RGBA_NV12) ? 4 : 3;
uidx = (code==CV_YUV2BGR_NV21 || code==CV_YUV2BGRA_NV21 || code==CV_YUV2RGB_NV21 || code==CV_YUV2RGBA_NV21) ? 1 : 0;
if (dcn <= 0) dcn = (code==COLOR_YUV420sp2BGRA || code==COLOR_YUV420sp2RGBA || code==COLOR_YUV2BGRA_NV12 || code==COLOR_YUV2RGBA_NV12) ? 4 : 3;
uidx = (code==COLOR_YUV2BGR_NV21 || code==COLOR_YUV2BGRA_NV21 || code==COLOR_YUV2RGB_NV21 || code==COLOR_YUV2RGBA_NV21) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U );
_dst.create(Size(sz.width, sz.height * 2 / 3), CV_MAKETYPE(depth, dcn));
@ -10772,12 +10776,12 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
hal::cvtTwoPlaneYUVtoBGR(src.data, src.step, dst.data, dst.step, dst.cols, dst.rows,
dcn, swapBlue(code), uidx);
break;
case CV_YUV2BGR_YV12: case CV_YUV2RGB_YV12: case CV_YUV2BGRA_YV12: case CV_YUV2RGBA_YV12:
case CV_YUV2BGR_IYUV: case CV_YUV2RGB_IYUV: case CV_YUV2BGRA_IYUV: case CV_YUV2RGBA_IYUV:
case COLOR_YUV2BGR_YV12: case COLOR_YUV2RGB_YV12: case COLOR_YUV2BGRA_YV12: case COLOR_YUV2RGBA_YV12:
case COLOR_YUV2BGR_IYUV: case COLOR_YUV2RGB_IYUV: case COLOR_YUV2BGRA_IYUV: case COLOR_YUV2RGBA_IYUV:
//http://www.fourcc.org/yuv.php#YV12 == yuv420p -> It comprises an NxM Y plane followed by (N/2)x(M/2) V and U planes.
//http://www.fourcc.org/yuv.php#IYUV == I420 -> It comprises an NxN Y plane followed by (N/2)x(N/2) U and V planes
if (dcn <= 0) dcn = (code==CV_YUV2BGRA_YV12 || code==CV_YUV2RGBA_YV12 || code==CV_YUV2RGBA_IYUV || code==CV_YUV2BGRA_IYUV) ? 4 : 3;
uidx = (code==CV_YUV2BGR_YV12 || code==CV_YUV2RGB_YV12 || code==CV_YUV2BGRA_YV12 || code==CV_YUV2RGBA_YV12) ? 1 : 0;
if (dcn <= 0) dcn = (code==COLOR_YUV2BGRA_YV12 || code==COLOR_YUV2RGBA_YV12 || code==COLOR_YUV2RGBA_IYUV || code==COLOR_YUV2BGRA_IYUV) ? 4 : 3;
uidx = (code==COLOR_YUV2BGR_YV12 || code==COLOR_YUV2RGB_YV12 || code==COLOR_YUV2BGRA_YV12 || code==COLOR_YUV2RGBA_YV12) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U );
_dst.create(Size(sz.width, sz.height * 2 / 3), CV_MAKETYPE(depth, dcn));
@ -10786,7 +10790,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
dcn, swapBlue(code), uidx);
break;
case CV_YUV2GRAY_420:
case COLOR_YUV2GRAY_420:
{
if (dcn <= 0) dcn = 1;
@ -10806,10 +10810,10 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
src(Range(0, dstSz.height), Range::all()).copyTo(dst);
}
break;
case CV_RGB2YUV_YV12: case CV_BGR2YUV_YV12: case CV_RGBA2YUV_YV12: case CV_BGRA2YUV_YV12:
case CV_RGB2YUV_IYUV: case CV_BGR2YUV_IYUV: case CV_RGBA2YUV_IYUV: case CV_BGRA2YUV_IYUV:
case COLOR_RGB2YUV_YV12: case COLOR_BGR2YUV_YV12: case COLOR_RGBA2YUV_YV12: case COLOR_BGRA2YUV_YV12:
case COLOR_RGB2YUV_IYUV: case COLOR_BGR2YUV_IYUV: case COLOR_RGBA2YUV_IYUV: case COLOR_BGRA2YUV_IYUV:
if (dcn <= 0) dcn = 1;
uidx = (code == CV_BGR2YUV_IYUV || code == CV_BGRA2YUV_IYUV || code == CV_RGB2YUV_IYUV || code == CV_RGBA2YUV_IYUV) ? 1 : 2;
uidx = (code == COLOR_BGR2YUV_IYUV || code == COLOR_BGRA2YUV_IYUV || code == COLOR_RGB2YUV_IYUV || code == COLOR_RGBA2YUV_IYUV) ? 1 : 2;
CV_Assert( (scn == 3 || scn == 4) && depth == CV_8U );
CV_Assert( dcn == 1 );
CV_Assert( sz.width % 2 == 0 && sz.height % 2 == 0 );
@ -10818,15 +10822,15 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
hal::cvtBGRtoThreePlaneYUV(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
scn, swapBlue(code), uidx);
break;
case CV_YUV2RGB_UYVY: case CV_YUV2BGR_UYVY: case CV_YUV2RGBA_UYVY: case CV_YUV2BGRA_UYVY:
case CV_YUV2RGB_YUY2: case CV_YUV2BGR_YUY2: case CV_YUV2RGB_YVYU: case CV_YUV2BGR_YVYU:
case CV_YUV2RGBA_YUY2: case CV_YUV2BGRA_YUY2: case CV_YUV2RGBA_YVYU: case CV_YUV2BGRA_YVYU:
case COLOR_YUV2RGB_UYVY: case COLOR_YUV2BGR_UYVY: case COLOR_YUV2RGBA_UYVY: case COLOR_YUV2BGRA_UYVY:
case COLOR_YUV2RGB_YUY2: case COLOR_YUV2BGR_YUY2: case COLOR_YUV2RGB_YVYU: case COLOR_YUV2BGR_YVYU:
case COLOR_YUV2RGBA_YUY2: case COLOR_YUV2BGRA_YUY2: case COLOR_YUV2RGBA_YVYU: case COLOR_YUV2BGRA_YVYU:
//http://www.fourcc.org/yuv.php#UYVY
//http://www.fourcc.org/yuv.php#YUY2
//http://www.fourcc.org/yuv.php#YVYU
if (dcn <= 0) dcn = (code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2RGBA_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 4 : 3;
ycn = (code==CV_YUV2RGB_UYVY || code==CV_YUV2BGR_UYVY || code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY) ? 1 : 0;
uidx = (code==CV_YUV2RGB_YVYU || code==CV_YUV2BGR_YVYU || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 1 : 0;
if (dcn <= 0) dcn = (code==COLOR_YUV2RGBA_UYVY || code==COLOR_YUV2BGRA_UYVY || code==COLOR_YUV2RGBA_YUY2 || code==COLOR_YUV2BGRA_YUY2 || code==COLOR_YUV2RGBA_YVYU || code==COLOR_YUV2BGRA_YVYU) ? 4 : 3;
ycn = (code==COLOR_YUV2RGB_UYVY || code==COLOR_YUV2BGR_UYVY || code==COLOR_YUV2RGBA_UYVY || code==COLOR_YUV2BGRA_UYVY) ? 1 : 0;
uidx = (code==COLOR_YUV2RGB_YVYU || code==COLOR_YUV2BGR_YVYU || code==COLOR_YUV2RGBA_YVYU || code==COLOR_YUV2BGRA_YVYU) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( scn == 2 && depth == CV_8U );
_dst.create(sz, CV_8UC(dcn));
@ -10834,7 +10838,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
hal::cvtOnePlaneYUVtoBGR(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
dcn, swapBlue(code), uidx, ycn);
break;
case CV_YUV2GRAY_UYVY: case CV_YUV2GRAY_YUY2:
case COLOR_YUV2GRAY_UYVY: case COLOR_YUV2GRAY_YUY2:
{
if (dcn <= 0) dcn = 1;
@ -10842,17 +10846,17 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
CV_Assert( scn == 2 && depth == CV_8U );
src.release(); // T-API datarace fixup
extractChannel(_src, _dst, code == CV_YUV2GRAY_UYVY ? 1 : 0);
extractChannel(_src, _dst, code == COLOR_YUV2GRAY_UYVY ? 1 : 0);
}
break;
case CV_RGBA2mRGBA:
case COLOR_RGBA2mRGBA:
if (dcn <= 0) dcn = 4;
CV_Assert( scn == 4 && dcn == 4 && depth == CV_8U );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtRGBAtoMultipliedRGBA(src.data, src.step, dst.data, dst.step, src.cols, src.rows);
break;
case CV_mRGBA2RGBA:
case COLOR_mRGBA2RGBA:
if (dcn <= 0) dcn = 4;
CV_Assert( scn == 4 && dcn == 4 && depth == CV_8U );
_dst.create(sz, CV_MAKETYPE(depth, dcn));

View File

@ -185,7 +185,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
}
}
int bt_pix0 = (int)img.elemSize(), bt_pix = bt_pix0;
size_t bt_pix0 = img.elemSize(), bt_pix = bt_pix0;
size_t istep = img.step;
int dx = pt2.x - pt1.x;
@ -230,7 +230,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
plusDelta = dx + dx;
minusDelta = -(dy + dy);
plusStep = (int)istep;
minusStep = bt_pix;
minusStep = (int)bt_pix;
count = dx + 1;
}
else /* connectivity == 4 */
@ -240,14 +240,14 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
err = 0;
plusDelta = (dx + dx) + (dy + dy);
minusDelta = -(dy + dy);
plusStep = (int)istep - bt_pix;
minusStep = bt_pix;
plusStep = (int)(istep - bt_pix);
minusStep = (int)bt_pix;
count = dx + dy + 1;
}
this->ptr0 = img.ptr();
this->step = (int)img.step;
this->elemSize = bt_pix0;
this->elemSize = (int)bt_pix0;
}
static void

View File

@ -567,10 +567,13 @@ static int icvInitEMD( const float* signature1, int size1,
static int icvFindBasicVariables( float **cost, char **is_x,
CvNode1D * u, CvNode1D * v, int ssize, int dsize )
{
int i, j, found;
int i, j;
int u_cfound, v_cfound;
CvNode1D u0_head, u1_head, *cur_u, *prev_u;
CvNode1D v0_head, v1_head, *cur_v, *prev_v;
bool found;
CV_Assert(u != 0 && v != 0);
/* initialize the rows list (u) and the columns list (v) */
u0_head.next = u;
@ -599,13 +602,14 @@ static int icvFindBasicVariables( float **cost, char **is_x,
u_cfound = v_cfound = 0;
while( u_cfound < ssize || v_cfound < dsize )
{
found = 0;
found = false;
if( v_cfound < dsize )
{
/* loop over all marked columns */
prev_v = &v1_head;
for( found |= (cur_v = v1_head.next) != 0; cur_v != 0; cur_v = cur_v->next )
cur_v = v1_head.next;
found = found || (cur_v != 0);
for( ; cur_v != 0; cur_v = cur_v->next )
{
float cur_v_val = cur_v->val;
@ -640,7 +644,9 @@ static int icvFindBasicVariables( float **cost, char **is_x,
{
/* loop over all marked rows */
prev_u = &u1_head;
for( found |= (cur_u = u1_head.next) != 0; cur_u != 0; cur_u = cur_u->next )
cur_u = u1_head.next;
found = found || (cur_u != 0);
for( ; cur_u != 0; cur_u = cur_u->next )
{
float cur_u_val = cur_u->val;
float *_cost;

View File

@ -2077,23 +2077,23 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op,
erode( src, dst, kernel, anchor, iterations, borderType, borderValue );
dilate( dst, dst, kernel, anchor, iterations, borderType, borderValue );
break;
case CV_MOP_CLOSE:
case MORPH_CLOSE:
dilate( src, dst, kernel, anchor, iterations, borderType, borderValue );
erode( dst, dst, kernel, anchor, iterations, borderType, borderValue );
break;
case CV_MOP_GRADIENT:
case MORPH_GRADIENT:
erode( src, temp, kernel, anchor, iterations, borderType, borderValue );
dilate( src, dst, kernel, anchor, iterations, borderType, borderValue );
dst -= temp;
break;
case CV_MOP_TOPHAT:
case MORPH_TOPHAT:
if( src.data != dst.data )
temp = dst;
erode( src, temp, kernel, anchor, iterations, borderType, borderValue );
dilate( temp, temp, kernel, anchor, iterations, borderType, borderValue );
dst = src - temp;
break;
case CV_MOP_BLACKHAT:
case MORPH_BLACKHAT:
if( src.data != dst.data )
temp = dst;
dilate( src, temp, kernel, anchor, iterations, borderType, borderValue );

View File

@ -2556,7 +2556,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
break;
}
}
assert( k < 16 );
CV_Assert( k < 16 );
/* Update corresponding histogram segment */
if ( luc[c][k] <= j-r )
@ -2593,7 +2593,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
break;
}
}
assert( b < 16 );
CV_Assert( b < 16 );
}
}
else
@ -2619,7 +2619,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
break;
}
}
assert( k < 16 );
CV_Assert( k < 16 );
/* Update corresponding histogram segment */
if ( luc[c][k] <= j-r )
@ -2656,7 +2656,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
break;
}
}
assert( b < 16 );
CV_Assert( b < 16 );
}
}
}

View File

@ -990,7 +990,7 @@ getThreshVal_Otsu_8u( const Mat& _src )
}
#ifdef HAVE_IPP
unsigned char thresh;
unsigned char thresh = 0;
CV_IPP_RUN_FAST(ipp_getThreshVal_Otsu_8u(_src.ptr(), step, size, thresh), thresh);
#endif

View File

@ -573,7 +573,9 @@ Mat LogisticRegressionImpl::remap_labels(const Mat& _labels_i, const map<int, in
for(int i =0;i<labels.rows;i++)
{
new_labels.at<int>(i,0) = lmap.find(labels.at<int>(i,0))->second;
map<int, int>::const_iterator val = lmap.find(labels.at<int>(i,0));
CV_Assert(val != lmap.end());
new_labels.at<int>(i,0) = val->second;
}
return new_labels;
}

View File

@ -87,9 +87,7 @@ typedef struct CvHidHaarStageClassifier
typedef struct CvHidHaarClassifierCascade
{
int count;
int isStumpBased;
int has_tilted_features;
int is_tree;
double inv_window_area;
CvMat sum, sqsum, tilted;
CvHidHaarStageClassifier* stage_classifier;
@ -97,6 +95,8 @@ typedef struct CvHidHaarClassifierCascade
sumtype *p0, *p1, *p2, *p3;
void** ipp_stages;
bool is_tree;
bool isStumpBased;
} CvHidHaarClassifierCascade;
@ -167,7 +167,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
CvHidHaarClassifier* haar_classifier_ptr;
CvHidHaarTreeNode* haar_node_ptr;
CvSize orig_window_size;
int has_tilted_features = 0;
bool has_tilted_features = false;
int max_count = 0;
if( !CV_IS_HAAR_CLASSIFIER(cascade) )
@ -214,7 +214,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
{
CvRect r = classifier->haar_feature[l].rect[k].r;
int tilted = classifier->haar_feature[l].tilted;
has_tilted_features |= tilted != 0;
has_tilted_features = has_tilted_features | (tilted != 0);
if( r.width < 0 || r.height < 0 || r.y < 0 ||
r.x + r.width > orig_window_size.width
||
@ -251,9 +251,9 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
haar_classifier_ptr = (CvHidHaarClassifier*)(out->stage_classifier + cascade->count);
haar_node_ptr = (CvHidHaarTreeNode*)(haar_classifier_ptr + total_classifiers);
out->isStumpBased = 1;
out->isStumpBased = true;
out->has_tilted_features = has_tilted_features;
out->is_tree = 0;
out->is_tree = false;
/* initialize internal representation */
for( i = 0; i < cascade->count; i++ )
@ -274,7 +274,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
hid_stage_classifier->child = (stage_classifier->child == -1)
? NULL : out->stage_classifier + stage_classifier->child;
out->is_tree |= hid_stage_classifier->next != NULL;
out->is_tree = out->is_tree || (hid_stage_classifier->next != NULL);
for( j = 0; j < stage_classifier->count; j++ )
{
@ -308,7 +308,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
haar_node_ptr =
(CvHidHaarTreeNode*)cvAlignPtr(alpha_ptr+node_count+1, sizeof(void*));
out->isStumpBased &= node_count == 1;
out->isStumpBased = out->isStumpBased && (node_count == 1);
}
}

View File

@ -79,6 +79,10 @@ CvHeapElem;
class CvPriorityQueueFloat
{
private:
CvPriorityQueueFloat(const CvPriorityQueueFloat & ); // copy disabled
CvPriorityQueueFloat& operator=(const CvPriorityQueueFloat &); // assign disabled
protected:
CvHeapElem *mem,*empty,*head,*tail;
int num,in;

View File

@ -59,7 +59,7 @@ struct CV_EXPORTS CameraParams
{
CameraParams();
CameraParams(const CameraParams& other);
const CameraParams& operator =(const CameraParams& other);
CameraParams& operator =(const CameraParams& other);
Mat K() const;
double focal; // Focal length

View File

@ -207,7 +207,7 @@ struct CV_EXPORTS MatchesInfo
{
MatchesInfo();
MatchesInfo(const MatchesInfo &other);
const MatchesInfo& operator =(const MatchesInfo &other);
MatchesInfo& operator =(const MatchesInfo &other);
int src_img_idx, dst_img_idx; //!< Images indices (optional)
std::vector<DMatch> matches;

View File

@ -50,7 +50,7 @@ CameraParams::CameraParams() : focal(1), aspect(1), ppx(0), ppy(0),
CameraParams::CameraParams(const CameraParams &other) { *this = other; }
const CameraParams& CameraParams::operator =(const CameraParams &other)
CameraParams& CameraParams::operator =(const CameraParams &other)
{
focal = other.focal;
ppx = other.ppx;

View File

@ -625,7 +625,7 @@ MatchesInfo::MatchesInfo() : src_img_idx(-1), dst_img_idx(-1), num_inliers(0), c
MatchesInfo::MatchesInfo(const MatchesInfo &other) { *this = other; }
const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
{
src_img_idx = other.src_img_idx;
dst_img_idx = other.dst_img_idx;

View File

@ -1047,7 +1047,16 @@ void DpSeamFinder::updateLabelsUsingSeam(
for (std::map<int, int>::iterator itr = connect2.begin(); itr != connect2.end(); ++itr)
{
double len = static_cast<double>(contours_[comp1].size());
isAdjComp[itr->first] = itr->second / len > 0.05 && connectOther.find(itr->first)->second / len < 0.1;
int res = 0;
if (itr->second / len > 0.05)
{
std::map<int, int>::const_iterator sub = connectOther.find(itr->first);
if (sub != connectOther.end() && (sub->second / len < 0.1))
{
res = 1;
}
}
isAdjComp[itr->first] = res;
}
// update labels