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


Java Size.equals方法代码示例

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


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

示例1: chooseOptimalSize

import android.util.Size; //导入方法依赖的package包/类
/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the minimum of both, or an exact match if possible.
 *
 * @param choices The list of sizes that the camera supports for the intended output class
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
private static Size chooseOptimalSize(final Size[] choices, int minWidth, int minHeight) {
    final int minSize = Math.max(Math.min(minWidth, minHeight), MINIMUM_PREVIEW_SIZE);
    final Size desiredSize = new Size(minWidth, minHeight);

    // Collect the supported resolutions that are at least as big as the preview Surface
    boolean exactSizeFound = false;
    final List<Size> bigEnough = new ArrayList<>();
    //noinspection MismatchedQueryAndUpdateOfCollection
    final List<Size> tooSmall = new ArrayList<>();
    for (final Size option : choices) {
        if (option.equals(desiredSize)) {
            // Set the size but don't return yet so that remaining sizes will still be logged.
            exactSizeFound = true;
        }

        if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
            bigEnough.add(option);
        } else {
            tooSmall.add(option);
        }
    }

    if (exactSizeFound) return desiredSize;

    // Pick the smallest of those, assuming we found any
    if (bigEnough.size() > 0) {
        return Collections.min(bigEnough, new CompareSizesByArea());
    } else {
        return choices[0];
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:39,代码来源:Camera2Api.java

示例2: chooseOptimalSize

import android.util.Size; //导入方法依赖的package包/类
/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the minimum of both, or an exact match if possible.
 *
 * @param choices The list of sizes that the camera supports for the intended output class
 * @param width The minimum desired width
 * @param height The minimum desired height
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
private static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
  final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
  final Size desiredSize = new Size(width, height);

  // Collect the supported resolutions that are at least as big as the preview Surface
  boolean exactSizeFound = false;
  final List<Size> bigEnough = new ArrayList<Size>();
  final List<Size> tooSmall = new ArrayList<Size>();
  for (final Size option : choices) {
    if (option.equals(desiredSize)) {
      // Set the size but don't return yet so that remaining sizes will still be logged.
      exactSizeFound = true;
    }

    if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
      bigEnough.add(option);
    } else {
      tooSmall.add(option);
    }
  }

  if (exactSizeFound) {
    return desiredSize;
  }

  // Pick the smallest of those, assuming we found any
  if (bigEnough.size() > 0) {
    final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
    return chosenSize;
  } else {
    return choices[0];
  }
}
 
开发者ID:hpi-xnor,项目名称:android-image-classification,代码行数:43,代码来源:CameraConnectionFragment.java

示例3: chooseOptimalSize

import android.util.Size; //导入方法依赖的package包/类
/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the minimum of both, or an exact match if possible.
 *
 * @param choices The list of sizes that the camera supports for the intended output class
 * @param width The minimum desired width
 * @param height The minimum desired height
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
private static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
    final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
    final Size desiredSize = new Size(width, height);

    // Collect the supported resolutions that are at least as big as the preview Surface
    boolean exactSizeFound = false;
    final List<Size> bigEnough = new ArrayList<Size>();
    final List<Size> tooSmall = new ArrayList<Size>();
    for (final Size option : choices) {
        if (option.equals(desiredSize)) {
            // Set the size but don't return yet so that remaining sizes will still be logged.
            exactSizeFound = true;
        }

        if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
            bigEnough.add(option);
        } else {
            tooSmall.add(option);
        }
    }

    LOGGER.i("Desired size: " + desiredSize + ", min size: " + minSize + "x" + minSize);
    LOGGER.i("Valid preview sizes: [" + TextUtils.join(", ", bigEnough) + "]");
    LOGGER.i("Rejected preview sizes: [" + TextUtils.join(", ", tooSmall) + "]");

    if (exactSizeFound) {
        LOGGER.i("Exact size match found.");
        return desiredSize;
    }

    // Pick the smallest of those, assuming we found any
    if (bigEnough.size() > 0) {
        final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
        LOGGER.i("Chosen size: " + chosenSize.getWidth() + "x" + chosenSize.getHeight());
        return chosenSize;
    } else {
        LOGGER.e("Couldn't find any suitable preview size");
        return choices[0];
    }
}
 
