當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。