本文整理汇总了Java中org.opencv.imgproc.Imgproc.circle方法的典型用法代码示例。如果您正苦于以下问题:Java Imgproc.circle方法的具体用法?Java Imgproc.circle怎么用?Java Imgproc.circle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.imgproc.Imgproc
的用法示例。
在下文中一共展示了Imgproc.circle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCameraFrame
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
final int viewMode = mViewMode;
switch (viewMode) {
case VIEW_MODE_OPTICAL_FLOW:
mGray = inputFrame.gray();
if(features.toArray().length==0){
int rowStep = 50, colStep = 100;
int nRows = mGray.rows()/rowStep, nCols = mGray.cols()/colStep;
// Log.d(TAG, "\nRows: "+nRows+"\nCols: "+nCols+"\n");
Point points[] = new Point[nRows*nCols];
for(int i=0; i<nRows; i++){
for(int j=0; j<nCols; j++){
points[i*nCols+j]=new Point(j*colStep, i*rowStep);
// Log.d(TAG, "\nRow: "+i*rowStep+"\nCol: "+j*colStep+"\n: ");
}
}
features.fromArray(points);
prevFeatures.fromList(features.toList());
mPrevGray = mGray.clone();
break;
}
nextFeatures.fromArray(prevFeatures.toArray());
Video.calcOpticalFlowPyrLK(mPrevGray, mGray, prevFeatures, nextFeatures, status, err);
List<Point> prevList=features.toList(), nextList=nextFeatures.toList();
Scalar color = new Scalar(255);
for(int i = 0; i<prevList.size(); i++){
// Core.circle(mGray, prevList.get(i), 5, color);
Imgproc.line(mGray, prevList.get(i), nextList.get(i), color);
}
mPrevGray = mGray.clone();
break;
case VIEW_MODE_KLT_TRACKER:
mGray = inputFrame.gray();
if(features.toArray().length==0){
Imgproc.goodFeaturesToTrack(mGray, features, 10, 0.01, 10);
Log.d(TAG, features.toList().size()+"");
prevFeatures.fromList(features.toList());
mPrevGray = mGray.clone();
// prevFeatures.fromList(nextFeatures.toList());
break;
}
// OpticalFlow(mPrevGray.getNativeObjAddr(), mGray.getNativeObjAddr(), prevFeatures.getNativeObjAddr(), nextFeatures.getNativeObjAddr());
Video.calcOpticalFlowPyrLK(mPrevGray, mGray, prevFeatures, nextFeatures, status, err);
List<Point> drawFeature = nextFeatures.toList();
// Log.d(TAG, drawFeature.size()+"");
for(int i = 0; i<drawFeature.size(); i++){
Point p = drawFeature.get(i);
Imgproc.circle(mGray, p, 5, new Scalar(255));
}
mPrevGray = mGray.clone();
prevFeatures.fromList(nextFeatures.toList());
break;
default: mViewMode = VIEW_MODE_KLT_TRACKER;
}
return mGray;
}
示例2: displayResults
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public Mat displayResults(Mat frame) {
//draw boxes and centroids
if (tracks != null) {
for (int i=0; i<tracks.length; i++) {
if (tracks[i].totalVisibleCount > 20) {
Imgproc.rectangle(frame, new Point(tracks[i].bbox.x, tracks[i].bbox.y),
new Point(tracks[i].bbox.x + tracks[i].bbox.width, tracks[i].bbox.y + tracks[i].bbox.height), new Scalar(255, 0, 0));
Imgproc.putText(frame, Integer.toString(tracks[i].id),
new Point(tracks[i].bbox.x, tracks[i].bbox.y),
Core.FONT_HERSHEY_PLAIN, 1.0, new Scalar(255,0,0));
Imgproc.circle(frame, new Point(tracks[i].kalmanPredict()[0], tracks[i].kalmanPredict()[1]), 4, new Scalar(255,100,100));
}
}
}
return frame;
}
示例3: pointMapList
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void pointMapList(Mat input, List<Map<Point, Double>> list, int radiusRatio, int thickness,
int mosaicLength) {
for (int i = 0; i < list.size(); i++) {
Map dataMap = new HashMap<>();
dataMap = list.get(i);
final Set<Map.Entry<Point, Double>> entryseSet = dataMap.entrySet();
for (final Map.Entry<Point, Double> entry : entryseSet) {
final Point p = entry.getKey();
double v = entry.getValue();
if (Double.isInfinite(entry.getValue())) {
v = 1;
}
final int radius = (new Double(radiusRatio * v)).intValue();
Imgproc.circle(input, new Point(p.x * mosaicLength, p.y * mosaicLength), radius,
new Scalar(255, 0, 255), thickness);
}
}
// System.out.println("Done Drawing");
}
示例4: trackLaser
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
private void trackLaser()
{
Imgproc.cvtColor(frame,hsv , Imgproc.COLOR_BGR2HSV);
//shiny RED Color
Scalar lowerScale = new Scalar(0, 0, 255);
Scalar upperScale = new Scalar(255, 255, 255);
Core.inRange(hsv, lowerScale, upperScale, mask);
matOfPoints.clear();
Imgproc.findContours(mask, matOfPoints, heir , Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
if (matOfPoints.size() > 0) {
float[] radius = new float[1];
Point[] matOfPoint = matOfPoints.get(maxPoint(matOfPoints)).toArray();
Imgproc.minEnclosingCircle(new MatOfPoint2f(matOfPoint), laserCenter,radius);
//Trigger Listener up here
Imgproc.circle(frame, laserCenter, 7, new Scalar(255, 0, 0), 2);
Imgproc.circle(mask, laserCenter, 7, new Scalar(255, 0, 0), 2);
triggerLaserDetectionFrame(laserCenter);
}
triggerProcessingListeners(onFrameProcessedListeners, frame);
triggerProcessingListeners(onMaskProcessedListeners, mask);
}
示例5: drawFaceShapes
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void drawFaceShapes(Rect face, Mat matrixRGBA) {
Point start = face.tl();
int h = (int) start.y + (face.height / 2);
int w = (int) start.x + (face.width / 2);
Imgproc.rectangle(matrixRGBA, start, face.br(),
FACE_RECT_COLOR, 3);
Point center = new Point(w, h);
Imgproc.circle(matrixRGBA, center, 10, new Scalar(255, 0, 0, 255), 3);
}
示例6: Circle
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static Mat Circle(Mat circularInput, Point cc, int radius) {
final Mat maskCopyTo = Mat.zeros(circularInput.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��
// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
final Mat maskFloodFill = Mat.zeros(new Size(circularInput.cols() + 2, circularInput.rows() + 2),
CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
Imgproc.circle(maskCopyTo, new Point(cc.x, cc.y), radius, Scalar.all(255), 2, 8, 0); // ����Բ������
Imgproc.floodFill(maskCopyTo, maskFloodFill, new Point(207, 290), Scalar.all(255), null, Scalar.all(20),
Scalar.all(20), 4); // ��ˮ��䷨���Բ���ڲ�
// MatView.imshow(maskFloodFill, "Mask of floodFill"); // ����floodFill������mask
// MatView.imshow(maskCopyTo, "Mask of copyTo"); // ����copyTo������mask
final Mat imgCircularROI = new Mat();
circularInput.copyTo(imgCircularROI, maskCopyTo); // ��ȡԲ�ε�ROI
// MatView.imshow(imgCircularROI, "Circular ROI"); // ��ʾԲ�ε�ROI
return imgCircularROI;
}
示例7: pointList
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void pointList(Mat input, List<Point> list, int radius, int size) {
for (int i = 0; i < list.size(); i++) {
final Point p = list.get(i);
Imgproc.circle(input, p, radius, new Scalar(255, 0, 255), size);
}
System.out.println("Done Drawing");
}
示例8: onCameraFrame
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
Mat input = inputFrame.gray();
Mat circles = new Mat();
Imgproc.blur(input, input, new Size(7, 7), new Point(2, 2));
Imgproc.HoughCircles(input, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 100, 100, 90, 0, 1000);
Log.i(TAG, String.valueOf("size: " + circles.cols()) + ", " + String.valueOf(circles.rows()));
if (circles.cols() > 0) {
for (int x=0; x < Math.min(circles.cols(), 5); x++ ) {
double circleVec[] = circles.get(0, x);
if (circleVec == null) {
break;
}
Point center = new Point((int) circleVec[0], (int) circleVec[1]);
int radius = (int) circleVec[2];
Imgproc.circle(input, center, 3, new Scalar(255, 255, 255), 5);
Imgproc.circle(input, center, radius, new Scalar(255, 255, 255), 2);
}
}
circles.release();
input.release();
return inputFrame.rgba();
}
示例9: drawPostProcessing
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
/**
* Draws an array of analysis objects unto a mat.
*
* @param feed mat to draw on
* @param color color to draw with
* @param an array of analysis to draw
* @see Imgproc#circle(Mat, Point, int, Scalar)
*/
public static void drawPostProcessing(Mat feed, Scalar color, Analysis... an){
for (int i = 0; i < an.length; i++) {
Analysis analysis = an[i];
Imgproc.circle(feed,
new Point(analysis.getDouble(Analysis.PROP_CENTER_X), analysis.getDouble(Analysis.PROP_CENTER_Y)),
3, color, 2);
}
Imgproc.line(feed, new Point(feed.width()/2, 0), new Point(feed.width()/2, feed.height()), new Scalar(0, 51, 255));
}
示例10: HoughCircles
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
void HoughCircles() {
Mat grayMat = new Mat();
Mat cannyEdges = new Mat();
Mat circles = new Mat();
//Converting the image to grayscale
Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);
Imgproc.Canny(grayMat, cannyEdges, 10, 100);
Imgproc.HoughCircles(cannyEdges, circles, Imgproc.CV_HOUGH_GRADIENT, 1, cannyEdges.rows() / 15);//, grayMat.rows() / 8);
Mat houghCircles = new Mat();
houghCircles.create(cannyEdges.rows(), cannyEdges.cols(), CvType.CV_8UC1);
//Drawing lines on the image
for (int i = 0; i < circles.cols(); i++) {
double[] parameters = circles.get(0, i);
double x, y;
int r;
x = parameters[0];
y = parameters[1];
r = (int) parameters[2];
Point center = new Point(x, y);
//Drawing circles on an image
Imgproc.circle(houghCircles, center, r, new Scalar(255, 0, 0), 1);
}
//Converting Mat back to Bitmap
Utils.matToBitmap(houghCircles, currentBitmap);
imageView.setImageBitmap(currentBitmap);
}
示例11: HarrisCorner
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
void HarrisCorner() {
Mat grayMat = new Mat();
Mat corners = new Mat();
//Converting the image to grayscale
Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);
Mat tempDst = new Mat();
//finding contours
Imgproc.cornerHarris(grayMat, tempDst, 2, 3, 0.04);
//Normalizing harris corner's output
Mat tempDstNorm = new Mat();
Core.normalize(tempDst, tempDstNorm, 0, 255, Core.NORM_MINMAX);
Core.convertScaleAbs(tempDstNorm, corners);
//Drawing corners on a new image
Random r = new Random();
for (int i = 0; i < tempDstNorm.cols(); i++) {
for (int j = 0; j < tempDstNorm.rows(); j++) {
double[] value = tempDstNorm.get(j, i);
if (value[0] > 150)
Imgproc.circle(corners, new Point(i, j), 5, new Scalar(r.nextInt(255)), 2);
}
}
//Converting Mat back to Bitmap
Utils.matToBitmap(corners, currentBitmap);
imageView.setImageBitmap(currentBitmap);
}
示例12: drawCircle
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
private static void drawCircle(Mat img, Point center, int diameter, Color color, int thickness) {
Imgproc.circle(img, center, diameter, color.getScalarRGBA(), thickness);
}
示例13: drawIrisCircle
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void drawIrisCircle(Mat matrixRgba, Core.MinMaxLocResult minMaxLocResult) {
Imgproc.circle(matrixRgba, minMaxLocResult.minLoc, 2, new Scalar(255, 255, 255, 255), 2);
}
示例14: point
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void point(Mat input, Point p, int radius, int size) {
Imgproc.circle(input, p, radius, new Scalar(255, 0, 255), size);
}
示例15: drawPoints
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void drawPoints(Mat im, List<Point> points, Scalar color) {
for (Point point : points) {
Imgproc.circle(im, point, 0, color, 3); // radius=0, thickness=3
}
}