本文整理匯總了Java中org.opencv.core.Mat.height方法的典型用法代碼示例。如果您正苦於以下問題:Java Mat.height方法的具體用法?Java Mat.height怎麽用?Java Mat.height使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.opencv.core.Mat
的用法示例。
在下文中一共展示了Mat.height方法的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());
}
示例2: mat2Bitmap
import org.opencv.core.Mat; //導入方法依賴的package包/類
private Bitmap mat2Bitmap(Mat src, int code) {
Mat rgbaMat = new Mat(src.width(), src.height(), CvType.CV_8UC4);
Imgproc.cvtColor(src, rgbaMat, code, 4);
Bitmap bmp = Bitmap.createBitmap(rgbaMat.cols(), rgbaMat.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(rgbaMat, bmp);
return bmp;
}
示例3: 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;
}
示例4: 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);
}
示例5: getInputDataLeNet
import org.opencv.core.Mat; //導入方法依賴的package包/類
private float[] getInputDataLeNet(Bitmap bitmap) {
final int INPUT_LENGTH = 28;
Mat imageMat = new Mat();
Mat inputMat = new Mat();
Utils.bitmapToMat(bitmap, imageMat);
// convert the image to 28 * 28, grayscale, 0~1, and smaller means whiter
Imgproc.cvtColor(imageMat, imageMat, Imgproc.COLOR_RGBA2GRAY);
imageMat = centerCropAndScale(imageMat, INPUT_LENGTH);
imageMat.convertTo(imageMat, CvType.CV_32F, 1. / 255);
Core.subtract(Mat.ones(imageMat.size(), CvType.CV_32F), imageMat, inputMat);
float[] inputData = new float[inputMat.width() * inputMat.height()];
inputMat.get(0, 0, inputData);
return inputData;
}
示例6: logicaOU
import org.opencv.core.Mat; //導入方法依賴的package包/類
public void logicaOU (String output){
manipulacao m = new manipulacao();
Mat ou = m.copiarImagem(imagem1);
int height = ou.height();
int width = ou.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};
ou.put(h, w, branco);
if(rgb1[0] == 0 || rgb2[0] == 0){
double[] preto = {0,0,0};
ou.put(h, w, preto);
}
}
}
m.salvarImagem(output, ou);
}
示例7: match
import org.opencv.core.Mat; //導入方法依賴的package包/類
public MatchResult match(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 = scene.clone(); img.width() > tw && img.height() > th;
CvProcessing.resize(img, scaleFactor)){
MatchResult currResult = match(img, templ, method, img);
if(bestScore == null || bestScore.maxVal < currResult.maxVal){
bestScore = currResult;
bestScore.scaleFactor = currScaleFactor;
}
currScaleFactor *= scaleFactor;
}
return bestScore;
}
示例8: drawNumbers
import org.opencv.core.Mat; //導入方法依賴的package包/類
public static void drawNumbers(Mat img, int[][] emptyGrid, int[][] filledGrid, Mat positions, Scalar color){
if(positions.height() == 81) {
double fontscale = positions.get(0, 3)[0] / 20;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (emptyGrid[i][j] == 0) {
//if the box is empty then ...
String k = "" + filledGrid[i][j]; //the value of this box in te filled grid
//the position of each box is localized on "positions" by i*9+j
double x = positions.get(i * 9 + j, 0)[0] + positions.get(i * 9 + j, 2)[0] / 3;
double y = positions.get(i * 9 + j, 1)[0] + 3 * positions.get(i * 9 + j, 3)[0] / 4;
Point pt = new Point(x, y);
Imgproc.putText(img, k, pt, Core.FONT_HERSHEY_PLAIN, fontscale, color, 2);
}
}
}
}
}
示例9: 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);
}
示例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]));
}
}
}
示例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);
}
}
示例12: bufferedImage
import org.opencv.core.Mat; //導入方法依賴的package包/類
public BufferedImage bufferedImage(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;
}
示例13: tillFit
import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat tillFit(Mat input, double targetX, double targetY) {
final Mat inputClone = input.clone();
double newWidth = input.width();
double newHeight = input.height();
while (newWidth > targetX || newHeight > targetY) {
Imgproc.resize(input, inputClone, new Size(newWidth * 0.9, newHeight * 0.9));
newWidth *= 0.9;
newHeight *= 0.9;
}
return inputClone;
}
示例14: SketchRecognition
import org.opencv.core.Mat; //導入方法依賴的package包/類
public SketchRecognition(Mat input) {
this.originalImage = input;
this.image = new Mat();
this.hierarchy = new Mat();
this.contours = new ArrayList<MatOfPoint>();
this.HEIGHT = input.height();
this.WIDTH = input.width();
}
示例15: ExtractBoxes
import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat ExtractBoxes(Mat im, int connectiviy){
try{
Mat stats = new Mat();
Mat imB = Processing.binarize(im,Imgproc.THRESH_OTSU);
Imgproc.connectedComponentsWithStats(imB,new Mat(),stats,new Mat(),connectiviy,CvType.CV_32S);
Mat stat = Mat.zeros(81,5,CvType.CV_32F);
double mcw = stats.get(0,2)[0]; //max contour width
double mch = stats.get(0,3)[0]; // max contour height
int j=0;
for(int i = 1; i < stats.height(); i++){
double area = stats.get(i,2)[0] * stats.get(i,3)[0];
if(area < (mcw/8)*(mch/8) && area > (mcw/25)*(mch/25)){
stat.put(j,0,stats.get(i,0)[0]);
stat.put(j,1,stats.get(i,1)[0]);
stat.put(j,2,stats.get(i,2)[0]);
stat.put(j,3,stats.get(i,3)[0]);
stat.put(j,4,stats.get(i,4)[0]);
j +=1;
}
}
stat = Processing.statSorted(stat,0);
/*if(stat.get(0,0)[0] == 0 && stat.get(0,1)[0] ==0 && (stat.get(0,2)[0] ==0 || stat.get(0,3)[0] ==0))
return null;*/
return stat;
}
catch(Exception e){
return null;
}
}