From bcb82cc81cffcef1ef915b4149c07b3b07cce2f8 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 28 四月 2017 17:37:42 +0800
Subject: [PATCH] optimize
---
VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java | 98 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java b/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java
index e6fd85f..dff4f0c 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java
+++ b/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java
@@ -17,8 +17,9 @@
package com.example.nativecodec;
import android.app.Activity;
-import android.content.res.AssetManager;
+import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
@@ -30,12 +31,22 @@
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.Spinner;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.widget.Button;
+import android.widget.TextView;
-import com.bsk.zhangbo.demoforbsk.util.RtspFaceNative;
+import java.nio.ByteBuffer;
-import java.io.IOException;
+import cn.com.basic.face.util.NativeImg;
+import cn.com.basic.face.util.RtspFaceNative;
public class NativeCodec extends Activity {
static final String TAG = "NativeCodec";
@@ -54,13 +65,18 @@
boolean mCreated = false;
boolean mIsPlaying = false;
+ public static NativeImg faceImg = null;
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
+ ThisActivity = this;
+
RtspFaceNative.init();
+ RtspFaceNative.setLocalIP("192.168.1.10");
mGLView1 = (MyGLSurfaceView) findViewById(R.id.glsurfaceview1);
@@ -192,9 +208,12 @@
//mCreated = createStreamingMediaPlayer(getResources().getAssets(), mSourceString);
//#todo ok
- mCreated = RtspFaceNative.createPlayer(1, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream");
- mCreated = RtspFaceNative.createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/sub/av_stream");
+ mCreated = RtspFaceNative.createPlayer(1, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/sub/av_stream");
+ //mCreated = RtspFaceNative.createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/sub/av_stream");
//mCreated = createPlayer(1, "rtsp://192.168.1.56:8554");
+
+ RtspFaceNative.setFaceCallback(1, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
+ //RtspFaceNative.setFaceCallback(2, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
//byte[] arr = new byte[5];
//arr[0] = 3; arr[1] = 4; arr[2] = 5;
@@ -222,6 +241,71 @@
}
});
+
+ ((Button) findViewById(R.id.addface_native)).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ Log.i("@@@", "addface_native onClick");
+
+ }
+
+ });
+
+ ((ImageView) findViewById(R.id.addface_image)).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ Log.i("@@@", "addface_image onClick");
+ //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image);
+ //image.setImageBitmap(faceBitmap);
+ }
+
+ });
+
+ ((Button) findViewById(R.id.addface_native)).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ Log.i("@@@", "addface_image onClick");
+ RtspFaceNative.dbgFaceAdd(ThisActivity.faceImg);
+ }
+
+ });
+
+ }
+
+ static NativeCodec ThisActivity;
+
+ public static void setFaceDrawable(NativeImg img)
+ {
+ //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image);
+ //return image;
+
+ ThisActivity.faceImg = img;
+
+ //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image);
+ //image.callOnClick();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ThisActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Bitmap bitmap = Bitmap.createBitmap(faceImg.width, faceImg.height, Bitmap.Config.ARGB_8888);
+ ByteBuffer byteBuffer = ByteBuffer.wrap(faceImg.image, 0, faceImg.size);
+ bitmap.copyPixelsFromBuffer(byteBuffer);
+
+ ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image);
+ image.setImageBitmap(bitmap);
+
+ TextView textView1 = (TextView)ThisActivity.findViewById(R.id.textView1);
+ textView1.setText(RtspFaceNative.dbgGetLog());
+ }
+ });
+ }
+ }).start();
}
void switchSurface() {
@@ -307,7 +391,7 @@
/** Load jni .so on initialization */
static {
System.loadLibrary("rtspface");
- //System.loadLibrary("opencv_java3");
+ System.loadLibrary("opencv_java3");
}
// VideoSink abstracts out the difference between Surface and SurfaceTexture
@@ -336,6 +420,7 @@
void useAsSinkForNative() {
Surface s = mSurfaceHolder.getSurface();
Log.i("@@@", "setting surface " + s);
+ //mSurfaceHolder1.setFormat(PixelFormat.RGBA_8888);
RtspFaceNative.setSurface(1, s);
}
@@ -357,6 +442,7 @@
void useAsSinkForNative() {
SurfaceTexture st = mMyGLSurfaceView.getSurfaceTexture();
Surface s = new Surface(st);
+ //setEGLConfigChooser(8, 8, 8, 8, 0, 0);
RtspFaceNative.setSurface(2, s);
s.release();
}
--
Gitblit v1.8.0