本文整理汇总了Java中org.opencv.core.Core.bitwise_and方法的典型用法代码示例。如果您正苦于以下问题:Java Core.bitwise_and方法的具体用法?Java Core.bitwise_and怎么用?Java Core.bitwise_and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.core.Core
的用法示例。
在下文中一共展示了Core.bitwise_and方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: skinDetection
import org.opencv.core.Core; //导入方法依赖的package包/类
public Mat skinDetection(Mat src) {
// define the upper and lower boundaries of the HSV pixel
// intensities to be considered 'skin'
Scalar lower = new Scalar(0, 48, 80);
Scalar upper = new Scalar(20, 255, 255);
// Convert to HSV
Mat hsvFrame = new Mat(src.rows(), src.cols(), CvType.CV_8U, new Scalar(3));
Imgproc.cvtColor(src, hsvFrame, Imgproc.COLOR_RGB2HSV, 3);
// Mask the image for skin colors
Mat skinMask = new Mat(hsvFrame.rows(), hsvFrame.cols(), CvType.CV_8U, new Scalar(3));
Core.inRange(hsvFrame, lower, upper, skinMask);
// currentSkinMask = new Mat(hsvFrame.rows(), hsvFrame.cols(), CvType.CV_8U, new Scalar(3));
// skinMask.copyTo(currentSkinMask);
// apply a series of erosions and dilations to the mask
// using an elliptical kernel
final Size kernelSize = new Size(11, 11);
final Point anchor = new Point(-1, -1);
final int iterations = 2;
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, kernelSize);
Imgproc.erode(skinMask, skinMask, kernel, anchor, iterations);
Imgproc.dilate(skinMask, skinMask, kernel, anchor, iterations);
// blur the mask to help remove noise, then apply the
// mask to the frame
final Size ksize = new Size(3, 3);
Mat skin = new Mat(skinMask.rows(), skinMask.cols(), CvType.CV_8U, new Scalar(3));
Imgproc.GaussianBlur(skinMask, skinMask, ksize, 0);
Core.bitwise_and(src, src, skin, skinMask);
return skin;
}
示例2: iRCF_NH_ME
import org.opencv.core.Core; //导入方法依赖的package包/类
public static Mat[] iRCF_NH_ME(Mat image, int blurVal, double minAreaSize, int offset) {
Mat[] matSet = new Mat[3];
// MatView.imshow(image, "Ori");
final Mat gray = new Mat();
Imgproc.cvtColor(image, gray, Imgproc.COLOR_RGB2GRAY);
final double percentOfCrop = 0.5;
final Rect rect = new Rect((int) (gray.width() * percentOfCrop / 2), (int) (gray.height() * percentOfCrop / 2),
(int) (gray.width() * (1 - percentOfCrop)), (int) (gray.height() * (1 - percentOfCrop)));
final Mat findThresh = gray.clone().submat(rect);
final double thresh = Imgproc.threshold(findThresh, findThresh, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
Mat roi = ROI_Irregular.RectangleSubROI(gray, rect);
Imgproc.GaussianBlur(roi, roi, new Size(blurVal, blurVal), 0);
// MatView.imshow(roi, "ROI");
Imgproc.threshold(roi, roi, thresh, 255, Imgproc.THRESH_BINARY);
// MatView.imshow(roi, "Bin");
matSet = largestContour(image.clone(), roi, minAreaSize, offset);
final Mat emptyBox = matSet[2];
// MatView.imshow(emptyBox, "EmptyBox");
roi = matSet[0];
// MatView.imshow(roi, "Contour");
Core.subtract(roi, emptyBox, roi);
// Core.bitwise_xor(roi, emptyBox, roi);
// MatView.imshow(roi, "Contour2");
final Mat box = matSet[1];
// MatView.imshow(box, "Box");
Core.bitwise_and(image, roi, roi);
// MatView.imshow(roi, "Final ROI1");
return matSet;
}