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.
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
{
/* 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
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);
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));
}
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));
}
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));
}
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));
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));
}
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));
}
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));
}
}
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() {
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;
}
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;
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));
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);
}
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)));
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];
}
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);
}
}
}
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);
}
}
}
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)));
// 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]
}
// 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);
// ----------------------- 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())];