Giter VIP home page Giter VIP logo

nv21cropdemo's Introduction

NV21cropDemo

NV21图像裁剪

在相机预览数据回调方法中调用 例如将1920x1080 的nv21数据 上下左右裁剪掉一半

@Override
public void onPreview(byte[] nv21, Camera camera) {
  if (nv21 != null && nv21.length == 1920 * 1080 * 3 / 2) {
    int offsetW = 1920 / 4;
    int offsetH = 1080 / 4;
    byte[] data = NV21Utils.clipNV21(nv21, 1920, 1080, offsetW, offsetH, offsetW * 2, offsetH * 2);
    Log.e(TAG, "onPreviewFrame: " + data.length);
   }
}

工具所带的裁剪方法目前有两种,一种只裁剪,一种再裁剪的同时进行镜像操作

/**
 * NV21裁剪  算法效率 友善rk3399开发板测试 3ms
 *
 * @param src    源数据
 * @param width  源宽
 * @param height 源高
 * @param left   顶点坐标
 * @param top    顶点坐标
 * @param clip_w 裁剪后的宽
 * @param clip_h 裁剪后的高
 * @return 裁剪后的数据
 */
byte[] clipNV21(byte[] src, int width, int height, int left, int top, int clip_w, int clip_h);

/**
 * 剪切数据并且镜像 算法效率 友善rk3399开发板测试 14ms
 *
 * @param src
 * @param width
 * @param height
 * @param left
 * @param top
 * @param clip_w
 * @param clip_h
 * @return
 */
byte[] clipMirrorNV21(byte[] src, int width, int height, int left, int top, int clip_w, int clip_h)

nv21cropdemo's People

Contributors

hbottle avatar lakehubo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.