开发者ID:Jamjomjara,项目名称:snu-artoon,代码行数:50,代码来源:CameraConnectionFragment.java

示例4: chooseOptimalSize

import android.util.Size; //导入方法依赖的package包/类
/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the minimum of both, or an exact match if possible.
 *
 * @param choices The list of sizes that the camera supports for the intended output class
 * @param width The minimum desired width
 * @param height The minimum desired height
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
private static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
  final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
  final Size desiredSize = new Size(width, height);

  // Collect the supported resolutions that are at least as big as the preview Surface
  boolean exactSizeFound = false;
  final List<Size> bigEnough = new ArrayList<Size>();
  final List<Size> tooSmall = new ArrayList<Size>();
  for (final Size option : choices) {
    if (option.equals(desiredSize)) {
      // Set the size but don't return yet so that remaining sizes will still be logged.
      exactSizeFound = true;
    }

    if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
      bigEnough.add(option);
    } else {
      tooSmall.add(option);
    }
  }

  LOGGER.i("Desired size: " + desiredSize + ", min size: " + minSize + "x" + minSize);
  LOGGER.i("Valid preview sizes: [" + TextUtils.join(", ", bigEnough) + "]");
  LOGGER.i("Rejected preview sizes: [" + TextUtils.join(", ", tooSmall) + "]");

  if (exactSizeFound) {
    LOGGER.i("Exact size match found.");
    return desiredSize;
  }

  // Pick the smallest of those, assuming we found any
  if (bigEnough.size() > 0) {
    final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
    LOGGER.i("Chosen size: " + chosenSize.getWidth() + "x" + chosenSize.getHeight());
    return chosenSize;
  } else {
    LOGGER.e("Couldn't find any suitable preview size");
    return choices[0];
  }
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:50,代码来源:CameraConnectionFragment.java

示例5: chooseOptimalSize

import android.util.Size; //导入方法依赖的package包/类
/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the minimum of both, or an exact match if possible.
 *
 * @param choices The list of sizes that the camera supports for the intended output class
 * @param width The minimum desired width
 * @param height The minimum desired height
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
protected static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
  final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
  final Size desiredSize = new Size(width, height);

  // Collect the supported resolutions that are at least as big as the preview Surface
  boolean exactSizeFound = false;
  final List<Size> bigEnough = new ArrayList<Size>();
  final List<Size> tooSmall = new ArrayList<Size>();
  for (final Size option : choices) {
    if (option.equals(desiredSize)) {
      // Set the size but don't return yet so that remaining sizes will still be logged.
      exactSizeFound = true;
    }

    if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
      bigEnough.add(option);
    } else {
      tooSmall.add(option);
    }
  }

  LOGGER.i("Desired size: " + desiredSize + ", min size: " + minSize + "x" + minSize);
  LOGGER.i("Valid preview sizes: [" + TextUtils.join(", ", bigEnough) + "]");
  LOGGER.i("Rejected preview sizes: [" + TextUtils.join(", ", tooSmall) + "]");

  if (exactSizeFound) {
    LOGGER.i("Exact size match found.");
    return desiredSize;
  }

  // Pick the smallest of those, assuming we found any
  if (bigEnough.size() > 0) {
    final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
    LOGGER.i("Chosen size: " + chosenSize.getWidth() + "x" + chosenSize.getHeight());
    return chosenSize;
  } else {
    LOGGER.e("Couldn't find any suitable preview size");
    return choices[0];
  }
}
 
开发者ID:Nilhcem,项目名称:tensorflow-classifier-android,代码行数:50,代码来源:CameraConnectionFragment.java


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