Skip to content

Commit

Permalink
Merge pull request opencv#12246 from sturkmen72:move_enums
Browse files Browse the repository at this point in the history
* Update core.hpp

* Update imgproc.hpp

* Update ImgprocTest.java

* Update CameraCalibrator.java

* Update OnCameraFrameRender.java

* Update FindContoursDemo.java

* Update IntroductionToSVMDemo.java

* Update NonLinearSVMsDemo.java

* Update IntroductionToPCADemo.java

* Update Smoothing.java

* Update MainActivity.java

* Update CalcBackProjectDemo1.java

* Update CornerSubPixDemo.java

* Update CornerDetectorDemo.java

* Update GoodFeaturesToTrackDemo.java
  • Loading branch information
sturkmen72 authored and alalek committed Aug 24, 2018
1 parent 6356403 commit d8cd1d8
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 64 deletions.
21 changes: 0 additions & 21 deletions modules/core/include/opencv2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,6 @@ enum KmeansFlags {
KMEANS_USE_INITIAL_LABELS = 1
};

//! type of line
enum LineTypes {
FILLED = -1,
LINE_4 = 4, //!< 4-connected line
LINE_8 = 8, //!< 8-connected line
LINE_AA = 16 //!< antialiased line
};

//! Only a subset of Hershey fonts <https://en.wikipedia.org/wiki/Hershey_fonts> are supported
enum HersheyFonts {
FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font
FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font
FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX)
FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font
FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX)
FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX
FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font
FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX
FONT_ITALIC = 16 //!< flag for italic font
};

enum ReduceTypes { REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix.
REDUCE_AVG = 1, //!< the output is the mean vector of all rows/columns of the matrix.
REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all rows/columns of the matrix.
Expand Down
52 changes: 40 additions & 12 deletions modules/imgproc/include/opencv2/imgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,46 @@ enum RectanglesIntersectTypes {
INTERSECT_FULL = 2 //!< One of the rectangle is fully enclosed in the other
};


/** types of line
@ingroup imgproc_draw
*/
enum LineTypes {
FILLED = -1,
LINE_4 = 4, //!< 4-connected line
LINE_8 = 8, //!< 8-connected line
LINE_AA = 16 //!< antialiased line
};

/** Only a subset of Hershey fonts <https://en.wikipedia.org/wiki/Hershey_fonts> are supported
@ingroup imgproc_draw
*/
enum HersheyFonts {
FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font
FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font
FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX)
FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font
FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX)
FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX
FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font
FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX
FONT_ITALIC = 16 //!< flag for italic font
};

/** Possible set of marker types used for the cv::drawMarker function
@ingroup imgproc_draw
*/
enum MarkerTypes
{
MARKER_CROSS = 0, //!< A crosshair marker shape
MARKER_TILTED_CROSS = 1, //!< A 45 degree tilted crosshair marker shape
MARKER_STAR = 2, //!< A star marker shape, combination of cross and tilted cross
MARKER_DIAMOND = 3, //!< A diamond marker shape
MARKER_SQUARE = 4, //!< A square marker shape
MARKER_TRIANGLE_UP = 5, //!< An upwards pointing triangle marker shape
MARKER_TRIANGLE_DOWN = 6 //!< A downwards pointing triangle marker shape
};

