本文整理匯總了Java中org.opencv.core.Size類的典型用法代碼示例。如果您正苦於以下問題:Java Size類的具體用法?Java Size怎麽用?Java Size使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Size類屬於org.opencv.core包,在下文中一共展示了Size類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateCameraFrameSize
import org.opencv.core.Size; //導入依賴的package包/類
/**
* This helper method can be called by subclasses to select camera preview size.
* It goes over the list of the supported preview sizes and selects the maximum one which
* fits both values set via setMaxFrameSize() and surface frame allocated for this view
* @param supportedSizes
* @param surfaceWidth
* @param surfaceHeight
* @return optimal frame size
*/
protected Size calculateCameraFrameSize(List<?> supportedSizes, ListItemAccessor accessor, int surfaceWidth, int surfaceHeight) {
int calcWidth = 0;
int calcHeight = 0;
int maxAllowedWidth = (mMaxWidth != MAX_UNSPECIFIED && mMaxWidth < surfaceWidth)? mMaxWidth : surfaceWidth;
int maxAllowedHeight = (mMaxHeight != MAX_UNSPECIFIED && mMaxHeight < surfaceHeight)? mMaxHeight : surfaceHeight;
for (Object size : supportedSizes) {
int width = accessor.getWidth(size);
int height = accessor.getHeight(size);
if (width <= maxAllowedWidth && height <= maxAllowedHeight) {
if (width >= calcWidth && height >= calcHeight) {
calcWidth = (int) width;
calcHeight = (int) height;
}
}
}
return new Size(calcWidth, calcHeight);
}
示例2: makeScale
import org.opencv.core.Size; //導入依賴的package包/類
/**
* Scales an image to an approximate size. The scale will always be equal
* on the x and y axis, regardless of the approxSize.
*
* @param img The image
* @param approxSize The target size
* @param maximize If maximize is true, then if the approxSize aspect ratio
* does not match the target, then the largest possible image
* would be used. If false (default), the the smallest image
* would be used.
* @param integerScale If true (default), then only integer scale factors would be used.
* Otherwise, any scale factor can be used.
*/
private static double makeScale(Mat img, Size approxSize, boolean maximize, boolean integerScale) {
Size imageSize = img.size();
double ratioWidth = approxSize.width / imageSize.width;
double ratioHeight = approxSize.height / imageSize.height;
double ratio = maximize ? Math.max(ratioWidth, ratioHeight) : Math.min(ratioWidth, ratioHeight);
if (MathUtil.equal(ratio, 1))
return 1;
if (integerScale) {
//The scale factor is always greater than 1
double scale = (ratio < 1) ? 1 / ratio : ratio;
//If you are actually increasing the size of the object, use ceiling()
//Otherwise, use floor()
scale = maximize ^ (ratio < 1) ? Math.ceil(scale) : Math.floor(scale);
//Get the actual ratio again
return (ratio < 1) ? 1 / scale : scale;
} else {
return ratio;
}
}
示例3: stereoCalibrate
import org.opencv.core.Size; //導入依賴的package包/類
public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, int flags, TermCriteria criteria)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
double retVal = stereoCalibrate_3(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
return retVal;
}
示例4: buildOpticalFlowPyramid
import org.opencv.core.Size; //導入依賴的package包/類
public static int buildOpticalFlowPyramid(Mat img, List<Mat> pyramid, Size winSize, int maxLevel)
{
Mat pyramid_mat = new Mat();
int retVal = buildOpticalFlowPyramid_1(img.nativeObj, pyramid_mat.nativeObj, winSize.width, winSize.height, maxLevel);
Converters.Mat_to_vector_Mat(pyramid_mat, pyramid);
pyramid_mat.release();
return retVal;
}
示例5: cornerSubPix
import org.opencv.core.Size; //導入依賴的package包/類
public static void cornerSubPix(Mat image, MatOfPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria)
{
Mat corners_mat = corners;
cornerSubPix_0(image.nativeObj, corners_mat.nativeObj, winSize.width, winSize.height, zeroZone.width, zeroZone.height, criteria.type, criteria.maxCount, criteria.epsilon);
return;
}
示例6: calibrate
import org.opencv.core.Size; //導入依賴的package包/類
public static double calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
Mat rvecs_mat = new Mat();
Mat tvecs_mat = new Mat();
double retVal = calibrate_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
rvecs_mat.release();
Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
tvecs_mat.release();
return retVal;
}
示例7: stereoCalibrate
import org.opencv.core.Size; //導入依賴的package包/類
public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags, TermCriteria criteria)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
double retVal = stereoCalibrate_0(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
return retVal;
}
示例8: ellipse2Poly
import org.opencv.core.Size; //導入依賴的package包/類
public static void ellipse2Poly(Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, MatOfPoint pts)
{
Mat pts_mat = pts;
ellipse2Poly_0(center.x, center.y, axes.width, axes.height, angle, arcStart, arcEnd, delta, pts_mat.nativeObj);
return;
}
示例9: detectMultiScale2
import org.opencv.core.Size; //導入依賴的package包/類
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
{
Mat objects_mat = objects;
Mat numDetections_mat = numDetections;
detectMultiScale2_0(nativeObj, image.nativeObj, objects_mat.nativeObj, numDetections_mat.nativeObj, scaleFactor, minNeighbors, flags, minSize.width, minSize.height, maxSize.width, maxSize.height);
return;
}
示例10: getOptimalNewCameraMatrix
import org.opencv.core.Size; //導入依賴的package包/類
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint)
{
double[] validPixROI_out = new double[4];
Mat retVal = new Mat(getOptimalNewCameraMatrix_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out, centerPrincipalPoint));
if(validPixROI!=null){ validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; }
return retVal;
}
示例11: calibrate
import org.opencv.core.Size; //導入依賴的package包/類
public static double calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
Mat rvecs_mat = new Mat();
Mat tvecs_mat = new Mat();
double retVal = calibrate_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
rvecs_mat.release();
Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
tvecs_mat.release();
return retVal;
}
示例12: drawChessboardCorners
import org.opencv.core.Size; //導入依賴的package包/類
public static void drawChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, boolean patternWasFound)
{
Mat corners_mat = corners;
drawChessboardCorners_0(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj, patternWasFound);
return;
}
示例13: calibrateCameraExtended
import org.opencv.core.Size; //導入依賴的package包/類
public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
Mat rvecs_mat = new Mat();
Mat tvecs_mat = new Mat();
double retVal = calibrateCameraExtended_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj);
Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
rvecs_mat.release();
Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
tvecs_mat.release();
return retVal;
}
示例14: stereoRectify
import org.opencv.core.Size; //導入依賴的package包/類
public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
{
double[] validPixROI1_out = new double[4];
double[] validPixROI2_out = new double[4];
stereoRectify_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; }
if(validPixROI2!=null){ validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; }
return;
}
示例15: stereoCalibrate
import org.opencv.core.Size; //導入依賴的package包/類
public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags)
{
Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
double retVal = stereoCalibrate_1(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags);
return retVal;
}