| | |
| | | package cn.com.basic.face.fragment; |
| | | |
| | | import android.graphics.ImageFormat; |
| | | import android.media.ImageReader; |
| | | import android.content.Context; |
| | | import android.net.wifi.WifiManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.text.format.Formatter; |
| | | import android.view.SurfaceView; |
| | | import android.view.View; |
| | | import android.widget.RadioButton; |
| | |
| | | import cn.com.basic.face.widget.surveilance.SurveillanceBottomAttendanceListView; |
| | | import cn.com.basic.face.widget.surveilance.SurveillanceBottomVisitorListView; |
| | | |
| | | import com.facebook.common.file.FileUtils; |
| | | import com.lidroid.xutils.view.annotation.ViewInject; |
| | | import com.lidroid.xutils.view.annotation.event.OnClick; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileReader; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | public class SurveillanceFragment extends BaseFragment { |
| | | |
| | |
| | | System.loadLibrary("rtspface"); |
| | | RtspFaceNative.init(); |
| | | // RtspFaceNative.setLocalIP("192.168.1.10"); |
| | | RtspFaceNative.setLocalIP("192.168.1.106");//自己手机ip |
| | | // RtspFaceNative.setLocalIP("192.168.1.106");//自己手机ip |
| | | // RtspFaceNative.setLocalIP("192.168.1.203"); |
| | | // RtspFaceNative.setLocalIP("192.168.1.205"); |
| | | WifiManager wm = (WifiManager) MainActivity.getInstance().getSystemService(Context.WIFI_SERVICE); |
| | | String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); |
| | | RtspFaceNative.setLocalIP(ip); |
| | | } |
| | | } |
| | | |
| | |
| | | if (useNative) { |
| | | MainActivity.getInstance().runOnUiThread(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | String str = convertStreamToString(MainActivity.getInstance().getAssets().open("license.lic")); |
| | | RtspFaceNative.dbgSetStfaceLicense(str); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | RtspFaceNative.setSurface(1, fragment_supervisory_enter_camera.getHolder().getSurface()); |
| | | RtspFaceNative.setSurface(2, fragment_supervisory_exit_camera.getHolder().getSurface()); |
| | | RtspFaceNative.createPlayer(1, DeviceMng.getInstance().getCamera1Address()); |
| | |
| | | RtspFaceNative.setFaceCallback(1, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | RtspFaceNative.setFaceCallback(2, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | } |
| | | public String convertStreamToString(InputStream is) throws Exception { |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
| | | StringBuilder sb = new StringBuilder(); |
| | | String line = null; |
| | | while ((line = reader.readLine()) != null) { |
| | | sb.append(line).append("\n"); |
| | | } |
| | | reader.close(); |
| | | return sb.toString(); |
| | | } |
| | | public String getStringFromFile (String filePath) throws Exception { |
| | | File fl = new File(filePath); |
| | | FileInputStream fin = new FileInputStream(fl); |
| | | String ret = convertStreamToString(fin); |
| | | //Make sure you close all streams. |
| | | fin.close(); |
| | | return ret; |
| | | } |
| | | }); |
| | | |
| | | } else { |