本文整理匯總了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;
}