1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2018-11-02 05:31:07 +00:00
70 changed files with 2344 additions and 2076 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+22 -1
View File
@@ -118,9 +118,10 @@ v = f_y*y'' + c_y
tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
coefficients. Higher-order coefficients are not considered in OpenCV.
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$) and pincushion distortion (typically \f$ k_1 < 0 \f$).
The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
![](pics/distortion_examples.png)
![](pics/distortion_examples2.png)
In some cases the image sensor may be tilted in order to focus an oblique plane in front of the
camera (Scheimpfug condition). This can be useful for particle image velocimetry (PIV) or
@@ -899,6 +900,26 @@ found, or as colored corners connected with lines if the board was found.
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
InputArray corners, bool patternWasFound );
/** @brief Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP
@param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
@param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
\f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
@param distCoeffs Input vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements. If the vector is empty, the zero distortion coefficients are assumed.
@param rvec Rotation vector (see @ref Rodrigues ) that, together with tvec , brings points from
the model coordinate system to the camera coordinate system.
@param tvec Translation vector.
@param length Length of the painted axes in the same unit than tvec (usually in meters).
@param thickness Line thickness of the painted axes.
This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
OX is drawn in red, OY in green and OZ in blue.
*/
CV_EXPORTS_W void drawFrameAxes(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
InputArray rvec, InputArray tvec, float length, int thickness=3);
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
{
CV_WRAP CirclesGridFinderParameters();
+27
View File
@@ -52,6 +52,33 @@
namespace cv
{
void drawFrameAxes(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
InputArray rvec, InputArray tvec, float length, int thickness)
{
CV_INSTRUMENT_REGION();
int type = image.type();
int cn = CV_MAT_CN(type);
CV_CheckType(type, cn == 1 || cn == 3 || cn == 4,
"Number of channels must be 1, 3 or 4" );
CV_Assert(image.getMat().total() > 0);
CV_Assert(length > 0);
// project axes points
vector<Point3f> axesPoints;
axesPoints.push_back(Point3f(0, 0, 0));
axesPoints.push_back(Point3f(length, 0, 0));
axesPoints.push_back(Point3f(0, length, 0));
axesPoints.push_back(Point3f(0, 0, length));
vector<Point2f> imagePoints;
projectPoints(axesPoints, rvec, tvec, cameraMatrix, distCoeffs, imagePoints);
// draw axes lines
line(image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), thickness);
line(image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), thickness);
line(image, imagePoints[0], imagePoints[3], Scalar(255, 0, 0), thickness);
}
bool solvePnP( InputArray _opoints, InputArray _ipoints,
InputArray _cameraMatrix, InputArray _distCoeffs,
+1 -1
View File
@@ -3,7 +3,7 @@ Introduction {#intro}
OpenCV (Open Source Computer Vision Library: <http://opencv.org>) is an open-source BSD-licensed
library that includes several hundreds of computer vision algorithms. The document describes the
so-called OpenCV 2.x API, which is essentially a C++ API, as opposite to the C-based OpenCV 1.x API.
so-called OpenCV 2.x API, which is essentially a C++ API, as opposed to the C-based OpenCV 1.x API.
The latter is described in opencv1x.pdf.
OpenCV has a modular structure, which means that the package includes several shared or static
@@ -2505,7 +2505,7 @@ inline void v_pack_store(float16_t* ptr, const v_float32x8& a)
_mm_storeu_si128((__m128i*)ptr, ah);
}
inline void v256_cleanup() { _mm256_zeroupper(); }
inline void v256_cleanup() { _mm256_zeroall(); }
//! @name Check SIMD256 support
//! @{
@@ -681,6 +681,18 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::reshape(int cn, int newndims, const int* newsz)
//
// javadoc: Mat::reshape(cn, newshape)
public Mat reshape(int cn, int[] newshape)
{
Mat retVal = new Mat(n_reshape_1(nativeObj, cn, newshape.length, newshape));
return retVal;
}
//
// C++: Mat Mat::row(int y)
//
@@ -794,6 +806,18 @@ public class Mat {
return retVal;
}
//
// C++: int Mat::size(int i)
//
// javadoc: Mat::size(int i)
public int size(int i)
{
int retVal = n_size_i(nativeObj, i);
return retVal;
}
//
// C++: size_t Mat::step1(int i = 0)
//
@@ -1271,6 +1295,9 @@ public class Mat {
private static native long n_reshape(long nativeObj, int cn);
// C++: Mat Mat::reshape(int cn, int newndims, const int* newsz)
private static native long n_reshape_1(long nativeObj, int cn, int newndims, int[] newsz);
// C++: Mat Mat::row(int y)
private static native long n_row(long nativeObj, int y);
@@ -1294,6 +1321,9 @@ public class Mat {
// C++: Size Mat::size()
private static native double[] n_size(long nativeObj);
// C++: int Mat::size(int i)
private static native int n_size_i(long nativeObj, int i);
// C++: size_t Mat::step1(int i = 0)
private static native long n_step1(long nativeObj, int i);
+13
View File
@@ -817,6 +817,19 @@ public class MatTest extends OpenCVTestCase {
assertMatEqual(truth, dst);
}
public void testReshapeIntIntArray() {
Mat src = new Mat(6, 5, CvType.CV_8UC3, new Scalar(0));
assertEquals(2, src.dims());
assertEquals(src.rows(), src.size(0));
assertEquals(src.cols(), src.size(1));
int[] newShape = {1, src.channels() * src.cols(), 1, src.rows()};
dst = src.reshape(1, newShape);
assertEquals(newShape.length, dst.dims());
for (int i = 0; i < newShape.length; ++i)
assertEquals(newShape[i], dst.size(i));
}
public void testRow() {
Mat row = gray0.row(0);
assertEquals(1, row.rows());
+31 -5
View File
@@ -96,6 +96,8 @@ Mat getMatFromTensor(opencv_onnx::TensorProto& tensor_proto)
for (int i = 0; i < tensor_proto.dims_size(); i++) {
sizes.push_back(tensor_proto.dims(i));
}
if (sizes.empty())
sizes.assign(1, 1);
if (datatype == opencv_onnx::TensorProto_DataType_FLOAT) {
if (!tensor_proto.float_data().empty()) {
@@ -173,11 +175,31 @@ LayerParams ONNXImporter::getLayerParams(const opencv_onnx::NodeProto& node_prot
}
else if(attribute_name == "pads")
{
CV_Assert(attribute_proto.ints_size() == 4);
lp.set("pad_t", saturate_cast<int32_t>(attribute_proto.ints(0)));
lp.set("pad_l", saturate_cast<int32_t>(attribute_proto.ints(1)));
lp.set("pad_b", saturate_cast<int32_t>(attribute_proto.ints(2)));
lp.set("pad_r", saturate_cast<int32_t>(attribute_proto.ints(3)));
if (node_proto.op_type() == "Pad")
{
// Padding layer.
// Paddings are in order begin0, begin1, .. beginN, end0, end1, ..., endN.
// We need to shuffle it to begin0, end0, begin1, end1, ...
CV_Assert(attribute_proto.ints_size() % 2 == 0);
const int dims = attribute_proto.ints_size() / 2;
std::vector<int32_t> paddings;
paddings.reserve(attribute_proto.ints_size());
for (int i = 0; i < dims; ++i)
{
paddings.push_back(attribute_proto.ints(i));
paddings.push_back(attribute_proto.ints(dims + i));
}
lp.set("paddings", DictValue::arrayInt(&paddings[0], paddings.size()));
}
else
{
// Convolution or pooling.
CV_Assert(attribute_proto.ints_size() == 4);
lp.set("pad_t", saturate_cast<int32_t>(attribute_proto.ints(0)));
lp.set("pad_l", saturate_cast<int32_t>(attribute_proto.ints(1)));
lp.set("pad_b", saturate_cast<int32_t>(attribute_proto.ints(2)));
lp.set("pad_r", saturate_cast<int32_t>(attribute_proto.ints(3)));
}
}
else if(attribute_name == "auto_pad")
{
@@ -543,6 +565,10 @@ void ONNXImporter::populateNet(Net dstNet)
replaceLayerParam(layerParams, "shape", "dim");
}
}
else if (layer_type == "Pad")
{
layerParams.type = "Padding";
}
else
{
for (int j = 0; j < node_proto.input_size(); j++) {
+5
View File
@@ -129,6 +129,11 @@ TEST_P(Test_ONNX_layers, Constant)
testONNXModels("constant");
}
TEST_P(Test_ONNX_layers, Padding)
{
testONNXModels("padding");
}
TEST_P(Test_ONNX_layers, MultyInputs)
{
const String model = _tf("models/multy_inputs.onnx");
+2 -2
View File
@@ -581,8 +581,8 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
#if defined (HAVE_WIN32UI) // see window_w32.cpp
#elif defined (HAVE_GTK) // see window_gtk.cpp
#elif defined (HAVE_COCOA) // see window_carbon.cpp
#elif defined (HAVE_CARBON)
#elif defined (HAVE_COCOA) // see window_cocoa.mm
#elif defined (HAVE_CARBON) // see window_carbon.cpp
#elif defined (HAVE_QT) // see window_QT.cpp
#elif defined (WINRT) && !defined (WINRT_8_0) // see window_winrt.cpp
+7 -5
View File
@@ -230,7 +230,7 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
if (oldImageSize.height != imageSize.height || oldImageSize.width != imageSize.width)
{
//Set new view size considering sliders (reserve height and min width)
NSSize scaledImageSize;
NSSize scaledImageSize = imageSize;
if ([[window contentView] respondsToSelector:@selector(convertSizeFromBacking:)])
{
// Only resize for retina displays if the image is bigger than the screen
@@ -239,13 +239,14 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
screenSize.height -= titleBarHeight;
if (imageSize.width > screenSize.width || imageSize.height > screenSize.height)
{
CGFloat fx = screenSize.width/std::max(imageSize.width, (CGFloat)1.f);
CGFloat fy = screenSize.height/std::max(imageSize.height, (CGFloat)1.f);
CGFloat min_f = std::min(fx, fy);
scaledImageSize = [[window contentView] convertSizeFromBacking:imageSize];
scaledImageSize.width = std::min(scaledImageSize.width, min_f*imageSize.width);
scaledImageSize.height = std::min(scaledImageSize.height, min_f*imageSize.height);
}
}
else
{
scaledImageSize = imageSize;
}
NSSize contentSize = vrectOld.size;
contentSize.height = scaledImageSize.height + [window contentView].sliderHeight;
contentSize.width = std::max<int>(scaledImageSize.width, MIN_SLIDER_WIDTH);
@@ -735,6 +736,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
CGFloat heightDiff = (base.height / constraint.height);
CGFloat widthDiff = (base.width / constraint.width);
if (heightDiff == 0) heightDiff = widthDiff;
if (widthDiff == heightDiff) {
return base;
}
+6
View File
@@ -253,6 +253,10 @@ bool TiffDecoder::readHeader()
int wanted_channels = normalizeChannelsNumber(ncn);
switch(bpp)
{
case 1:
m_type = CV_MAKETYPE(CV_8U, photometric > 1 ? wanted_channels : 1);
result = true;
break;
case 8:
m_type = CV_MAKETYPE(CV_8U, photometric > 1 ? wanted_channels : 1);
result = true;
@@ -269,6 +273,8 @@ bool TiffDecoder::readHeader()
m_type = CV_MAKETYPE(CV_64F, photometric > 1 ? 3 : 1);
result = true;
break;
default:
CV_Error(cv::Error::StsError, "Invalid bitsperpixel value read from TIFF header! Must be 1, 8, 16, 32 or 64.");
}
}
}
+1 -1
View File
@@ -266,7 +266,7 @@ bool WebPEncoder::write(const Mat& img, const std::vector<int>& params)
if (channels == 1)
{
cvtColor(*image, temp, CV_GRAY2BGR);
cvtColor(*image, temp, COLOR_GRAY2BGR);
image = &temp;
channels = 3;
}
+1 -1
View File
@@ -42,7 +42,7 @@ TEST(Imgcodecs_Png, regression_ImreadVSCvtColor)
Mat original_image = imread(imgName);
Mat gray_by_codec = imread(imgName, IMREAD_GRAYSCALE);
Mat gray_by_cvt;
cvtColor(original_image, gray_by_cvt, CV_BGR2GRAY);
cvtColor(original_image, gray_by_cvt, COLOR_BGR2GRAY);
Mat diff;
absdiff(gray_by_codec, gray_by_cvt, diff);
+26
View File
@@ -251,6 +251,32 @@ TEST(Imgcodecs_Tiff, imdecode_no_exception_temporary_file_removed)
EXPECT_NO_THROW(cv::imdecode(buf, IMREAD_UNCHANGED));
}
TEST(Imgcodecs_Tiff, decode_black_and_write_image_pr12989)
{
const string filename = cvtest::findDataFile("readwrite/bitsperpixel1.tiff");
cv::Mat img;
ASSERT_NO_THROW(img = cv::imread(filename, IMREAD_GRAYSCALE));
ASSERT_FALSE(img.empty());
EXPECT_EQ(64, img.cols);
EXPECT_EQ(64, img.rows);
EXPECT_EQ(CV_8UC1, img.type()) << cv::typeToString(img.type());
// Check for 0/255 values only: 267 + 3829 = 64*64
EXPECT_EQ(267, countNonZero(img == 0));
EXPECT_EQ(3829, countNonZero(img == 255));
}
TEST(Imgcodecs_Tiff, decode_black_and_write_image_pr12989_default)
{
const string filename = cvtest::findDataFile("readwrite/bitsperpixel1.tiff");
cv::Mat img;
ASSERT_NO_THROW(img = cv::imread(filename)); // by default image type is CV_8UC3
ASSERT_FALSE(img.empty());
EXPECT_EQ(64, img.cols);
EXPECT_EQ(64, img.rows);
EXPECT_EQ(CV_8UC3, img.type()) << cv::typeToString(img.type());
}
#endif
}} // namespace
+109 -48
View File
@@ -46,7 +46,10 @@
#include "opencv2/core.hpp"
/**
@defgroup imgproc Image processing
@defgroup imgproc Image Processing
This module includes image-processing functions.
@{
@defgroup imgproc_filter Image Filtering
@@ -148,6 +151,7 @@ case, the color[3] is simply copied to the repainted pixels. Thus, if you want t
semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main
image.
@defgroup imgproc_color_conversions Color Space Conversions
@defgroup imgproc_colormap ColorMaps in OpenCV
The human perception isn't built for observing fine changes in grayscale images. Human eyes are more
@@ -444,6 +448,9 @@ enum ShapeMatchModes {
//! @} imgproc_shape
//! @addtogroup imgproc_feature
//! @{
//! Variants of a Hough transform
enum HoughModes {
@@ -464,7 +471,6 @@ enum HoughModes {
};
//! Variants of Line Segment %Detector
//! @ingroup imgproc_feature
enum LineSegmentDetectorModes {
LSD_REFINE_NONE = 0, //!< No refinement applied
LSD_REFINE_STD = 1, //!< Standard refinement is applied. E.g. breaking arches into smaller straighter line approximations.
@@ -472,6 +478,8 @@ enum LineSegmentDetectorModes {
//!< refined through increase of precision, decrement in size, etc.
};
//! @} imgproc_feature
/** Histogram comparison methods
@ingroup imgproc_hist
*/
@@ -502,9 +510,9 @@ enum HistCompMethods {
HISTCMP_KL_DIV = 5
};
/** the color conversion code
/** the color conversion codes
@see @ref imgproc_color_conversions
@ingroup imgproc_misc
@ingroup imgproc_color_conversions
*/
enum ColorConversionCodes {
COLOR_BGR2BGRA = 0, //!< add alpha channel to RGB or BGR image
@@ -589,7 +597,7 @@ enum ColorConversionCodes {
COLOR_HLS2BGR = 60,
COLOR_HLS2RGB = 61,
COLOR_BGR2HSV_FULL = 66, //!<
COLOR_BGR2HSV_FULL = 66,
COLOR_RGB2HSV_FULL = 67,
COLOR_BGR2HLS_FULL = 68,
COLOR_RGB2HLS_FULL = 69,
@@ -773,16 +781,16 @@ enum ColorConversionCodes {
COLOR_COLORCVT_MAX = 143
};
/** types of intersection between rectangles
@ingroup imgproc_shape
*/
//! @addtogroup imgproc_shape
//! @{
//! types of intersection between rectangles
enum RectanglesIntersectTypes {
INTERSECT_NONE = 0, //!< No intersection
INTERSECT_PARTIAL = 1, //!< There is a partial intersection
INTERSECT_FULL = 2 //!< One of the rectangle is fully enclosed in the other
};
/** types of line
@ingroup imgproc_draw
*/
@@ -822,7 +830,8 @@ enum MarkerTypes
MARKER_TRIANGLE_DOWN = 6 //!< A downwards pointing triangle marker shape
};
//! finds arbitrary template in the grayscale image using Generalized Hough Transform
/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform
*/
class CV_EXPORTS_W GeneralizedHough : public Algorithm
{
public:
@@ -855,8 +864,10 @@ public:
CV_WRAP virtual int getMaxBufferSize() const = 0;
};
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Detects position only without translation and rotation
/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform
Detects position only without translation and rotation @cite Ballard1981 .
*/
class CV_EXPORTS_W GeneralizedHoughBallard : public GeneralizedHough
{
public:
@@ -869,8 +880,10 @@ public:
CV_WRAP virtual int getVotesThreshold() const = 0;
};
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
//! Detects position, translation and rotation
/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform
Detects position, translation and rotation @cite Guil1999 .
*/
class CV_EXPORTS_W GeneralizedHoughGuil : public GeneralizedHough
{
public:
@@ -923,14 +936,19 @@ public:
virtual int getPosThresh() const = 0;
};
/** @brief Base class for Contrast Limited Adaptive Histogram Equalization. :
*/
//! @} imgproc_shape
//! @addtogroup imgproc_hist
//! @{
/** @brief Base class for Contrast Limited Adaptive Histogram Equalization.
*/
class CV_EXPORTS_W CLAHE : public Algorithm
{
public:
/** @brief Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization.
@param src Source image with CV_8UC1 type.
@param src Source image of type CV_8UC1 or CV_16UC1.
@param dst Destination image.
*/
CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0;
@@ -957,6 +975,7 @@ public:
CV_WRAP virtual void collectGarbage() = 0;
};
//! @} imgproc_hist
//! @addtogroup imgproc_subdiv2d
//! @{
@@ -1498,8 +1517,8 @@ pixel values which overlap the filter placed over the pixel \f$ (x, y) \f$.
The unnormalized square box filter can be useful in computing local image statistics such as the the local
variance and standard deviation around the neighborhood of a pixel.
@param _src input image
@param _dst output image of the same size and type as _src
@param src input image
@param dst output image of the same size and type as _src
@param ddepth the output image depth (-1 to use src.depth())
@param ksize kernel size
@param anchor kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel
@@ -1508,7 +1527,7 @@ center.
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes
@sa boxFilter
*/
CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
CV_EXPORTS_W void sqrBoxFilter( InputArray src, OutputArray dst, int ddepth,
Size ksize, Point anchor = Point(-1, -1),
bool normalize = true,
int borderType = BORDER_DEFAULT );
@@ -3127,6 +3146,14 @@ The algorithm normalizes the brightness and increases the contrast of the image.
*/
CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
/** @brief Creates a smart pointer to a cv::CLAHE class and initializes it.
@param clipLimit Threshold for contrast limiting.
@param tileGridSize Size of grid for histogram equalization. Input image will be divided into
equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
*/
CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
/** @brief Computes the "minimal work" distance between two weighted point configurations.
The function computes the earth mover distance and/or a lower boundary of the distance between the
@@ -3442,6 +3469,20 @@ CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask,
Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
int flags = 4 );
//! Performs linear blending of two images:
//! \f[ \texttt{dst}(i,j) = \texttt{weights1}(i,j)*\texttt{src1}(i,j) + \texttt{weights2}(i,j)*\texttt{src2}(i,j) \f]
//! @param src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer.
//! @param src2 It has the same type and size as src1.
//! @param weights1 It has a type of CV_32FC1 and the same size with src1.
//! @param weights2 It has a type of CV_32FC1 and the same size with src1.
//! @param dst It is created if it does not have the same size and type with src1.
CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
//! @} imgproc_misc
//! @addtogroup imgproc_color_conversions
//! @{
/** @brief Converts an image from one color space to another.
The function converts an input image from one color space to another. In case of a transformation
@@ -3505,10 +3546,39 @@ This function only supports YUV420 to RGB conversion as of now.
*/
CV_EXPORTS_W void cvtColorTwoPlane( InputArray src1, InputArray src2, OutputArray dst, int code );
//! @} imgproc_misc
/** @brief main function for all demosaicing processes
// main function for all demosaicing processes
CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
@param src input image: 8-bit unsigned or 16-bit unsigned.
@param dst output image of the same size and depth as src.
@param code Color space conversion code (see the description below).
@param dstCn number of channels in the destination image; if the parameter is 0, the number of the
channels is derived automatically from src and code.
The function can do the following transformations:
- Demosaicing using bilinear interpolation
#COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR
#COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY
- Demosaicing using Variable Number of Gradients.
#COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG
- Edge-Aware Demosaicing.
#COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA
- Demosaicing with alpha channel
#COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA
@sa cvtColor
*/
CV_EXPORTS_W void demosaicing(InputArray src, OutputArray dst, int code, int dstCn = 0);
//! @} imgproc_color_conversions
//! @addtogroup imgproc_shape
//! @{
@@ -3754,13 +3824,14 @@ The function computes a curve length or a closed contour perimeter.
*/
CV_EXPORTS_W double arcLength( InputArray curve, bool closed );
/** @brief Calculates the up-right bounding rectangle of a point set.
/** @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.
The function calculates and returns the minimal up-right bounding rectangle for the specified point set.
The function calculates and returns the minimal up-right bounding rectangle for the specified point set or
non-zero pixels of gray-scale image.
@param points Input 2D point set, stored in std::vector or Mat.
@param array Input gray-scale image or 2D point set, stored in std::vector or Mat.
*/
CV_EXPORTS_W Rect boundingRect( InputArray points );
CV_EXPORTS_W Rect boundingRect( InputArray array );
/** @brief Calculates a contour area.
@@ -3886,6 +3957,12 @@ vector: std::vector\<int\> implies returnPoints=false, std::vector\<Point\> impl
returnPoints=true.
@note `points` and `hull` should be different arrays, inplace processing isn't supported.
Check @ref tutorial_hull "the corresponding tutorial" for more details.
useful links:
https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/
*/
CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull,
bool clockwise = false, bool returnPoints = true );
@@ -4092,31 +4169,15 @@ at most 8 vertices. Stored as std::vector\<cv::Point2f\> or cv::Mat as Mx1 of ty
*/
CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion );
//! @} imgproc_shape
/** @brief Creates implementation for cv::CLAHE .
@param clipLimit Threshold for contrast limiting.
@param tileGridSize Size of grid for histogram equalization. Input image will be divided into
equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
*/
CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Detects position only without translation and rotation
/** @brief Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it.
*/
CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
//! Detects position, translation and rotation
/** @brief Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it.
*/
CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
//! Performs linear blending of two images:
//! \f[ \texttt{dst}(i,j) = \texttt{weights1}(i,j)*\texttt{src1}(i,j) + \texttt{weights2}(i,j)*\texttt{src2}(i,j) \f]
//! @param src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer.
//! @param src2 It has the same type and size as src1.
//! @param weights1 It has a type of CV_32FC1 and the same size with src1.
//! @param weights2 It has a type of CV_32FC1 and the same size with src1.
//! @param dst It is created if it does not have the same size and type with src1.
CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
//! @} imgproc_shape
//! @addtogroup imgproc_colormap
//! @{
+84 -149
View File
@@ -12,183 +12,118 @@ namespace cv
////////////////// Various 3/4-channel to 3/4-channel RGB transformations /////////////////
template<typename _Tp> struct RGB2RGB
{
typedef _Tp channel_type;
template<typename _Tp> struct v_type;
RGB2RGB(int _srccn, int _dstcn, int _blueIdx) : srccn(_srccn), dstcn(_dstcn), blueIdx(_blueIdx) {}
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int scn = srccn, dcn = dstcn, bidx = blueIdx;
if( dcn == 3 )
{
n *= 3;
for( int i = 0; i < n; i += 3, src += scn )
{
_Tp t0 = src[bidx], t1 = src[1], t2 = src[bidx ^ 2];
dst[i] = t0; dst[i+1] = t1; dst[i+2] = t2;
}
}
else if( scn == 3 )
{
n *= 3;
_Tp alpha = ColorChannel<_Tp>::max();
for( int i = 0; i < n; i += 3, dst += 4 )
{
_Tp t0 = src[i], t1 = src[i+1], t2 = src[i+2];
dst[bidx] = t0; dst[1] = t1; dst[bidx^2] = t2; dst[3] = alpha;
}
}
else
{
n *= 4;
for( int i = 0; i < n; i += 4 )
{
_Tp t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
}
}
}
int srccn, dstcn, blueIdx;
template<>
struct v_type<uchar>{
typedef v_uint8 t;
};
#if CV_NEON
template<>
struct v_type<ushort>{
typedef v_uint16 t;
};
template<> struct RGB2RGB<uchar>
template<>
struct v_type<float>{
typedef v_float32 t;
};
template<typename _Tp> struct v_set;
template<>
struct v_set<uchar>
{
typedef uchar channel_type;
static inline v_type<uchar>::t set(uchar x)
{
return vx_setall_u8(x);
}
};
template<>
struct v_set<ushort>
{
static inline v_type<ushort>::t set(ushort x)
{
return vx_setall_u16(x);
}
};
template<>
struct v_set<float>
{
static inline v_type<float>::t set(float x)
{
return vx_setall_f32(x);
}
};
template<typename _Tp>
struct RGB2RGB
{
typedef _Tp channel_type;
typedef typename v_type<_Tp>::t vt;
RGB2RGB(int _srccn, int _dstcn, int _blueIdx) :
srccn(_srccn), dstcn(_dstcn), blueIdx(_blueIdx)
{
v_alpha = vdupq_n_u8(ColorChannel<uchar>::max());
v_alpha2 = vget_low_u8(v_alpha);
CV_Assert(srccn == 3 || srccn == 4);
CV_Assert(dstcn == 3 || dstcn == 4);
}
void operator()(const uchar * src, uchar * dst, int n) const
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int scn = srccn, dcn = dstcn, bidx = blueIdx, i = 0;
if (dcn == 3)
int scn = srccn, dcn = dstcn, bi = blueIdx;
int i = 0;
_Tp alphav = ColorChannel<_Tp>::max();
#if CV_SIMD
const int vsize = vt::nlanes;
for(; i < n-vsize+1;
i += vsize, src += vsize*scn, dst += vsize*dcn)
{
n *= 3;
if (scn == 3)
vt a, b, c, d;
if(scn == 4)
{
for ( ; i <= n - 48; i += 48, src += 48 )
{
uint8x16x3_t v_src = vld3q_u8(src), v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx ^ 2];
vst3q_u8(dst + i, v_dst);
}
for ( ; i <= n - 24; i += 24, src += 24 )
{
uint8x8x3_t v_src = vld3_u8(src), v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx ^ 2];
vst3_u8(dst + i, v_dst);
}
for ( ; i < n; i += 3, src += 3 )
{
uchar t0 = src[bidx], t1 = src[1], t2 = src[bidx ^ 2];
dst[i] = t0; dst[i+1] = t1; dst[i+2] = t2;
}
v_load_deinterleave(src, a, b, c, d);
}
else
{
for ( ; i <= n - 48; i += 48, src += 64 )
{
uint8x16x4_t v_src = vld4q_u8(src);
uint8x16x3_t v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx ^ 2];
vst3q_u8(dst + i, v_dst);
}
for ( ; i <= n - 24; i += 24, src += 32 )
{
uint8x8x4_t v_src = vld4_u8(src);
uint8x8x3_t v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx ^ 2];
vst3_u8(dst + i, v_dst);
}
for ( ; i < n; i += 3, src += 4 )
{
uchar t0 = src[bidx], t1 = src[1], t2 = src[bidx ^ 2];
dst[i] = t0; dst[i+1] = t1; dst[i+2] = t2;
}
v_load_deinterleave(src, a, b, c);
d = v_set<_Tp>::set(alphav);
}
if(bi == 2)
swap(a, c);
if(dcn == 4)
{
v_store_interleave(dst, a, b, c, d);
}
else
{
v_store_interleave(dst, a, b, c);
}
}
else if (scn == 3)
vx_cleanup();
#endif
for ( ; i < n; i++, src += scn, dst += dcn )
{
n *= 3;
for ( ; i <= n - 48; i += 48, dst += 64 )
_Tp t0 = src[0], t1 = src[1], t2 = src[2];
dst[bi ] = t0;
dst[1] = t1;
dst[bi^2] = t2;
if(dcn == 4)
{
uint8x16x3_t v_src = vld3q_u8(src + i);
uint8x16x4_t v_dst;
v_dst.val[bidx] = v_src.val[0];
v_dst.val[1] = v_src.val[1];
v_dst.val[bidx ^ 2] = v_src.val[2];
v_dst.val[3] = v_alpha;
vst4q_u8(dst, v_dst);
}
for ( ; i <= n - 24; i += 24, dst += 32 )
{
uint8x8x3_t v_src = vld3_u8(src + i);
uint8x8x4_t v_dst;
v_dst.val[bidx] = v_src.val[0];
v_dst.val[1] = v_src.val[1];
v_dst.val[bidx ^ 2] = v_src.val[2];
v_dst.val[3] = v_alpha2;
vst4_u8(dst, v_dst);
}
uchar alpha = ColorChannel<uchar>::max();
for (; i < n; i += 3, dst += 4 )
{
uchar t0 = src[i], t1 = src[i+1], t2 = src[i+2];
dst[bidx] = t0; dst[1] = t1; dst[bidx^2] = t2; dst[3] = alpha;
}
}
else
{
n *= 4;
for ( ; i <= n - 64; i += 64 )
{
uint8x16x4_t v_src = vld4q_u8(src + i), v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx^2];
v_dst.val[3] = v_src.val[3];
vst4q_u8(dst + i, v_dst);
}
for ( ; i <= n - 32; i += 32 )
{
uint8x8x4_t v_src = vld4_u8(src + i), v_dst;
v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
v_dst.val[2] = v_src.val[bidx^2];
v_dst.val[3] = v_src.val[3];
vst4_u8(dst + i, v_dst);
}
for ( ; i < n; i += 4)
{
uchar t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
_Tp d = scn == 4 ? src[3] : alphav;
dst[3] = d;
}
}
}
int srccn, dstcn, blueIdx;
uint8x16_t v_alpha;
uint8x8_t v_alpha2;
};
#endif
/////////// Transforming 16-bit (565 or 555) RGB to/from 24/32-bit (888[8]) RGB //////////
+19 -19
View File
@@ -658,10 +658,10 @@ static void Bayer2Gray_( const Mat& srcmat, Mat& dstmat, int code )
Size size = srcmat.size();
int bcoeff = B2Y, rcoeff = R2Y;
int start_with_green = code == CV_BayerGB2GRAY || code == CV_BayerGR2GRAY;
int start_with_green = code == COLOR_BayerGB2GRAY || code == COLOR_BayerGR2GRAY;
bool brow = true;
if( code != CV_BayerBG2GRAY && code != CV_BayerGB2GRAY )
if( code != COLOR_BayerBG2GRAY && code != COLOR_BayerGB2GRAY )
{
brow = false;
std::swap(bcoeff, rcoeff);
@@ -923,10 +923,10 @@ static void Bayer2RGB_( const Mat& srcmat, Mat& dstmat, int code )
{
int dst_step = (int)(dstmat.step/sizeof(T));
Size size = srcmat.size();
int blue = (code == CV_BayerBG2BGR || code == CV_BayerGB2BGR ||
code == CV_BayerBG2BGRA || code == CV_BayerGB2BGRA ) ? -1 : 1;
int start_with_green = (code == CV_BayerGB2BGR || code == CV_BayerGR2BGR ||
code == CV_BayerGB2BGRA || code == CV_BayerGR2BGRA);
int blue = (code == COLOR_BayerBG2BGR || code == COLOR_BayerGB2BGR ||
code == COLOR_BayerBG2BGRA || code == COLOR_BayerGB2BGRA ) ? -1 : 1;
int start_with_green = (code == COLOR_BayerGB2BGR || code == COLOR_BayerGR2BGR ||
code == COLOR_BayerGB2BGRA || code == COLOR_BayerGR2BGRA);
int dcn = dstmat.channels();
size.height -= 2;
@@ -964,8 +964,8 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
int dststep = (int)dstmat.step;
Size size = srcmat.size();
int blueIdx = code == CV_BayerBG2BGR_VNG || code == CV_BayerGB2BGR_VNG ? 0 : 2;
bool greenCell0 = code != CV_BayerBG2BGR_VNG && code != CV_BayerRG2BGR_VNG;
int blueIdx = code == COLOR_BayerBG2BGR_VNG || code == COLOR_BayerGB2BGR_VNG ? 0 : 2;
bool greenCell0 = code != COLOR_BayerBG2BGR_VNG && code != COLOR_BayerRG2BGR_VNG;
// for too small images use the simple interpolation algorithm
if( MIN(size.width, size.height) < 8 )
@@ -1625,8 +1625,8 @@ static void Bayer2RGB_EdgeAware_T(const Mat& src, Mat& dst, int code)
size.width -= 2;
size.height -= 2;
int start_with_green = code == CV_BayerGB2BGR_EA || code == CV_BayerGR2BGR_EA ? 1 : 0;
int blue = code == CV_BayerGB2BGR_EA || code == CV_BayerBG2BGR_EA ? 1 : 0;
int start_with_green = code == COLOR_BayerGB2BGR_EA || code == COLOR_BayerGR2BGR_EA ? 1 : 0;
int blue = code == COLOR_BayerGB2BGR_EA || code == COLOR_BayerBG2BGR_EA ? 1 : 0;
if (size.height > 0)
{
@@ -1672,7 +1672,7 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
switch (code)
{
case CV_BayerBG2GRAY: case CV_BayerGB2GRAY: case CV_BayerRG2GRAY: case CV_BayerGR2GRAY:
case COLOR_BayerBG2GRAY: case COLOR_BayerGB2GRAY: case COLOR_BayerRG2GRAY: case COLOR_BayerGR2GRAY:
if (dcn <= 0)
dcn = 1;
CV_Assert( scn == 1 && dcn == 1 );
@@ -1688,12 +1688,12 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
CV_Error(CV_StsUnsupportedFormat, "Bayer->Gray demosaicing only supports 8u and 16u types");
break;
case CV_BayerBG2BGRA: case CV_BayerGB2BGRA: case CV_BayerRG2BGRA: case CV_BayerGR2BGRA:
case COLOR_BayerBG2BGRA: case COLOR_BayerGB2BGRA: case COLOR_BayerRG2BGRA: case COLOR_BayerGR2BGRA:
if (dcn <= 0)
dcn = 4;
/* fallthrough */
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 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:
{
if (dcn <= 0)
dcn = 3;
@@ -1702,10 +1702,10 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
_dst.create(sz, CV_MAKE_TYPE(depth, dcn));
Mat dst_ = _dst.getMat();
if( code == CV_BayerBG2BGR || code == CV_BayerBG2BGRA ||
code == CV_BayerGB2BGR || code == CV_BayerGB2BGRA ||
code == CV_BayerRG2BGR || code == CV_BayerRG2BGRA ||
code == CV_BayerGR2BGR || code == CV_BayerGR2BGRA )
if( code == COLOR_BayerBG2BGR || code == COLOR_BayerBG2BGRA ||
code == COLOR_BayerGB2BGR || code == COLOR_BayerGB2BGRA ||
code == COLOR_BayerRG2BGR || code == COLOR_BayerRG2BGRA ||
code == COLOR_BayerGR2BGR || code == COLOR_BayerGR2BGRA )
{
if( depth == CV_8U )
Bayer2RGB_<uchar, SIMDBayerInterpolator_8u>(src, dst_, code);
@@ -1722,7 +1722,7 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
}
break;
case CV_BayerBG2BGR_EA: case CV_BayerGB2BGR_EA: case CV_BayerRG2BGR_EA: case CV_BayerGR2BGR_EA:
case COLOR_BayerBG2BGR_EA: case COLOR_BayerGB2BGR_EA: case COLOR_BayerRG2BGR_EA: case COLOR_BayerGR2BGR_EA:
if (dcn <= 0)
dcn = 3;
+52 -52
View File
@@ -415,7 +415,7 @@ void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat&
#undef INIT_FWD_INV_CODES
#define INIT_FWD_INV_CODES( fwd, inv ) \
fwd_code = CV_##fwd; inv_code = CV_##inv; \
fwd_code = COLOR_##fwd; inv_code = COLOR_##inv; \
fwd_code_str = #fwd; inv_code_str = #inv
//// rgb <=> gray
@@ -447,16 +447,16 @@ void CV_ColorGrayTest::get_test_array_types_and_sizes( int test_case_idx, vector
if( cn == 3 )
{
if( blue_idx == 0 )
fwd_code = CV_BGR2GRAY, inv_code = CV_GRAY2BGR;
fwd_code = COLOR_BGR2GRAY, inv_code = COLOR_GRAY2BGR;
else
fwd_code = CV_RGB2GRAY, inv_code = CV_GRAY2RGB;
fwd_code = COLOR_RGB2GRAY, inv_code = COLOR_GRAY2RGB;
}
else
{
if( blue_idx == 0 )
fwd_code = CV_BGRA2GRAY, inv_code = CV_GRAY2BGRA;
fwd_code = COLOR_BGRA2GRAY, inv_code = COLOR_GRAY2BGRA;
else
fwd_code = CV_RGBA2GRAY, inv_code = CV_GRAY2RGBA;
fwd_code = COLOR_RGBA2GRAY, inv_code = COLOR_GRAY2RGBA;
}
}
@@ -515,9 +515,9 @@ void CV_ColorYCrCbTest::get_test_array_types_and_sizes( int test_case_idx, vecto
CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
if( blue_idx == 0 )
fwd_code = CV_BGR2YCrCb, inv_code = CV_YCrCb2BGR;
fwd_code = COLOR_BGR2YCrCb, inv_code = COLOR_YCrCb2BGR;
else
fwd_code = CV_RGB2YCrCb, inv_code = CV_YCrCb2RGB;
fwd_code = COLOR_RGB2YCrCb, inv_code = COLOR_YCrCb2RGB;
}
@@ -612,17 +612,17 @@ void CV_ColorHSVTest::get_test_array_types_and_sizes( int test_case_idx, vector<
if( full_hrange )
{
if( blue_idx == 0 )
fwd_code = CV_BGR2HSV_FULL, inv_code = CV_HSV2BGR_FULL;
fwd_code = COLOR_BGR2HSV_FULL, inv_code = COLOR_HSV2BGR_FULL;
else
fwd_code = CV_RGB2HSV_FULL, inv_code = CV_HSV2RGB_FULL;
fwd_code = COLOR_RGB2HSV_FULL, inv_code = COLOR_HSV2RGB_FULL;
hue_range = 256;
}
else
{
if( blue_idx == 0 )
fwd_code = CV_BGR2HSV, inv_code = CV_HSV2BGR;
fwd_code = COLOR_BGR2HSV, inv_code = COLOR_HSV2BGR;
else
fwd_code = CV_RGB2HSV, inv_code = CV_HSV2RGB;
fwd_code = COLOR_RGB2HSV, inv_code = COLOR_HSV2RGB;
hue_range = 180;
}
}
@@ -747,9 +747,9 @@ void CV_ColorHLSTest::get_test_array_types_and_sizes( int test_case_idx, vector<
CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
if( blue_idx == 0 )
fwd_code = CV_BGR2HLS, inv_code = CV_HLS2BGR;
fwd_code = COLOR_BGR2HLS, inv_code = COLOR_HLS2BGR;
else
fwd_code = CV_RGB2HLS, inv_code = CV_HLS2RGB;
fwd_code = COLOR_RGB2HLS, inv_code = COLOR_HLS2RGB;
}
@@ -930,9 +930,9 @@ void CV_ColorXYZTest::get_test_array_types_and_sizes( int test_case_idx, vector<
CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
if( blue_idx == 0 )
fwd_code = CV_BGR2XYZ, inv_code = CV_XYZ2BGR;
fwd_code = COLOR_BGR2XYZ, inv_code = COLOR_XYZ2BGR;
else
fwd_code = CV_RGB2XYZ, inv_code = CV_XYZ2RGB;
fwd_code = COLOR_RGB2XYZ, inv_code = COLOR_XYZ2RGB;
}
@@ -1059,16 +1059,16 @@ void CV_ColorLabTest::get_test_array_types_and_sizes( int test_case_idx, vector<
if(srgb)
{
if( blue_idx == 0 )
fwd_code = CV_BGR2Lab, inv_code = CV_Lab2BGR;
fwd_code = COLOR_BGR2Lab, inv_code = COLOR_Lab2BGR;
else
fwd_code = CV_RGB2Lab, inv_code = CV_Lab2RGB;
fwd_code = COLOR_RGB2Lab, inv_code = COLOR_Lab2RGB;
}
else
{
if( blue_idx == 0 )
fwd_code = CV_LBGR2Lab, inv_code = CV_Lab2LBGR;
fwd_code = COLOR_LBGR2Lab, inv_code = COLOR_Lab2LBGR;
else
fwd_code = CV_LRGB2Lab, inv_code = CV_Lab2LRGB;
fwd_code = COLOR_LRGB2Lab, inv_code = COLOR_Lab2LRGB;
}
}
@@ -1238,16 +1238,16 @@ void CV_ColorLuvTest::get_test_array_types_and_sizes( int test_case_idx, vector<
if(srgb)
{
if( blue_idx == 0 )
fwd_code = CV_BGR2Luv, inv_code = CV_Luv2BGR;
fwd_code = COLOR_BGR2Luv, inv_code = COLOR_Luv2BGR;
else
fwd_code = CV_RGB2Luv, inv_code = CV_Luv2RGB;
fwd_code = COLOR_RGB2Luv, inv_code = COLOR_Luv2RGB;
}
else
{
if( blue_idx == 0 )
fwd_code = CV_LBGR2Luv, inv_code = CV_Luv2LBGR;
fwd_code = COLOR_LBGR2Luv, inv_code = COLOR_Luv2LBGR;
else
fwd_code = CV_LRGB2Luv, inv_code = CV_Luv2LRGB;
fwd_code = COLOR_LRGB2Luv, inv_code = COLOR_Luv2LRGB;
}
}
@@ -1453,17 +1453,17 @@ void CV_ColorRGBTest::get_test_array_types_and_sizes( int test_case_idx, vector<
if( cvtest::randInt(rng) & 1 )
{
if( blue_idx == 0 )
fwd_code = CV_BGR2BGR565, inv_code = CV_BGR5652BGR;
fwd_code = COLOR_BGR2BGR565, inv_code = COLOR_BGR5652BGR;
else
fwd_code = CV_RGB2BGR565, inv_code = CV_BGR5652RGB;
fwd_code = COLOR_RGB2BGR565, inv_code = COLOR_BGR5652RGB;
dst_bits = 16;
}
else
{
if( blue_idx == 0 )
fwd_code = CV_BGR2BGR555, inv_code = CV_BGR5552BGR;
fwd_code = COLOR_BGR2BGR555, inv_code = COLOR_BGR5552BGR;
else
fwd_code = CV_RGB2BGR555, inv_code = CV_BGR5552RGB;
fwd_code = COLOR_RGB2BGR555, inv_code = COLOR_BGR5552RGB;
dst_bits = 15;
}
}
@@ -1471,13 +1471,13 @@ void CV_ColorRGBTest::get_test_array_types_and_sizes( int test_case_idx, vector<
{
if( cn == 3 )
{
fwd_code = CV_RGB2BGR, inv_code = CV_BGR2RGB;
fwd_code = COLOR_RGB2BGR, inv_code = COLOR_BGR2RGB;
blue_idx = 2;
}
else if( blue_idx == 0 )
fwd_code = CV_BGRA2BGR, inv_code = CV_BGR2BGRA;
fwd_code = COLOR_BGRA2BGR, inv_code = COLOR_BGR2BGRA;
else
fwd_code = CV_RGBA2BGR, inv_code = CV_BGR2RGBA;
fwd_code = COLOR_RGBA2BGR, inv_code = COLOR_BGR2RGBA;
}
if( CV_MAT_CN(types[INPUT][0]) != CV_MAT_CN(types[OUTPUT][0]) )
@@ -1704,7 +1704,7 @@ CV_ColorBayerTest::CV_ColorBayerTest() : CV_ColorCvtBaseTest( false, false, true
fwd_code_str = "BayerBG2BGR";
inv_code_str = "";
fwd_code = CV_BayerBG2BGR;
fwd_code = COLOR_BayerBG2BGR;
inv_code = -1;
}
@@ -1718,7 +1718,7 @@ void CV_ColorBayerTest::get_test_array_types_and_sizes( int test_case_idx, vecto
types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(CV_MAT_DEPTH(types[INPUT][0]), 3);
inplace = false;
fwd_code = cvtest::randInt(rng)%4 + CV_BayerBG2BGR;
fwd_code = cvtest::randInt(rng)%4 + COLOR_BayerBG2BGR;
}
@@ -1747,7 +1747,7 @@ static void bayer2BGR_(const Mat& src, Mat& dst, int code)
int bi = 0;
int step = (int)(src.step/sizeof(T));
if( code == CV_BayerRG2BGR || code == CV_BayerGR2BGR )
if( code == COLOR_BayerRG2BGR || code == COLOR_BayerGR2BGR )
bi ^= 2;
for( i = 1; i < src.rows - 1; i++ )
@@ -1850,7 +1850,7 @@ TEST(Imgproc_ColorBayer, regression)
CV_Assert( !given.empty() && !gold.empty() );
cvtColor(given, result, CV_BayerBG2GRAY);
cvtColor(given, result, COLOR_BayerBG2GRAY);
EXPECT_EQ(gold.type(), result.type());
EXPECT_EQ(gold.cols, result.cols);
@@ -1873,7 +1873,7 @@ TEST(Imgproc_ColorBayerVNG, regression)
CV_Assert( !given.empty() );
cvtColor(given, result, CV_BayerBG2BGR_VNG, 3);
cvtColor(given, result, COLOR_BayerBG2BGR_VNG, 3);
if (gold.empty())
imwrite(goldfname, result);
@@ -1977,7 +1977,7 @@ TEST(Imgproc_ColorBayerVNG_Strict, regression)
CV_Assert(!bayer.empty() && bayer.type() == CV_8UC1);
// calculating a dst image
cvtColor(bayer, dst, CV_BayerBG2BGR_VNG + i);
cvtColor(bayer, dst, COLOR_BayerBG2BGR_VNG + i);
// reading a reference image
full_path = parent_path + pattern[i] + image_name;
@@ -2099,8 +2099,8 @@ TEST(Imgproc_ColorLab_Full, accuracy)
// Convert test image to LAB
cv::Mat lab;
int forward_code = blueInd ? srgb ? CV_BGR2Lab : CV_LBGR2Lab : srgb ? CV_RGB2Lab : CV_LRGB2Lab;
int inverse_code = blueInd ? srgb ? CV_Lab2BGR : CV_Lab2LBGR : srgb ? CV_Lab2RGB : CV_Lab2LRGB;
int forward_code = blueInd ? srgb ? COLOR_BGR2Lab : COLOR_LBGR2Lab : srgb ? COLOR_RGB2Lab : COLOR_LRGB2Lab;
int inverse_code = blueInd ? srgb ? COLOR_Lab2BGR : COLOR_Lab2LBGR : srgb ? COLOR_Lab2RGB : COLOR_Lab2LRGB;
cv::cvtColor(src, lab, forward_code);
// Convert LAB image back to BGR(RGB)
cv::Mat recons;
@@ -2623,10 +2623,10 @@ int row8uLuvChoose(const uchar* src_row, uchar *dst_row, int n, bool forward, in
TEST(Imgproc_ColorLab_Full, bitExactness)
{
int codes[] = { CV_BGR2Lab, CV_RGB2Lab, CV_LBGR2Lab, CV_LRGB2Lab,
CV_Lab2BGR, CV_Lab2RGB, CV_Lab2LBGR, CV_Lab2LRGB};
string names[] = { "CV_BGR2Lab", "CV_RGB2Lab", "CV_LBGR2Lab", "CV_LRGB2Lab",
"CV_Lab2BGR", "CV_Lab2RGB", "CV_Lab2LBGR", "CV_Lab2LRGB" };
int codes[] = { COLOR_BGR2Lab, COLOR_RGB2Lab, COLOR_LBGR2Lab, COLOR_LRGB2Lab,
COLOR_Lab2BGR, COLOR_Lab2RGB, COLOR_Lab2LBGR, COLOR_Lab2LRGB};
string names[] = { "COLOR_BGR2Lab", "COLOR_RGB2Lab", "COLOR_LBGR2Lab", "COLOR_LRGB2Lab",
"COLOR_Lab2BGR", "COLOR_Lab2RGB", "COLOR_Lab2LBGR", "COLOR_Lab2LRGB" };
// need to be recalculated each time we change Lab algorithms, RNG or test system
const int nIterations = 8;
@@ -2707,10 +2707,10 @@ TEST(Imgproc_ColorLab_Full, bitExactness)
TEST(Imgproc_ColorLuv_Full, bitExactness)
{
int codes[] = { CV_BGR2Luv, CV_RGB2Luv, CV_LBGR2Luv, CV_LRGB2Luv,
CV_Luv2BGR, CV_Luv2RGB, CV_Luv2LBGR, CV_Luv2LRGB};
string names[] = { "CV_BGR2Luv", "CV_RGB2Luv", "CV_LBGR2Luv", "CV_LRGB2Luv",
"CV_Luv2BGR", "CV_Luv2RGB", "CV_Luv2LBGR", "CV_Luv2LRGB" };
int codes[] = { COLOR_BGR2Luv, COLOR_RGB2Luv, COLOR_LBGR2Luv, COLOR_LRGB2Luv,
COLOR_Luv2BGR, COLOR_Luv2RGB, COLOR_Luv2LBGR, COLOR_Luv2LRGB};
string names[] = { "COLOR_BGR2Luv", "COLOR_RGB2Luv", "COLOR_LBGR2Luv", "COLOR_LRGB2Luv",
"COLOR_Luv2BGR", "COLOR_Luv2RGB", "COLOR_Luv2LBGR", "COLOR_Luv2LRGB" };
/* to be enabled when bit-exactness is done for other codes */
bool codeEnabled[] = { true, true, false, false, true, true, true, true };
@@ -2812,8 +2812,8 @@ static void test_Bayer2RGB_EdgeAware_8u(const Mat& src, Mat& dst, int code)
const uchar* S = src.ptr<uchar>(1) + 1;
uchar* D = dst.ptr<uchar>(1) + dcn;
int start_with_green = code == CV_BayerGB2BGR_EA || code == CV_BayerGR2BGR_EA ? 1 : 0;
int blue = code == CV_BayerGB2BGR_EA || code == CV_BayerBG2BGR_EA ? 1 : 0;
int start_with_green = code == COLOR_BayerGB2BGR_EA || code == COLOR_BayerGR2BGR_EA ? 1 : 0;
int blue = code == COLOR_BayerGB2BGR_EA || code == COLOR_BayerBG2BGR_EA ? 1 : 0;
for (int y = 1; y < size.height; ++y)
{
@@ -2962,7 +2962,7 @@ TEST(ImgProc_BayerEdgeAwareDemosaicing, accuracy)
{
calculateBayerPattern<uchar, CV_8U>(src, bayer, types[i]);
Mat reference;
test_Bayer2RGB_EdgeAware_8u(bayer, reference, CV_BayerBG2BGR_EA + i);
test_Bayer2RGB_EdgeAware_8u(bayer, reference, COLOR_BayerBG2BGR_EA + i);
for (int t = 0; t <= 1; ++t)
{
@@ -2972,7 +2972,7 @@ TEST(ImgProc_BayerEdgeAwareDemosaicing, accuracy)
CV_Assert(!bayer.empty() && (bayer.type() == CV_8UC1 || bayer.type() == CV_16UC1));
Mat actual;
cv::demosaicing(bayer, actual, CV_BayerBG2BGR_EA + i);
cv::demosaicing(bayer, actual, COLOR_BayerBG2BGR_EA + i);
if (t == 0)
checkData<unsigned char>(actual, reference, ts, types[i], next, "CV_8U");
@@ -2996,10 +2996,10 @@ TEST(ImgProc_Bayer2RGBA, accuracy)
CV_Assert(raw.depth() == CV_8U);
CV_Assert(!raw.empty());
for (int code = CV_BayerBG2BGR; code <= CV_BayerGR2BGR; ++code)
for (int code = COLOR_BayerBG2BGR; code <= COLOR_BayerGR2BGR; ++code)
{
cvtColor(raw, rgb, code);
cvtColor(rgb, reference, CV_BGR2BGRA);
cvtColor(rgb, reference, COLOR_BGR2BGRA);
Mat actual;
cvtColor(raw, actual, code, 4);
+111 -111
View File
@@ -361,54 +361,54 @@ YUVreader* YUVreader::getReader(int code)
{
switch(code)
{
case CV_YUV2RGB_NV12:
case CV_YUV2BGR_NV12:
case CV_YUV2RGBA_NV12:
case CV_YUV2BGRA_NV12:
case COLOR_YUV2RGB_NV12:
case COLOR_YUV2BGR_NV12:
case COLOR_YUV2RGBA_NV12:
case COLOR_YUV2BGRA_NV12:
return new NV12Reader();
case CV_YUV2RGB_NV21:
case CV_YUV2BGR_NV21:
case CV_YUV2RGBA_NV21:
case CV_YUV2BGRA_NV21:
case COLOR_YUV2RGB_NV21:
case COLOR_YUV2BGR_NV21:
case COLOR_YUV2RGBA_NV21:
case COLOR_YUV2BGRA_NV21:
return new NV21Reader();
case CV_YUV2RGB_YV12:
case CV_YUV2BGR_YV12:
case CV_YUV2RGBA_YV12:
case CV_YUV2BGRA_YV12:
case COLOR_YUV2RGB_YV12:
case COLOR_YUV2BGR_YV12:
case COLOR_YUV2RGBA_YV12:
case COLOR_YUV2BGRA_YV12:
return new YV12Reader();
case CV_YUV2RGB_IYUV:
case CV_YUV2BGR_IYUV:
case CV_YUV2RGBA_IYUV:
case CV_YUV2BGRA_IYUV:
case COLOR_YUV2RGB_IYUV:
case COLOR_YUV2BGR_IYUV:
case COLOR_YUV2RGBA_IYUV:
case COLOR_YUV2BGRA_IYUV:
return new IYUVReader();
case CV_YUV2RGB_UYVY:
case CV_YUV2BGR_UYVY:
case CV_YUV2RGBA_UYVY:
case CV_YUV2BGRA_UYVY:
case COLOR_YUV2RGB_UYVY:
case COLOR_YUV2BGR_UYVY:
case COLOR_YUV2RGBA_UYVY:
case COLOR_YUV2BGRA_UYVY:
return new UYVYReader();
//case CV_YUV2RGB_VYUY = 109,
//case CV_YUV2BGR_VYUY = 110,
//case CV_YUV2RGBA_VYUY = 113,
//case CV_YUV2BGRA_VYUY = 114,
//case COLOR_YUV2RGB_VYUY = 109,
//case COLOR_YUV2BGR_VYUY = 110,
//case COLOR_YUV2RGBA_VYUY = 113,
//case COLOR_YUV2BGRA_VYUY = 114,
// return ??
case CV_YUV2RGB_YUY2:
case CV_YUV2BGR_YUY2:
case CV_YUV2RGBA_YUY2:
case CV_YUV2BGRA_YUY2:
case COLOR_YUV2RGB_YUY2:
case COLOR_YUV2BGR_YUY2:
case COLOR_YUV2RGBA_YUY2:
case COLOR_YUV2BGRA_YUY2:
return new YUY2Reader();
case CV_YUV2RGB_YVYU:
case CV_YUV2BGR_YVYU:
case CV_YUV2RGBA_YVYU:
case CV_YUV2BGRA_YVYU:
case COLOR_YUV2RGB_YVYU:
case COLOR_YUV2BGR_YVYU:
case COLOR_YUV2RGBA_YVYU:
case COLOR_YUV2BGRA_YVYU:
return new YVYUReader();
case CV_YUV2GRAY_420:
case COLOR_YUV2GRAY_420:
return new NV21Reader();
case CV_YUV2GRAY_UYVY:
case COLOR_YUV2GRAY_UYVY:
return new UYVYReader();
case CV_YUV2GRAY_YUY2:
case COLOR_YUV2GRAY_YUY2:
return new YUY2Reader();
case CV_YUV2BGR:
case CV_YUV2RGB:
case COLOR_YUV2BGR:
case COLOR_YUV2RGB:
return new YUV888Reader();
default:
return 0;
@@ -419,17 +419,17 @@ RGBreader* RGBreader::getReader(int code)
{
switch(code)
{
case CV_RGB2YUV_YV12:
case CV_RGB2YUV_I420:
case COLOR_RGB2YUV_YV12:
case COLOR_RGB2YUV_I420:
return new RGB888Reader();
case CV_BGR2YUV_YV12:
case CV_BGR2YUV_I420:
case COLOR_BGR2YUV_YV12:
case COLOR_BGR2YUV_I420:
return new BGR888Reader();
case CV_RGBA2YUV_I420:
case CV_RGBA2YUV_YV12:
case COLOR_RGBA2YUV_I420:
case COLOR_RGBA2YUV_YV12:
return new RGBA8888Reader();
case CV_BGRA2YUV_YV12:
case CV_BGRA2YUV_I420:
case COLOR_BGRA2YUV_YV12:
case COLOR_BGRA2YUV_I420:
return new BGRA8888Reader();
default:
return 0;
@@ -440,43 +440,43 @@ RGBwriter* RGBwriter::getWriter(int code)
{
switch(code)
{
case CV_YUV2RGB_NV12:
case CV_YUV2RGB_NV21:
case CV_YUV2RGB_YV12:
case CV_YUV2RGB_IYUV:
case CV_YUV2RGB_UYVY:
//case CV_YUV2RGB_VYUY:
case CV_YUV2RGB_YUY2:
case CV_YUV2RGB_YVYU:
case CV_YUV2RGB:
case COLOR_YUV2RGB_NV12:
case COLOR_YUV2RGB_NV21:
case COLOR_YUV2RGB_YV12:
case COLOR_YUV2RGB_IYUV:
case COLOR_YUV2RGB_UYVY:
//case COLOR_YUV2RGB_VYUY:
case COLOR_YUV2RGB_YUY2:
case COLOR_YUV2RGB_YVYU:
case COLOR_YUV2RGB:
return new RGB888Writer();
case CV_YUV2BGR_NV12:
case CV_YUV2BGR_NV21:
case CV_YUV2BGR_YV12:
case CV_YUV2BGR_IYUV:
case CV_YUV2BGR_UYVY:
//case CV_YUV2BGR_VYUY:
case CV_YUV2BGR_YUY2:
case CV_YUV2BGR_YVYU:
case CV_YUV2BGR:
case COLOR_YUV2BGR_NV12:
case COLOR_YUV2BGR_NV21:
case COLOR_YUV2BGR_YV12:
case COLOR_YUV2BGR_IYUV:
case COLOR_YUV2BGR_UYVY:
//case COLOR_YUV2BGR_VYUY:
case COLOR_YUV2BGR_YUY2:
case COLOR_YUV2BGR_YVYU:
case COLOR_YUV2BGR:
return new BGR888Writer();
case CV_YUV2RGBA_NV12:
case CV_YUV2RGBA_NV21:
case CV_YUV2RGBA_YV12:
case CV_YUV2RGBA_IYUV:
case CV_YUV2RGBA_UYVY:
//case CV_YUV2RGBA_VYUY:
case CV_YUV2RGBA_YUY2:
case CV_YUV2RGBA_YVYU:
case COLOR_YUV2RGBA_NV12:
case COLOR_YUV2RGBA_NV21:
case COLOR_YUV2RGBA_YV12:
case COLOR_YUV2RGBA_IYUV:
case COLOR_YUV2RGBA_UYVY:
//case COLOR_YUV2RGBA_VYUY:
case COLOR_YUV2RGBA_YUY2:
case COLOR_YUV2RGBA_YVYU:
return new RGBA8888Writer();
case CV_YUV2BGRA_NV12:
case CV_YUV2BGRA_NV21:
case CV_YUV2BGRA_YV12:
case CV_YUV2BGRA_IYUV:
case CV_YUV2BGRA_UYVY:
//case CV_YUV2BGRA_VYUY:
case CV_YUV2BGRA_YUY2:
case CV_YUV2BGRA_YVYU:
case COLOR_YUV2BGRA_NV12:
case COLOR_YUV2BGRA_NV21:
case COLOR_YUV2BGRA_YV12:
case COLOR_YUV2BGRA_IYUV:
case COLOR_YUV2BGRA_UYVY:
//case COLOR_YUV2BGRA_VYUY:
case COLOR_YUV2BGRA_YUY2:
case COLOR_YUV2BGRA_YVYU:
return new BGRA8888Writer();
default:
return 0;
@@ -487,9 +487,9 @@ GRAYwriter* GRAYwriter::getWriter(int code)
{
switch(code)
{
case CV_YUV2GRAY_420:
case CV_YUV2GRAY_UYVY:
case CV_YUV2GRAY_YUY2:
case COLOR_YUV2GRAY_420:
case COLOR_YUV2GRAY_UYVY:
case COLOR_YUV2GRAY_YUY2:
return new GRAYwriter();
default:
return 0;
@@ -500,15 +500,15 @@ YUVwriter* YUVwriter::getWriter(int code)
{
switch(code)
{
case CV_RGB2YUV_YV12:
case CV_BGR2YUV_YV12:
case CV_RGBA2YUV_YV12:
case CV_BGRA2YUV_YV12:
case COLOR_RGB2YUV_YV12:
case COLOR_BGR2YUV_YV12:
case COLOR_RGBA2YUV_YV12:
case COLOR_BGRA2YUV_YV12:
return new YV12Writer();
case CV_RGB2YUV_I420:
case CV_BGR2YUV_I420:
case CV_RGBA2YUV_I420:
case CV_BGRA2YUV_I420:
case COLOR_RGB2YUV_I420:
case COLOR_BGR2YUV_I420:
case COLOR_RGBA2YUV_I420:
case COLOR_BGRA2YUV_I420:
return new I420Writer();
default:
return 0;
@@ -611,16 +611,16 @@ struct ConversionYUV
GRAYwriter* grayWriter_;
};
CV_ENUM(YUVCVTS, CV_YUV2RGB_NV12, CV_YUV2BGR_NV12, CV_YUV2RGB_NV21, CV_YUV2BGR_NV21,
CV_YUV2RGBA_NV12, CV_YUV2BGRA_NV12, CV_YUV2RGBA_NV21, CV_YUV2BGRA_NV21,
CV_YUV2RGB_YV12, CV_YUV2BGR_YV12, CV_YUV2RGB_IYUV, CV_YUV2BGR_IYUV,
CV_YUV2RGBA_YV12, CV_YUV2BGRA_YV12, CV_YUV2RGBA_IYUV, CV_YUV2BGRA_IYUV,
CV_YUV2RGB_UYVY, CV_YUV2BGR_UYVY, CV_YUV2RGBA_UYVY, CV_YUV2BGRA_UYVY,
CV_YUV2RGB_YUY2, CV_YUV2BGR_YUY2, CV_YUV2RGB_YVYU, CV_YUV2BGR_YVYU,
CV_YUV2RGBA_YUY2, CV_YUV2BGRA_YUY2, CV_YUV2RGBA_YVYU, CV_YUV2BGRA_YVYU,
CV_YUV2GRAY_420, CV_YUV2GRAY_UYVY, CV_YUV2GRAY_YUY2,
CV_YUV2BGR, CV_YUV2RGB, CV_RGB2YUV_YV12, CV_BGR2YUV_YV12, CV_RGBA2YUV_YV12,
CV_BGRA2YUV_YV12, CV_RGB2YUV_I420, CV_BGR2YUV_I420, CV_RGBA2YUV_I420, CV_BGRA2YUV_I420)
CV_ENUM(YUVCVTS, COLOR_YUV2RGB_NV12, COLOR_YUV2BGR_NV12, COLOR_YUV2RGB_NV21, COLOR_YUV2BGR_NV21,
COLOR_YUV2RGBA_NV12, COLOR_YUV2BGRA_NV12, COLOR_YUV2RGBA_NV21, COLOR_YUV2BGRA_NV21,
COLOR_YUV2RGB_YV12, COLOR_YUV2BGR_YV12, COLOR_YUV2RGB_IYUV, COLOR_YUV2BGR_IYUV,
COLOR_YUV2RGBA_YV12, COLOR_YUV2BGRA_YV12, COLOR_YUV2RGBA_IYUV, COLOR_YUV2BGRA_IYUV,
COLOR_YUV2RGB_UYVY, COLOR_YUV2BGR_UYVY, COLOR_YUV2RGBA_UYVY, COLOR_YUV2BGRA_UYVY,
COLOR_YUV2RGB_YUY2, COLOR_YUV2BGR_YUY2, COLOR_YUV2RGB_YVYU, COLOR_YUV2BGR_YVYU,
COLOR_YUV2RGBA_YUY2, COLOR_YUV2BGRA_YUY2, COLOR_YUV2RGBA_YVYU, COLOR_YUV2BGRA_YVYU,
COLOR_YUV2GRAY_420, COLOR_YUV2GRAY_UYVY, COLOR_YUV2GRAY_YUY2,
COLOR_YUV2BGR, COLOR_YUV2RGB, COLOR_RGB2YUV_YV12, COLOR_BGR2YUV_YV12, COLOR_RGBA2YUV_YV12,
COLOR_BGRA2YUV_YV12, COLOR_RGB2YUV_I420, COLOR_BGR2YUV_I420, COLOR_RGBA2YUV_I420, COLOR_BGRA2YUV_I420)
typedef ::testing::TestWithParam<YUVCVTS> Imgproc_ColorYUV;
@@ -710,18 +710,18 @@ TEST_P(Imgproc_ColorYUV, roi_accuracy)
}
INSTANTIATE_TEST_CASE_P(cvt420, Imgproc_ColorYUV,
::testing::Values((int)CV_YUV2RGB_NV12, (int)CV_YUV2BGR_NV12, (int)CV_YUV2RGB_NV21, (int)CV_YUV2BGR_NV21,
(int)CV_YUV2RGBA_NV12, (int)CV_YUV2BGRA_NV12, (int)CV_YUV2RGBA_NV21, (int)CV_YUV2BGRA_NV21,
(int)CV_YUV2RGB_YV12, (int)CV_YUV2BGR_YV12, (int)CV_YUV2RGB_IYUV, (int)CV_YUV2BGR_IYUV,
(int)CV_YUV2RGBA_YV12, (int)CV_YUV2BGRA_YV12, (int)CV_YUV2RGBA_IYUV, (int)CV_YUV2BGRA_IYUV,
(int)CV_YUV2GRAY_420, (int)CV_RGB2YUV_YV12, (int)CV_BGR2YUV_YV12, (int)CV_RGBA2YUV_YV12,
(int)CV_BGRA2YUV_YV12, (int)CV_RGB2YUV_I420, (int)CV_BGR2YUV_I420, (int)CV_RGBA2YUV_I420,
(int)CV_BGRA2YUV_I420));
::testing::Values((int)COLOR_YUV2RGB_NV12, (int)COLOR_YUV2BGR_NV12, (int)COLOR_YUV2RGB_NV21, (int)COLOR_YUV2BGR_NV21,
(int)COLOR_YUV2RGBA_NV12, (int)COLOR_YUV2BGRA_NV12, (int)COLOR_YUV2RGBA_NV21, (int)COLOR_YUV2BGRA_NV21,
(int)COLOR_YUV2RGB_YV12, (int)COLOR_YUV2BGR_YV12, (int)COLOR_YUV2RGB_IYUV, (int)COLOR_YUV2BGR_IYUV,
(int)COLOR_YUV2RGBA_YV12, (int)COLOR_YUV2BGRA_YV12, (int)COLOR_YUV2RGBA_IYUV, (int)COLOR_YUV2BGRA_IYUV,
(int)COLOR_YUV2GRAY_420, (int)COLOR_RGB2YUV_YV12, (int)COLOR_BGR2YUV_YV12, (int)COLOR_RGBA2YUV_YV12,
(int)COLOR_BGRA2YUV_YV12, (int)COLOR_RGB2YUV_I420, (int)COLOR_BGR2YUV_I420, (int)COLOR_RGBA2YUV_I420,
(int)COLOR_BGRA2YUV_I420));
INSTANTIATE_TEST_CASE_P(cvt422, Imgproc_ColorYUV,
::testing::Values((int)CV_YUV2RGB_UYVY, (int)CV_YUV2BGR_UYVY, (int)CV_YUV2RGBA_UYVY, (int)CV_YUV2BGRA_UYVY,
(int)CV_YUV2RGB_YUY2, (int)CV_YUV2BGR_YUY2, (int)CV_YUV2RGB_YVYU, (int)CV_YUV2BGR_YVYU,
(int)CV_YUV2RGBA_YUY2, (int)CV_YUV2BGRA_YUY2, (int)CV_YUV2RGBA_YVYU, (int)CV_YUV2BGRA_YVYU,
(int)CV_YUV2GRAY_UYVY, (int)CV_YUV2GRAY_YUY2));
::testing::Values((int)COLOR_YUV2RGB_UYVY, (int)COLOR_YUV2BGR_UYVY, (int)COLOR_YUV2RGBA_UYVY, (int)COLOR_YUV2BGRA_UYVY,
(int)COLOR_YUV2RGB_YUY2, (int)COLOR_YUV2BGR_YUY2, (int)COLOR_YUV2RGB_YVYU, (int)COLOR_YUV2BGR_YVYU,
(int)COLOR_YUV2RGBA_YUY2, (int)COLOR_YUV2BGRA_YUY2, (int)COLOR_YUV2RGBA_YVYU, (int)COLOR_YUV2BGRA_YVYU,
(int)COLOR_YUV2GRAY_UYVY, (int)COLOR_YUV2GRAY_YUY2));
}} // namespace
@@ -359,7 +359,7 @@ int CV_GoodFeatureToTTest::prepare_test_case( int test_case_idx )
CV_Assert(src.data != NULL);
cvtColor( src, src_gray, CV_BGR2GRAY );
cvtColor( src, src_gray, COLOR_BGR2GRAY );
SrcType = types[test_case_idx & 0x1];
useHarrisDetector = test_case_idx & 2 ? true : false;
return 1;
+47
View File
@@ -528,7 +528,30 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols
return 0;
}
//
// int Mat::size(int i)
//
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1size_1i__JI
(JNIEnv* env, jclass, jlong self, jint i);
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1size_1i__JI
(JNIEnv* env, jclass, jlong self, jint i)
{
static const char method_name[] = "Mat::n_1size_1i__JI()";
try {
LOGD("%s", method_name);
Mat* me = (Mat*) self; //TODO: check for NULL
int _retval_ = me->size[i];
return _retval_;
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
return 0;
}
//
// void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0)
@@ -1307,7 +1330,31 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI
return 0;
}
//
// Mat Mat::reshape(int cn, int[] newshape)
//
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape_11
(JNIEnv* env, jclass, jlong self, jint cn, jint newndims, jintArray newshape);
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape_11
(JNIEnv* env, jclass, jlong self, jint cn, jint newndims, jintArray newshape)
{
static const char method_name[] = "Mat::n_1reshape_11";
try {
LOGD("%s", method_name);
Mat* me = (Mat*) self; //TODO: check for NULL
int* newsz = (int*)env->GetPrimitiveArrayCritical(newshape, 0);
Mat _retval_ = me->reshape( cn, newndims, newsz );
return (jlong) new Mat(_retval_);
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
return 0;
}
//
// Mat Mat::row(int y)
-2
View File
@@ -203,7 +203,6 @@ vector<Point2f> QRDetect::separateVerticalLines(const vector<Vec3d> &list_lines)
{
result.push_back(list_lines[pnt]);
}
}
}
@@ -433,7 +432,6 @@ bool QRDetect::computeTransformationPoints()
list_edge_points.push_back(up_right_edge_point);
double temp_area = fabs(contourArea(list_edge_points));
if (max_area < temp_area)
{
up_left_edge_point = new_non_zero_elem[0][i];
+2 -1
View File
@@ -1178,6 +1178,7 @@ if __name__ == "__main__":
if len(sys.argv) > 1:
dstdir = sys.argv[1]
if len(sys.argv) > 2:
srcfiles = [f.strip() for f in open(sys.argv[2], 'r').readlines()]
with open(sys.argv[2], 'r') as f:
srcfiles = [l.strip() for l in f.readlines()]
generator = PythonWrapperGenerator()
generator.gen(srcfiles, dstdir)
+112 -4
View File
@@ -1963,6 +1963,7 @@ static inline bool cv_ff_codec_tag_match(const AVCodecTag *tags, CV_CODEC_ID id,
}
return false;
}
static inline bool cv_ff_codec_tag_list_match(const AVCodecTag *const *tags, CV_CODEC_ID id, unsigned int tag)
{
int i;
@@ -1974,6 +1975,21 @@ static inline bool cv_ff_codec_tag_list_match(const AVCodecTag *const *tags, CV_
return false;
}
static inline void cv_ff_codec_tag_dump(const AVCodecTag *const *tags)
{
int i;
for (i = 0; tags && tags[i]; i++) {
const AVCodecTag * ptags = tags[i];
while (ptags->id != AV_CODEC_ID_NONE)
{
unsigned int tag = ptags->tag;
printf("fourcc tag 0x%08x/'%c%c%c%c' codec_id %04X\n", tag, CV_TAG_TO_PRINTABLE_CHAR4(tag), ptags->id);
ptags++;
}
}
}
/// Create a video writer object that uses FFMPEG
bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
double fps, int width, int height, bool is_color )
@@ -2017,6 +2033,13 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
input_pix_fmt = AV_PIX_FMT_GRAY8;
}
if (fourcc == -1)
{
fprintf(stderr,"OpenCV: FFMPEG: format %s / %s\n", fmt->name, fmt->long_name);
cv_ff_codec_tag_dump(fmt->codec_tag);
return false;
}
/* Lookup codec_id for given fourcc */
#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
if( (codec_id = codec_get_bmp_id( fourcc )) == CV_CODEC(CODEC_ID_NONE) )
@@ -2048,6 +2071,8 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
return false;
}
}
// validate tag
if (cv_ff_codec_tag_list_match(fmt->codec_tag, codec_id, fourcc) == false)
{
@@ -2085,11 +2110,78 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
#if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0)
case CV_CODEC(CODEC_ID_JPEGLS):
// BGR24 or GRAY8 depending on is_color...
// supported: bgr24 rgb24 gray gray16le
// as of version 3.4.1
codec_pix_fmt = input_pix_fmt;
break;
#endif
case CV_CODEC(CODEC_ID_HUFFYUV):
codec_pix_fmt = AV_PIX_FMT_YUV422P;
// supported: yuv422p rgb24 bgra
// as of version 3.4.1
switch(input_pix_fmt)
{
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_BGRA:
codec_pix_fmt = input_pix_fmt;
break;
case AV_PIX_FMT_BGR24:
codec_pix_fmt = AV_PIX_FMT_RGB24;
break;
default:
codec_pix_fmt = AV_PIX_FMT_YUV422P;
break;
}
break;
case CV_CODEC(CODEC_ID_PNG):
// supported: rgb24 rgba rgb48be rgba64be pal8 gray ya8 gray16be ya16be monob
// as of version 3.4.1
switch(input_pix_fmt)
{
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GRAY16BE:
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_BGRA:
codec_pix_fmt = input_pix_fmt;
break;
case AV_PIX_FMT_GRAY16LE:
codec_pix_fmt = AV_PIX_FMT_GRAY16BE;
break;
case AV_PIX_FMT_BGR24:
codec_pix_fmt = AV_PIX_FMT_RGB24;
break;
default:
codec_pix_fmt = AV_PIX_FMT_YUV422P;
break;
}
break;
case CV_CODEC(CODEC_ID_FFV1):
// supported: MANY
// as of version 3.4.1
switch(input_pix_fmt)
{
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GRAY16LE:
#ifdef AV_PIX_FMT_BGR0
case AV_PIX_FMT_BGR0:
#endif
case AV_PIX_FMT_BGRA:
codec_pix_fmt = input_pix_fmt;
break;
case AV_PIX_FMT_GRAY16BE:
codec_pix_fmt = AV_PIX_FMT_GRAY16LE;
break;
case AV_PIX_FMT_BGR24:
case AV_PIX_FMT_RGB24:
#ifdef AV_PIX_FMT_BGR0
codec_pix_fmt = AV_PIX_FMT_BGR0;
#else
codec_pix_fmt = AV_PIX_FMT_BGRA;
#endif
break;
default:
codec_pix_fmt = AV_PIX_FMT_YUV422P;
break;
}
break;
case CV_CODEC(CODEC_ID_MJPEG):
case CV_CODEC(CODEC_ID_LJPEG):
@@ -2097,9 +2189,25 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
bitrate_scale = 3;
break;
case CV_CODEC(CODEC_ID_RAWVIDEO):
codec_pix_fmt = input_pix_fmt == AV_PIX_FMT_GRAY8 ||
input_pix_fmt == AV_PIX_FMT_GRAY16LE ||
input_pix_fmt == AV_PIX_FMT_GRAY16BE ? input_pix_fmt : AV_PIX_FMT_YUV420P;
// RGBA is the only RGB fourcc supported by AVI and MKV format
if(fourcc == CV_FOURCC('R','G','B','A'))
{
codec_pix_fmt = AV_PIX_FMT_RGBA;
}
else
{
switch(input_pix_fmt)
{
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_GRAY16BE:
codec_pix_fmt = input_pix_fmt;
break;
default:
codec_pix_fmt = AV_PIX_FMT_YUV420P;
break;
}
}
break;
default:
// good for lossy formats, MPEG, etc.