当前位置: 首页>>代码示例>>Java>>正文


Java Mat.width方法代码示例

本文整理汇总了Java中org.opencv.core.Mat.width方法的典型用法代码示例。如果您正苦于以下问题:Java Mat.width方法的具体用法?Java Mat.width怎么用?Java Mat.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opencv.core.Mat的用法示例。


在下文中一共展示了Mat.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rotate

import org.opencv.core.Mat; //导入方法依赖的package包/类
/**
 * Rotate an image by an angle (counterclockwise)
 *
 * @param image Transform matrix
 * @param angle Angle to rotate by (counterclockwise) from -360 to 360
 */
public static void rotate(Mat image, double angle) {
    //Calculate size of new matrix
    double radians = Math.toRadians(angle);
    double sin = Math.abs(Math.sin(radians));
    double cos = Math.abs(Math.cos(radians));

    int newWidth = (int) (image.width() * cos + image.height() * sin);
    int newHeight = (int) (image.width() * sin + image.height() * cos);

    // rotating image
    Point center = new Point(newWidth / 2, newHeight / 2);
    Mat rotMatrix = Imgproc.getRotationMatrix2D(center, angle, 1.0); //1.0 means 100 % scale

    Size size = new Size(newWidth, newHeight);
    Imgproc.warpAffine(image, image, rotMatrix, image.size());
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:23,代码来源:Transform.java

示例2: imagePadding

import org.opencv.core.Mat; //导入方法依赖的package包/类
/**
 * Apply padding to the image.
 */
private Mat imagePadding(Mat source, int blockSize) {

    int width = source.width();
    int height = source.height();

    int bottomPadding = 0;
    int rightPadding = 0;

    if (width % blockSize != 0) {
        bottomPadding = blockSize - (width % blockSize);
    }
    if (height % blockSize != 0) {
        rightPadding = blockSize - (height % blockSize);
    }
    Core.copyMakeBorder(source, source, 0, bottomPadding, 0, rightPadding, Core.BORDER_CONSTANT, Scalar.all(0));
    return source;
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:21,代码来源:ImageProcessing.java

示例3: gerarCinza

import org.opencv.core.Mat; //导入方法依赖的package包/类
public void gerarCinza(Mat original, Mat cinza) {

		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
		
		int width = original.width(); //largura
		int height = original.height(); //altura
//		System.out.println(width+"/"+height);

		for (int w = 0; w < width; w++) {
			for (int h = 0; h < height; h++) {
//				System.out.println(w+"/"+h);
				double[] rgb = cinza.get(h, w);
				double cor = ((rgb[0] + rgb[1] + rgb[2]) / 3);
				double[] tom = { cor, cor, cor };
				cinza.put(h, w, tom);
			}
		}
		
		salvarImagem("paisagemcinza.png", cinza);

	}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:22,代码来源:Manipulacao.java

示例4: gerarBinarizacao

import org.opencv.core.Mat; //导入方法依赖的package包/类
public void gerarBinarizacao(Mat cinza, Mat binaria) {

		int width = cinza.width();
		int height = cinza.height();

		for (int w = 0; w < width; w++) {
			for (int h = 0; h < height; h++) {
				double cor = 0;
				double[] pixel = cinza.get(h, w);
				if (pixel[0] > 100)
					cor = 255;
				double[] tom = { cor, cor, cor };
				binaria.put(h, w, tom);

			}
		}
		
		salvarImagem("paisagembinaria.png", binaria);

	}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:21,代码来源:Manipulacao.java

示例5: logicaE

import org.opencv.core.Mat; //导入方法依赖的package包/类
public void logicaE (String output){
	
	manipulacao m = new manipulacao();
	Mat e = m.copiarImagem(imagem1);
	
	int height = e.height();
	int width = e.width();

	for (int h = 0; h < height; h++) {
		for (int w = 0; w < width; w++) {
			double[] rgb1 = imagem1.get(h, w);
			double[] rgb2 = imagem2.get(h, w);
			double[] branco = {255,255,255};
			e.put(h, w, branco);
			if(rgb1[0] == 0 && rgb2[0] == 0){
				double[] preto = {0,0,0};
				e.put(h, w, preto);
			}
		}
	}
	
	m.salvarImagem(output, e);
	
}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:25,代码来源:Operacoes.java

示例6: complemento

import org.opencv.core.Mat; //导入方法依赖的package包/类
public void complemento (String output){
	
	manipulacao m = new manipulacao();
	Mat com = m.copiarImagem(imagem2);
	
	int height = com.height();
	int width = com.width();

	for (int h = 0; h < height; h++) {
		for (int w = 0; w < width; w++) {
			double[] rgb = imagem2.get(h, w);
			double[] branco = {255,255,255};
			double[] preto = {0,0,0};
			if(rgb[0] == 0){
				com.put(h, w, branco);
			}else {
				com.put(h, w, preto);
			}
		}
	}
	
	m.salvarImagem(output, com);
	
}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:25,代码来源:Operacoes.java

示例7: processStillImage

import org.opencv.core.Mat; //导入方法依赖的package包/类
private void processStillImage() {
    Mat mat = Imgcodecs.imread("fly.bmp");
    for (int c = 0; c < mat.width() / 2; c++) {
        for (int r = 0; r < mat.height() / 2; r++) {
            double color[] = mat.get(r, c);
            color[0] = 255;
            mat.put(r, c, color);
            //System.out.printf("(%d, %d) = %s\n", r, c, Arrays.toString(color));
        }
    }
    Imgcodecs.imwrite("fly_new.bmp", mat);

    Mat gray = new Mat();
    Imgproc.cvtColor(mat, gray, Imgproc.COLOR_RGB2GRAY);
    Imgcodecs.imwrite("fly_gray.bmp", gray);
}
 
开发者ID:kmhasan-class,项目名称:fall2017ip,代码行数:17,代码来源:OpenCVTest.java

示例8: detectMany

import org.opencv.core.Mat; //导入方法依赖的package包/类
/**
 * 
* @Title: detectMany 
* @Description: 检测多人图片,返回检测的人脸区域对象
* @param mImgSRC
* @return
* MatOfRect
 */
public static MatOfRect detectMany(Mat mImgSRC) {
	
	if(mImgSRC.empty()) {
		LOG.info("检测多人图片检测时没有找到图片");
		return null;
	}
	// 人脸检测器文件的所在路径的文件夹名称数组
	String [] pathKey = {ServletContextHolder.getOpenCVHaarcascades(), "haarcascade_frontalface_alt.xml"};
	CascadeClassifier cascade = new CascadeClassifier(FileUtils.buildFilePath(pathKey));
	if(cascade.empty()) {
		LOG.info("人脸检测级联加载器为null");
		return null;
	}
	// 记录搜索到的人脸区域
	MatOfRect mOfRect = new MatOfRect();
	// 用于计算缩放比例
	int scaledWidth = mImgSRC.width();
	detectManyObject(mImgSRC, cascade, mOfRect, scaledWidth);
	if(mOfRect.toArray().length <= 0) {
		LOG.info("没有检测到人脸...");
		return null;
	}
	return mOfRect;
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:33,代码来源:DetectObject.java

示例9: scaleTemplateMatch

import org.opencv.core.Mat; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public MatchResult scaleTemplateMatch(Mat scene, Mat templ, Method method, double scaleFactor){
	int tw = templ.width();
	int th = templ.height();
	double currScaleFactor = scaleFactor;
	MatchResult bestScore = null;
	
	for(Mat img = templ.clone(); img.width() > tw*0.25;
			CvProcessing.resize(img, scaleFactor)){
		
		MatchResult currResult = match(scene, img, method, img);
        
        if(bestScore == null || bestScore.maxVal < currResult.maxVal){
        	bestScore = currResult;
        	bestScore.scaleFactor = currScaleFactor;
        }
        currScaleFactor  *= scaleFactor;
     }
	
	
      	return bestScore;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:23,代码来源:CvTemplateMatcher.java

示例10: atan2

import org.opencv.core.Mat; //导入方法依赖的package包/类
/**
 * Calculate bitwise atan2 for the given 2 images.
 */
private void atan2(Mat src1, Mat src2, Mat dst) {

    int height = src1.height();
    int width = src2.width();

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            dst.put(y, x, Core.fastAtan2((float) src1.get(y, x)[0], (float) src2.get(y, x)[0]));
        }
    }
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:15,代码来源:ImageProcessing.java

示例11: onFinish

import org.opencv.core.Mat; //导入方法依赖的package包/类
/**
 * detect the coordinates of the first frame then remove the listener as it will not be needed any more
 * @param frame
 */
@Override
public void onFinish(Mat frame) {
    if (frame.height() != 0)
    {
        screenCameraRatio.x = screenCoordinates.x / frame.width();
        screenCameraRatio.y = screenCoordinates.y / frame.height();
        laserDetector.removeOnFrameProcessedListeners(this);
    }
}
 
开发者ID:kareem2048,项目名称:Asteroids-Laser-Controller,代码行数:14,代码来源:AsteroidsController.java

示例12: Picture

import org.opencv.core.Mat; //导入方法依赖的package包/类
public Picture(Mat matInput) {
	this.bimg = Mat2BufferedImage.mat2BI(matInput);
	this.data = GetPixelArray.pixelArray(bimg, false);
	this.dataSingleChannel = GetPixelArray.pixelArray(bimg, true);
	this.width = matInput.width();
	this.height = matInput.height();
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:8,代码来源:Picture.java

示例13: testDetectManyObject

import org.opencv.core.Mat; //导入方法依赖的package包/类
@Test
public void testDetectManyObject() {
	String opencvDLL = "G:/java/JavaProjectRelease/classchecks/src/main/webapp/WEB-INF/dll/x64/opencv_java320.dll";
	System.load(opencvDLL);
	
	String haarcascade = "haarcascade_frontalface_alt.xml";
	
	
	CascadeClassifier cascade = new CascadeClassifier(XMLFilePath + haarcascade);
	
	Mat src = Imgcodecs.imread(imageDir + "/split/14.jpg");
	
	MatOfRect objects = new MatOfRect();
	int scaledWidth = src.width();
	
	DetectObject.detectManyObject(src, cascade, objects, scaledWidth);
	
	Rect [] rects = objects.toArray();
	int i = 0;
	for(Rect r : rects) {
		/*Imgproc.rectangle(src, new Point(r.x-100 , r.y-100 ), 
				new Point(r.x + r.width + 80, 
						r.y + r.height + 80), new Scalar(0, 0, 255), 3);*/
		Imgproc.rectangle(src, r.tl(), 
				r.br(), new Scalar(0, 0, 255), 3);
		/*r.width += 120;
		r.height += 120;
		r.x -= 100;
		r.y -= 100;
		System.out.println(r);
		Mat roi = new Mat(src, r);
		Imgcodecs.imwrite("e:/classchecks/2017417/split/"+i+".jpg", roi);
		i ++;*/
	}
	Imgcodecs.imwrite("e:/classchecks/2017417/dectctManyObject.jpg", src);
	//Imgcodecs.imwrite("e:/classchecks/dectctManyObject.jpg", src);
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:38,代码来源:DetectObjectTest.java

示例14: matToBufferedImage

import org.opencv.core.Mat; //导入方法依赖的package包/类
public BufferedImage matToBufferedImage(Mat mat) {

        if (mat.height() > 0 && mat.width() > 0) {
            BufferedImage image = new BufferedImage(mat.width(), mat.height(), BufferedImage.TYPE_3BYTE_BGR);
            WritableRaster raster = image.getRaster();
            DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
            byte[] data = dataBuffer.getData();
            mat.get(0, 0, data);
            return image;
        }
        return null;
    }
 
开发者ID:Plasmoxy,项目名称:AquamarineLake,代码行数:13,代码来源:DrawPanel.java

示例15: getInputDataResNet18

import org.opencv.core.Mat; //导入方法依赖的package包/类
private float[] getInputDataResNet18(Bitmap bitmap) {
    final int INPUT_SIDE_LENGTH = 224;

    Mat imageMat = new Mat();

    Utils.bitmapToMat(bitmap, imageMat);

    Imgproc.cvtColor(imageMat, imageMat, Imgproc.COLOR_RGBA2BGR);
    imageMat = centerCropAndScale(imageMat, INPUT_SIDE_LENGTH);
    Core.subtract(imageMat, new Scalar(104, 117, 123), imageMat);
    imageMat.convertTo(imageMat, CvType.CV_32FC3);

    float[] inputData = new float[imageMat.width() * imageMat.height() * imageMat.channels()];

    imageMat.get(0, 0, inputData);

    return inputData;
}
 
开发者ID:daquexian,项目名称:DNNLibrary,代码行数:19,代码来源:MainActivity.java


注:本文中的org.opencv.core.Mat.width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。