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


Java ImageUtils.saveBitmap方法代码示例

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


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

示例1: onClick

import org.tensorflow.demo.env.ImageUtils; //导入方法依赖的package包/类
@Override
public void onClick(final View v) {
  if (textureCopyBitmap != null) {
    // TODO(andrewharp): Save as jpeg with guaranteed unique filename.
    ImageUtils.saveBitmap(textureCopyBitmap, "stylized" + frameNum + ".png");
    Toast.makeText(
            StylizeActivity.this,
            "Saved image to: /sdcard/tensorflow/" + "stylized" + frameNum + ".png",
            Toast.LENGTH_LONG)
        .show();
  }
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:13,代码来源:StylizeActivity.java

示例2: processImage

import org.tensorflow.demo.env.ImageUtils; //导入方法依赖的package包/类
@Override
protected void processImage() {
  rgbFrameBitmap.setPixels(getRgbBytes(), 0, previewWidth, 0, 0, previewWidth, previewHeight);
  final Canvas canvas = new Canvas(croppedBitmap);
  canvas.drawBitmap(rgbFrameBitmap, frameToCropTransform, null);

  // For examining the actual TF input.
  if (SAVE_PREVIEW_BITMAP) {
    ImageUtils.saveBitmap(croppedBitmap);
  }
  runInBackground(
      new Runnable() {
        @Override
        public void run() {
          final long startTime = SystemClock.uptimeMillis();
          final List<Classifier.Recognition> results = classifier.recognizeImage(croppedBitmap);
          lastProcessingTimeMs = SystemClock.uptimeMillis() - startTime;
          LOGGER.i("Detect: %s", results);
          cropCopyBitmap = Bitmap.createBitmap(croppedBitmap);
          if (resultsView == null) {
            resultsView = (ResultsView) findViewById(R.id.results);
          }
          resultsView.setResults(results);
          requestRender();
          readyForNextImage();
        }
      });
}
 
开发者ID:Nilhcem,项目名称:tensorflow-classifier-android,代码行数:29,代码来源:ClassifierActivity.java

示例3: onImageAvailable

import org.tensorflow.demo.env.ImageUtils; //导入方法依赖的package包/类
@Override
public void onImageAvailable(final ImageReader reader) {
  Image image = null;

  try {
    image = reader.acquireLatestImage();

    if (image == null) {
      return;
    }

    if (computing) {
      image.close();
      return;
    }
    computing = true;

    Trace.beginSection("imageAvailable");

    final Plane[] planes = image.getPlanes();
    fillBytes(planes, yuvBytes);

    final int yRowStride = planes[0].getRowStride();
    final int uvRowStride = planes[1].getRowStride();
    final int uvPixelStride = planes[1].getPixelStride();
    ImageUtils.convertYUV420ToARGB8888(
        yuvBytes[0],
        yuvBytes[1],
        yuvBytes[2],
        rgbBytes,
        previewWidth,
        previewHeight,
        yRowStride,
        uvRowStride,
        uvPixelStride,
        false);

    image.close();
  } catch (final Exception e) {
    if (image != null) {
      image.close();
    }
    LOGGER.e(e, "Exception!");
    Trace.endSection();
    return;
  }

  rgbFrameBitmap.setPixels(rgbBytes, 0, previewWidth, 0, 0, previewWidth, previewHeight);
  final Canvas canvas = new Canvas(croppedBitmap);
  canvas.drawBitmap(rgbFrameBitmap, frameToCropTransform, null);

  // For examining the actual TF input.
  if (SAVE_PREVIEW_BITMAP) {
    ImageUtils.saveBitmap(croppedBitmap);
  }

  runInBackground(
      new Runnable() {
        @Override
        public void run() {
          final long startTime = SystemClock.uptimeMillis();
          final List<Classifier.Recognition> results = classifier.recognizeImage(croppedBitmap);
          lastProcessingTimeMs = SystemClock.uptimeMillis() - startTime;

          cropCopyBitmap = Bitmap.createBitmap(croppedBitmap);
          resultsView.setResults(results);
          requestRender();
          computing = false;
        }
      });

  Trace.endSection();
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:74,代码来源:ClassifierActivity.java

示例4: onImageAvailable

import org.tensorflow.demo.env.ImageUtils; //导入方法依赖的package包/类
@Override public void onImageAvailable(final ImageReader reader) {
  imageReader = reader;

  Image image = null;

  try {
    image = reader.acquireLatestImage();

    if (image == null) {
      return;
    }

    if (savingImage || computing) {
      image.close();
      return;
    }
    savingImage = true;

    Trace.beginSection("imageAvailable");

    final Plane[] planes = image.getPlanes();
    fillBytes(planes, yuvBytes);

    final int yRowStride = planes[0].getRowStride();
    final int uvRowStride = planes[1].getRowStride();
    final int uvPixelStride = planes[1].getPixelStride();
    ImageUtils.convertYUV420ToARGB8888(yuvBytes[0], yuvBytes[1], yuvBytes[2], rgbBytes,
        previewWidth, previewHeight, yRowStride, uvRowStride, uvPixelStride, false);

    image.close();
  } catch (final Exception e) {
    if (image != null) {
      image.close();
    }
    LOGGER.e(e, "Exception!");
    Trace.endSection();
    return;
  }

  rgbFrameBitmap.setPixels(rgbBytes, 0, previewWidth, 0, 0, previewWidth, previewHeight);
  final Canvas canvas = new Canvas(croppedBitmap);
  canvas.drawBitmap(rgbFrameBitmap, frameToCropTransform, null);

  // For examining the actual TF input.
  if (SAVE_PREVIEW_BITMAP) {
    ImageUtils.saveBitmap(croppedBitmap);
  }

  savingImage = false;
  Trace.endSection();
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:52,代码来源:CameraActivity.java


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