[Change]
加入usb-camera Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package org.easydarwin.sw;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class JNIUtil {
|
||||
|
||||
static {
|
||||
System.loadLibrary("Utils");
|
||||
}
|
||||
|
||||
/**
|
||||
* 都是Y:U:V = 4:1:1但 U与 V顺序相反。变换可逆
|
||||
*
|
||||
* @param buffer
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
public static void yV12ToYUV420P(byte[] buffer, int width, int height) {
|
||||
callMethod("YV12ToYUV420P", null, buffer, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* 都是Y:U+V = 4:2,但是这两者U、V方向相反。变换可逆
|
||||
*
|
||||
* @param buffer
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
public static void nV21To420SP(byte[] buffer, int width, int height) {
|
||||
callMethod("NV21To420SP", null, buffer, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* 旋转1个字节为单位的矩阵
|
||||
*
|
||||
* @param data 要旋转的矩阵
|
||||
* @param offset 偏移量
|
||||
* @param width 宽度
|
||||
* @param height 高度
|
||||
* @param degree 旋转度数
|
||||
*/
|
||||
public static void rotateMatrix(byte[] data, int offset, int width, int height, int degree) {
|
||||
callMethod("RotateByteMatrix", null, data, offset, width, height, degree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 旋转2个字节为单位的矩阵
|
||||
*
|
||||
* @param data 要旋转的矩阵
|
||||
* @param offset 偏移量
|
||||
* @param width 宽度
|
||||
* @param height 高度
|
||||
* @param degree 旋转度数
|
||||
*/
|
||||
public static void rotateShortMatrix(byte[] data, int offset, int width, int height, int degree) {
|
||||
callMethod("RotateShortMatrix", null, data, offset, width, height, degree);
|
||||
}
|
||||
|
||||
private static native void callMethod(String methodName, Object[] returnValue, Object... params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.easydarwin.sw;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Created by jiangdg on 2020/1/11.
|
||||
*/
|
||||
|
||||
public class TxtOverlay {
|
||||
|
||||
static {
|
||||
System.loadLibrary("TxtOverlay");
|
||||
}
|
||||
|
||||
private static TxtOverlay instance;
|
||||
private final Context context;
|
||||
private long ctx;
|
||||
|
||||
private TxtOverlay(Context context){
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public static TxtOverlay getInstance() {
|
||||
if(instance == null) {
|
||||
throw new IllegalArgumentException("please call install in your application!");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void install(Context context) {
|
||||
if(instance == null) {
|
||||
instance = new TxtOverlay(context.getApplicationContext());
|
||||
|
||||
File youyuan = context.getFileStreamPath("SIMYOU.ttf");
|
||||
if (!youyuan.exists()){
|
||||
AssetManager am = context.getAssets();
|
||||
try {
|
||||
InputStream is = am.open("zk/SIMYOU.ttf");
|
||||
FileOutputStream os = context.openFileOutput("SIMYOU.ttf", Context.MODE_PRIVATE);
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
os.close();
|
||||
is.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
File youyuan = context.getFileStreamPath("SIMYOU.ttf");
|
||||
if (!youyuan.exists()){
|
||||
throw new IllegalArgumentException("the font file must be exists,please call install before!");
|
||||
}
|
||||
ctx = txtOverlayInit(width, height,youyuan.getAbsolutePath());
|
||||
}
|
||||
|
||||
public void overlay(byte[] data,
|
||||
String txt) {
|
||||
// txt = "drawtext=fontfile="+context.getFileStreamPath("SIMYOU.ttf")+": text='EasyPusher 2017':x=(w-text_w)/2:y=H-60 :fontcolor=white :box=1:boxcolor=0x00000000@0.3";
|
||||
// txt = "movie=/sdcard/qrcode.png [logo];[in][logo] "
|
||||
// + "overlay=" + 0 + ":" + 0
|
||||
// + " [out]";
|
||||
// if (ctx == 0) throw new RuntimeException("init should be called at first!");
|
||||
if (ctx == 0) return;
|
||||
txtOverlay(ctx, data, txt);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (ctx == 0) return;
|
||||
txtOverlayRelease(ctx);
|
||||
ctx = 0;
|
||||
}
|
||||
|
||||
|
||||
private static native long txtOverlayInit(int width, int height, String fonts);
|
||||
|
||||
private static native void txtOverlay(long ctx, byte[] data, String txt);
|
||||
|
||||
private static native void txtOverlayRelease(long ctx);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user