//! finds arbitrary template in the grayscale image using Generalized Hough Transform
class CV_EXPORTS GeneralizedHough : public Algorithm
{
Expand Down Expand Up @@ -4430,18 +4470,6 @@ CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Sc
/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */
/* ----------------------------------------------------------------------------------------- */

//! Possible set of marker types used for the cv::drawMarker function
enum MarkerTypes
{
MARKER_CROSS = 0, //!< A crosshair marker shape
MARKER_TILTED_CROSS = 1, //!< A 45 degree tilted crosshair marker shape
MARKER_STAR = 2, //!< A star marker shape, combination of cross and tilted cross
MARKER_DIAMOND = 3, //!< A diamond marker shape
MARKER_SQUARE = 4, //!< A square marker shape
MARKER_TRIANGLE_UP = 5, //!< An upwards pointing triangle marker shape
MARKER_TRIANGLE_DOWN = 6 //!< A downwards pointing triangle marker shape
};

/** @brief Draws a marker on a predefined position in an image.
The function cv::drawMarker draws a marker on a given position in the image. For the moment several
Expand Down
26 changes: 13 additions & 13 deletions modules/imgproc/misc/java/test/ImgprocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1938,8 +1938,8 @@ public void testGetTextSize() {
int thickness = 3;
int baseLine[] = new int[1];

Imgproc.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null);
Size res = Imgproc.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine);
Imgproc.getTextSize(text, Imgproc.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null);
Size res = Imgproc.getTextSize(text, Imgproc.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine);

assertEquals(543.0, res.width);
assertEquals(44.0, res.height);
Expand All @@ -1961,7 +1961,7 @@ public void testCircleMatPointIntScalarInt() {
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
Scalar color = new Scalar(128);

Imgproc.circle(gray0, center, radius, color, Core.FILLED);
Imgproc.circle(gray0, center, radius, color, Imgproc.FILLED);

assertTrue(0 != Core.countNonZero(gray0));
}
Expand Down Expand Up @@ -2042,7 +2042,7 @@ public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() {
Size axes = new Size(2, 2);
double angle = 30, startAngle = 60, endAngle = 90;

Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED);
Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Imgproc.FILLED);

assertTrue(0 != Core.countNonZero(gray0));
}
Expand All @@ -2054,11 +2054,11 @@ public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() {
Size axes2 = new Size(4, 4);
double angle = 30, startAngle = 0, endAngle = 30;

Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Imgproc.LINE_4, 0);
Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Imgproc.FILLED, Imgproc.LINE_4, 0);

assertTrue(0 != Core.countNonZero(gray0));

Imgproc.ellipse(gray0, center2, axes2, angle, startAngle, endAngle, colorBlack, Core.FILLED, Imgproc.LINE_4, 1);
Imgproc.ellipse(gray0, center2, axes2, angle, startAngle, endAngle, colorBlack, Imgproc.FILLED, Imgproc.LINE_4, 1);

assertEquals(0, Core.countNonZero(gray0));
}
Expand Down Expand Up @@ -2096,7 +2096,7 @@ public void testEllipseMatRotatedRectScalarInt() {
Size size = new Size(matSize / 4, matSize / 2);
RotatedRect box = new RotatedRect(center, size, 45);

Imgproc.ellipse(gray0, box, new Scalar(1), Core.FILLED);
Imgproc.ellipse(gray0, box, new Scalar(1), Imgproc.FILLED);
Imgproc.ellipse(gray0, box, new Scalar(0));

assertTrue(0 < Core.countNonZero(gray0));
Expand Down Expand Up @@ -2159,11 +2159,11 @@ public void testPutTextMatStringPointIntDoubleScalar() {
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, labelSize.height + 10);

Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite);
Imgproc.putText(img, text, origin, Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite);

assertTrue(Core.countNonZero(img) > 0);
// check that border is not corrupted
Imgproc.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Core.FILLED);
Imgproc.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Imgproc.FILLED);
assertEquals(0, Core.countNonZero(img));
}

Expand All @@ -2173,11 +2173,11 @@ public void testPutTextMatStringPointIntDoubleScalarInt() {
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, labelSize.height + 10);

Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 2);
Imgproc.putText(img, text, origin, Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 2);

assertTrue(Core.countNonZero(img) > 0);
// check that border is not corrupted
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10 + 1, labelSize.height + 10 + 1), colorBlack, Core.FILLED);
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10 + 1, labelSize.height + 10 + 1), colorBlack, Imgproc.FILLED);
assertEquals(0, Core.countNonZero(img));
}

Expand All @@ -2188,11 +2188,11 @@ public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() {
Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
Point origin = new Point(10, 10);

Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Imgproc.LINE_8, true);
Imgproc.putText(img, text, origin, Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Imgproc.LINE_8, true);

assertTrue(Core.countNonZero(img) > 0);
// check that border is not corrupted
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Core.FILLED);
Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Imgproc.FILLED);
assertEquals(0, Core.countNonZero(img));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void renderFrame(Mat rgbaFrame) {
drawPoints(rgbaFrame);

Imgproc.putText(rgbaFrame, "Captured: " + mCornersBuffer.size(), new Point(rgbaFrame.cols() / 3 * 2, rgbaFrame.rows() * 0.1),
Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));
Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));
}

public Mat getCameraMatrix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public Mat render(CvCameraViewFrame inputFrame) {
Imgproc.fillPoly(comparisonFrame, border, new Scalar(255, 255, 255));

Imgproc.putText(comparisonFrame, mResources.getString(R.string.original), new Point(mWidth * 0.1, mHeight * 0.1),
Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));
Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));
Imgproc.putText(comparisonFrame, mResources.getString(R.string.undistorted), new Point(mWidth * 0.6, mHeight * 0.1),
Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));
Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0));

return comparisonFrame;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
new Scalar(0, 255, 0));
String label = classNames[classId] + ": " + confidence;
int[] baseLine = new int[1];
Size labelSize = Imgproc.getTextSize(label, Core.FONT_HERSHEY_SIMPLEX, 0.5, 1, baseLine);
Size labelSize = Imgproc.getTextSize(label, Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, 1, baseLine);

// Draw background for label.
Imgproc.rectangle(subFrame, new Point(xLeftBottom, yLeftBottom - labelSize.height),
new Point(xLeftBottom + labelSize.width, yLeftBottom + baseLine[0]),
new Scalar(255, 255, 255), Core.FILLED);
new Scalar(255, 255, 255), Imgproc.FILLED);

// Write class name and confidence.
Imgproc.putText(subFrame, label, new Point(xLeftBottom, yLeftBottom),
Core.FONT_HERSHEY_SIMPLEX, 0.5, new Scalar(0, 0, 0));
Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, new Scalar(0, 0, 0));
}
}
return frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void update() {
hist.get(0, 0, histData);
for (int i = 0; i < bins; i++) {
Imgproc.rectangle(histImg, new Point(i * binW, h),
new Point((i + 1) * binW, h - Math.round(histData[i] * h / 255.0)), new Scalar(0, 0, 255), Core.FILLED);
new Point((i + 1) * binW, h - Math.round(histData[i] * h / 255.0)), new Scalar(0, 0, 255), Imgproc.FILLED);
}
Image histImage = HighGui.toBufferedImage(histImg);
histImgLabel.setIcon(new ImageIcon(histImage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int displayCaption(String caption) {
dst = Mat.zeros(src.size(), src.type());
Imgproc.putText(dst, caption,
new Point(src.cols() / 4, src.rows() / 2),
Core.FONT_HERSHEY_COMPLEX, 1, new Scalar(255, 255, 255));
Imgproc.FONT_HERSHEY_COMPLEX, 1, new Scalar(255, 255, 255));

return displayDst(DELAY_CAPTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void update() {
Mat drawing = Mat.zeros(cannyOutput.size(), CvType.CV_8UC3);
for (int i = 0; i < contours.size(); i++) {
Scalar color = new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256));
Imgproc.drawContours(drawing, contours, i, color, 2, Core.LINE_8, hierarchy, 0, new Point());
Imgproc.drawContours(drawing, contours, i, color, 2, Imgproc.LINE_8, hierarchy, 0, new Point());
}

imgContoursLabel.setIcon(new ImageIcon(HighGui.toBufferedImage(drawing)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void update() {
matCorners.get(0, 0, matCornersData);
for (int i = 0; i < corners.rows(); i++) {
Imgproc.circle(copy, new Point(cornersData[i * 2], cornersData[i * 2 + 1]), radius,
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Core.FILLED);
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Imgproc.FILLED);
matCornersData[i * 2] = cornersData[i * 2];
matCornersData[i * 2 + 1] = cornersData[i * 2 + 1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void update() {
if (McData[i * srcGray.cols() + j] > harrisMinVal
+ (harrisMaxVal - harrisMinVal) * qualityLevelVal / MAX_QUALITY_LEVEL) {
Imgproc.circle(harrisCopy, new Point(j, i), 4,
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Core.FILLED);
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Imgproc.FILLED);
}
}
}
Expand All @@ -162,7 +162,7 @@ private void update() {
if (shiTomasiData[i * srcGray.cols() + j] > shiTomasiMinVal
+ (shiTomasiMaxVal - shiTomasiMinVal) * qualityLevelVal / MAX_QUALITY_LEVEL) {
Imgproc.circle(shiTomasiCopy, new Point(j, i), 4,
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Core.FILLED);
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Imgproc.FILLED);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void update() {
int radius = 4;
for (int i = 0; i < corners.rows(); i++) {
Imgproc.circle(copy, new Point(cornersData[i * 2], cornersData[i * 2 + 1]), radius,
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Core.FILLED);
new Scalar(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)), Imgproc.FILLED);
}

imgLabel.setIcon(new ImageIcon(HighGui.toBufferedImage(copy)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ private void drawAxis(Mat img, Point p_, Point q_, Scalar colour, float scale) {
// Here we lengthen the arrow by a factor of scale
q.x = (int) (p.x - scale * hypotenuse * Math.cos(angle));
q.y = (int) (p.y - scale * hypotenuse * Math.sin(angle));
Imgproc.line(img, p, q, colour, 1, Core.LINE_AA, 0);
Imgproc.line(img, p, q, colour, 1, Imgproc.LINE_AA, 0);

// create the arrow hooks
p.x = (int) (q.x + 9 * Math.cos(angle + Math.PI / 4));
p.y = (int) (q.y + 9 * Math.sin(angle + Math.PI / 4));
Imgproc.line(img, p, q, colour, 1, Core.LINE_AA, 0);
Imgproc.line(img, p, q, colour, 1, Imgproc.LINE_AA, 0);

p.x = (int) (q.x + 9 * Math.cos(angle - Math.PI / 4));
p.y = (int) (q.y + 9 * Math.sin(angle - Math.PI / 4));
Imgproc.line(img, p, q, colour, 1, Core.LINE_AA, 0);
Imgproc.line(img, p, q, colour, 1, Imgproc.LINE_AA, 0);
//! [visualization1]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void main(String[] args) {
// Show the training data
//! [show_data]
int thickness = -1;
int lineType = Core.LINE_8;
int lineType = Imgproc.LINE_8;
Imgproc.circle(image, new Point(501, 10), 5, new Scalar(0, 0, 0), thickness, lineType, 0);
Imgproc.circle(image, new Point(255, 10), 5, new Scalar(255, 255, 255), thickness, lineType, 0);
Imgproc.circle(image, new Point(501, 255), 5, new Scalar(255, 255, 255), thickness, lineType, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static void main(String[] args) {
// ----------------------- 5. Show the training data--------------------------------------------
//! [show_data]
int thick = -1;
int lineType = Core.LINE_8;
int lineType = Imgproc.LINE_8;
float px, py;
// Class 1
float[] trainDataData = new float[(int) (trainData.total() * trainData.channels())];
Expand Down

0 comments on commit d8cd1d8

Please sign in to comment.