From 714ef3d64f4707bbf3f5602d632b096a65311a9d Mon Sep 17 00:00:00 2001 From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674> Date: 星期五, 12 五月 2017 14:48:50 +0800 Subject: [PATCH] --- VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java | 13 + VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml | 14 + VisitFace/DemoForBsk/app/src/main/assets/license.lic | 56 +++++++ VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java | 4 VisitFace/DemoForBsk/app/src/main/AndroidManifest.xml | 6 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/BitmapUtil.java | 300 +++++++++++++++++++++++++++++++++++-- VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java | 31 +++ VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java | 9 VisitFace/DemoForBsk/app/src/main/jniLibs/armeabi-v7a/librtspface.so | 0 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java | 2 10 files changed, 400 insertions(+), 35 deletions(-) diff --git a/VisitFace/DemoForBsk/app/src/main/AndroidManifest.xml b/VisitFace/DemoForBsk/app/src/main/AndroidManifest.xml index 1db3ae5..09fca88 100644 --- a/VisitFace/DemoForBsk/app/src/main/AndroidManifest.xml +++ b/VisitFace/DemoForBsk/app/src/main/AndroidManifest.xml @@ -11,6 +11,11 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> + <uses-permission android:name="android.permission.BROADCAST_STICKY" /> + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> + <application android:name="cn.com.basic.face.base.BaseApplication" android:allowBackup="true" @@ -24,7 +29,6 @@ android:windowSoftInputMode="adjustPan"> <intent-filter> <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> diff --git a/VisitFace/DemoForBsk/app/src/main/assets/license.lic b/VisitFace/DemoForBsk/app/src/main/assets/license.lic new file mode 100644 index 0000000..db0bd82 --- /dev/null +++ b/VisitFace/DemoForBsk/app/src/main/assets/license.lic @@ -0,0 +1,56 @@ +############################################################ +# SenseTime License +# License Product: FaceSdk +# Expiration: 20170309~20170609 +# License SN: 23eba58f-d927-4c8b-b531-fb588326e79d +############################################################ +sGfdd5sxA8NCweDGA+vU2qzOgOjTn64wtsOftvbVw+MzmQXlL9gGE+JsM0nU +lOHN/Ai/mjyyPqGW4W5FxJgLnqgzp2g09JkRdjXGle8IEY8ag4wXH8LUT+XY +OXBBvilrGRazpr4ni1SVkpgxTHoX3GdBY09aLCaJ9uCj1p7uErIgjhC2AQAA +AAEAAAABJioS4yQz2pTIieigSTrt4ANVz5LRRa52XLWQvB2azvNdASaqkN2B +qMLx/Hy1Bq6TLqWxL0paF9Xj5t/xptpwmax0BxY+Dn4rsdJj4PnChey1B2Hx +OLlVDQUj+oZ3lgpzi1wdFp8RLKEDJVa5WRuiV8Po3o+JrDz5DvX+FJIKyrgF +5piZ69rc/zi0ohoz3VqCCr1OEUv4XSpDkK/g+1NkBHvco/EZe8wLoh0R7nQR +7yHAzGQRZMEBTaduWIATW1PeBQJxUjKGCv57aCB5jeGk0wg/60/4702f2Dth +RpZOeMvfbYedzag4SKaHN5rQ9jE+L0dCqREJvkfUVMYJ8wyvAQABAAAAAAAD +AAAAAAAAAAAAAAAdFrdcj38Pba/zw3OZ/zBgEZR1PVWeUBie2oiKNyH5oui3 +TgKfJH5wsLTGRPVm9S7pvOYfkLzS36uvuwvzZDyuWR2Z4LhnnZuPmaVqjKCs +8vqKNKoYMjqRuKlLc/y+lAk4U/2HGWDkWruVyV2pwqQhUEreQjDI3kFfwPtR +Ku7yaU4WpTKlQnuqI0Obs6/RqzM+XXs3TfxMOQAiBu+kWzaZTC19BtXMPFrN +fAjbMnQde9bo7miN0Suho+Y+NJZgyHmTyQ== +------------------------------------------------------------ +sGfdd4ync6ncI3nEVcIUuDiB2p7YiL+mf00nQjQQvJDzvxzxFPvWImdrzRrz +SsYr6tyb7VKTFrtomRgHb6rAdQ73f6PjkCrObDuTl8VuM5ZWsQ3+L2elXInc +CERoBcK8QD/vnFDJZrbMIVYnp/3nMfrbH4dlfsNiRjGCSKc2wfBXOc3mAQAA +AAEAAACfjNAHR/gO6dqbIlC8U/1fwvD36bQEhb4W1dCHwbF/z6XaS7IMvYQc +t3y7lDyrbWeD4WE5b5chSLgza2yF0MRicANpv7p0juOxC7UW8wAlS9Kc4fZL +PqwJAHZQX6Lvq1RyMZdRYgXfS3G9IKHjzxM0Ffzouj3ZDKxE5u+Aggxjx8CL +EGYtcutF6ucUDrxbrVxKzP1s6xTcoKg2leRaum7D6wJQrfSMjFJd6Y3t1bWz +Ta4Nwez/On6PNmGkKwf/FZtay1cp33pMzTRbciDCBuDVnzqnbLhRrRJBJwrK +IFTZETbC3EU9z62mbMOrRU6DumwmO4/JH6Y6SdG0jcNZgHiXAQABAAAAAAAD +AAAAAAAAAAAAAABaGOJAie6YMETNu9Z7SRpvDvpF+/CVNzjmbD07Pf0yCcgV +teA61Pju5L3m4SEMmmc5bQd+lCbi3iJJla6B00nvIn9oJDW5yyHeAEbD7fGz +jnMGlhA6TBroyrMS0Ioc7kWV+jPNMqpH12+/d72mSjJxzoAcJCEVrdZXQM/x +acx2zjEcCTUmB1Am6kwN3JwRkLYbmvuX3BYEFmdb/asfbrqY7XEg0QM979yt +lfDfiMbabiEq+07Hw4JNIFBpJH48gsONtIVp1z/Q4JKgWJePjCN4uqAzXjm7 +OTwMy9UMwQZVvXa2uvdEBsK9uD1RZhDhhCM9cmQxSQlsPvPuBVngDk+7WfqJ +XX/t8Gvr9BHyTpfr9F9g+ycHN7I= +------------------------------------------------------------ +sGfdd51jz/3P1rkqceNQHuMInGXxJ3464NMUHYbgKSCoXBJMahSemJnZS1lw +MjS3FfxgWpCUlzsjN8PdPsCvmhTySdSGbAeZG6QEGe5odctMsw70fTQaayLm +yR5PDhKsnhRz+tCWyIDm53jFT+3ne39D3a8d/8X2lOFMhITh19BLtYUNAQAA +AAIAAABsqqz6JmKzKzcOFs9F4pl4XEwqDhhCqbeGww6tX1zB8xQQnhLu9apg +CYi/GPXi8e3NTWfccJ802gfmovCeTIJVnM+9i890/Vs9ZdRexAJDePbRGA8S +wOs5w5OoGc1j7Uf0gtJTNhzrQVDSROeu64SPgK3sAOmEmfoIgvfG6BkwSuyD +alKNI4ls/2OtCSU83tlQm3+c/298/KG+rm0QQ5spiMQtK+oWZy96/vTaCC7W +fYeyPxRDdVL2eEqf3pI81T6bUVfr/PAIQY6gxWD6EjyIsSrvFTDlUjl+y2o/ +VzP6XULm89mZ0KVtr0cJWCZhZWsB5k1MvRQPjNPQJzvuWiYbAAAAAAAAAAAA +AAAAAAAAAAAAAABDsOfzevB2OT/KCieqW0YYsaVPN/+VQQrNJh15Ipin5axF +PeyfcBeEkbP8P57z0Q+REKkQyHzarmD++TO7nsiklUMT0KazEWZYS7TwIEPz +ExveQ5EJzCV5+gm+zV0mA0IwTy3/TAodCWKBLaaEw8sg73boF1/qeMBBIEvQ +MGJMmBeBpx2s2W2Eas4VMs5fRxCNtljiVtSktGuCMaIHq/hUAb53mkdves+3 +nrrD2MYa+opGDvt0vWvMaU+BrIgqUusoVowo2oP8LB8CMufn1O2B1gn2C8lV +OCwROzxgkMOnuhjT7LdMJUF0D2XIo1MfwVDjKTgJY3qEtK4whaV3OD+KteZN +mtTdh+F1fo/zqfQhDP3MWwF+tdd95eXJFnm7naPch+NfXmSif8O+cQ6noIQl +k+L3IpI4QiHPwdAXF+9ZnH42l4YZ +############################################################ \ No newline at end of file diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java index d561e34..1c633ef 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java @@ -22,6 +22,7 @@ import cn.com.basic.face.discern.query.item.SurveillanceQueryItem; import cn.com.basic.face.fragment.*; import cn.com.basic.face.util.AppApi; +import cn.com.basic.face.util.BitmapUtil; import cn.com.basic.face.util.Constant; public class SurveillanceFragment { @@ -85,7 +86,8 @@ fragment_home_bottom_register_cell_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE +item.getImagePath())); } else { if (item.getBitmap() != null) { - fragment_home_bottom_register_cell_photo.setImageBitmap(item.getBitmap()); + fragment_home_bottom_register_cell_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(), + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); } else { fragment_home_bottom_register_cell_photo.setImageResource(R.drawable.u45); } @@ -95,7 +97,7 @@ @Override public void onClick(View view) { MainActivity.selectPage(1); - RegisterFragment.getInstance().setRegisterInfo(getVo(item));//java.lang.OutOfMemoryError: Failed to allocate a 25338980 byte allocation with 15827186 free bytes and 15MB until OOM +// RegisterFragment.getInstance().setRegisterInfo(getVo(item));//java.lang.OutOfMemoryError: Failed to allocate a 25338980 byte allocation with 15827186 free bytes and 15MB until OOM if(item.getBitmap() != null) { RegisterFragment.getInstance().setChoosePhoto(item.getBitmap()); RegisterFragment.getInstance().setSurveillanceQueryItem_selectPhoto(item); @@ -314,7 +316,8 @@ fragment_surveillance_photo_cell_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE +item.getImagePath())); } else { if (item.getBitmap() != null) { - fragment_surveillance_photo_cell_photo.setImageBitmap(item.getBitmap()); + fragment_surveillance_photo_cell_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(), + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); } else { fragment_surveillance_photo_cell_photo.setImageResource(R.drawable.u45); } diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java index 23c7de1..3cae29f 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java @@ -28,6 +28,7 @@ import cn.com.basic.face.service.DictionaryMng; import cn.com.basic.face.service.RegisterMng; import cn.com.basic.face.service.SurveillanceMng; +import cn.com.basic.face.util.BitmapUtil; import cn.com.basic.face.util.Constant; import cn.com.basic.face.util.NativeImg; import cn.com.basic.face.util.OkClickedListener; @@ -257,7 +258,8 @@ public void set_fragment_register_surveillance_photo(SurveillanceQueryItem item) { surveillanceQueryItem_selectPhoto = item; - fragment_register_surveillance_photo.setImageBitmap(item.getBitmap()); + fragment_register_surveillance_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(), + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); fragment_register_surveillance_photo_img = item.getBitmap(); fragment_register_surveillance_photo_placeholder_image.setVisibility(View.INVISIBLE); fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.INVISIBLE); @@ -265,7 +267,8 @@ public void set_fragment_register_upload_custom_photo(SurveillanceQueryItem item) { surveillanceQueryItem_uploadPhoto = item; - fragment_register_upload_custom_photo.setImageBitmap(item.getBitmap()); + fragment_register_upload_custom_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(), + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); fragment_register_upload_custom_photo_img = item.getBitmap(); fragment_register_upload_custom_photo_placeholder_image.setVisibility(View.INVISIBLE); @@ -326,7 +329,8 @@ Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri); - fragment_register_id_card_photo.setImageBitmap(bitmap); + fragment_register_id_card_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(bitmap, + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); fragment_register_id_card_photo_img = bitmap; MainActivity.getInstance().getContentResolver().delete(uri, null, null); @@ -468,7 +472,8 @@ } public void setChoosePhoto(Bitmap bitmap) { - fragment_register_surveillance_photo.setImageBitmap(bitmap); + fragment_register_surveillance_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(bitmap, + (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp))); fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.INVISIBLE); fragment_register_surveillance_photo_placeholder_image.setVisibility(View.INVISIBLE); } diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java index 4dc0da9..e42172e 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java @@ -23,9 +23,16 @@ 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; public class SurveillanceFragment extends BaseFragment { @@ -116,6 +123,12 @@ 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()); @@ -123,6 +136,24 @@ 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 { diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java index 1052c88..61376e0 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java @@ -116,7 +116,7 @@ // port = camera1.getString("fragment_device_right_camera1_port", ""); // } - return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/sub/av_stream"; + return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/main/av_stream"; } public String getCamera2Address() { @@ -139,7 +139,7 @@ // port = camera1.getString("fragment_device_right_camera1_port", ""); // } - return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/sub/av_stream"; + return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/main/av_stream"; } } diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/BitmapUtil.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/BitmapUtil.java index 9f32ab5..6d09740 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/BitmapUtil.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/BitmapUtil.java @@ -2,7 +2,9 @@ import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; @@ -33,30 +35,292 @@ return output; } - public static Bitmap getCornerBitmap(Bitmap bitmap) { - int min = bitmap.getWidth() > bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth(); + public static Bitmap getCornerBitmap(Bitmap mBitmap) { +// int min = bitmap.getWidth() > bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth(); +// +// int width = bitmap.getWidth(); +// int height = bitmap.getHeight(); +// +// Bitmap output = Bitmap.createBitmap(width, +// height, Bitmap.Config.ARGB_8888); +// Canvas canvas = new Canvas(output); +// +// final int color = 0xff424242; +// final Paint paint = new Paint(); +// final RectF rectF = new RectF(0, 0, width, height); +// final Rect rect = new Rect(0, 0, width, height); +// +// paint.setAntiAlias(true); +// canvas.drawARGB(0, 0, 0, 0); +// paint.setColor(color); +// //canvas.drawCircle(min / 2, min / 2, min / 2, paint); +// canvas.drawRoundRect(rectF, 333, 333, paint); +// paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); +// canvas.drawBitmap(bitmap, rect, rect, paint); +// +// return output; + // Create a rounded corners bitmap +// mBitmap = getRoundedBitmap(mBitmap, cornerRadius); +// +// // Add a border around rounded corners bitmap +// mBitmap = addBorderToRoundedBitmap(mBitmap, cornerRadius, 10, Color.WHITE); +// +// // Add a border around rounded corners bitmap as shadow +// mBitmap = addBorderToRoundedBitmap(mBitmap, cornerRadius, 3, Color.LTGRAY); + return mBitmap; + } - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); + public static Bitmap getRoundedCornerBitmap(Bitmap mBitmap, int cornerRadius) { +// Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap +// .getHeight(), Bitmap.Config.ARGB_8888); +// Canvas canvas = new Canvas(output); +// +// final int color = 0xff424242; +// final Paint paint = new Paint(); +// final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); +// final RectF rectF = new RectF(rect); +// final float roundPx = pixels; +// +// paint.setAntiAlias(true); +// canvas.drawARGB(0, 0, 0, 0); +// paint.setColor(color); +// canvas.drawRoundRect(rectF, roundPx, roundPx, paint); +// +// paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); +// canvas.drawBitmap(bitmap, rect, rect, paint); +// +// return output; - Bitmap output = Bitmap.createBitmap(width, - height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); + mBitmap = getRoundedBitmap(mBitmap, cornerRadius); - final int color = 0xff424242; - final Paint paint = new Paint(); - final RectF rectF = new RectF(0, 0, width, height); - final Rect rect = new Rect(0, 0, width, height); + // Add a border around rounded corners bitmap + mBitmap = addBorderToRoundedBitmap(mBitmap, cornerRadius, 10, Color.WHITE); + // Add a border around rounded corners bitmap as shadow + mBitmap = addBorderToRoundedBitmap(mBitmap, cornerRadius, 3, Color.LTGRAY); + return mBitmap; + } + + public static Path RoundedRect( + float left, float top, float right, float bottom, float rx, float ry, + boolean tl, boolean tr, boolean br, boolean bl + ){ + Path path = new Path(); + if (rx < 0) rx = 0; + if (ry < 0) ry = 0; + float width = right - left; + float height = bottom - top; + if (rx > width / 2) rx = width / 2; + if (ry > height / 2) ry = height / 2; + float widthMinusCorners = (width - (2 * rx)); + float heightMinusCorners = (height - (2 * ry)); + + path.moveTo(right, top + ry); + if (tr) + path.rQuadTo(0, -ry, -rx, -ry);//top-right corner + else{ + path.rLineTo(0, -ry); + path.rLineTo(-rx,0); + } + path.rLineTo(-widthMinusCorners, 0); + if (tl) + path.rQuadTo(-rx, 0, -rx, ry); //top-left corner + else{ + path.rLineTo(-rx, 0); + path.rLineTo(0,ry); + } + path.rLineTo(0, heightMinusCorners); + + if (bl) + path.rQuadTo(0, ry, rx, ry);//bottom-left corner + else{ + path.rLineTo(0, ry); + path.rLineTo(rx,0); + } + + path.rLineTo(widthMinusCorners, 0); + if (br) + path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner + else{ + path.rLineTo(rx,0); + path.rLineTo(0, -ry); + } + + path.rLineTo(0, -heightMinusCorners); + + path.close();//Given close, last lineto can be removed. + + return path; + } + + // Custom method to create rounded bitmap from a rectangular bitmap + public static Bitmap getRoundedBitmap(Bitmap srcBitmap, int cornerRadius) { + // Initialize a new instance of Bitmap + Bitmap dstBitmap = Bitmap.createBitmap( + srcBitmap.getWidth(), // Width + srcBitmap.getHeight(), // Height + + Bitmap.Config.ARGB_8888 // Config + ); + + /* + Canvas + The Canvas class holds the "draw" calls. To draw something, you need 4 basic + components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing + into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint + (to describe the colors and styles for the drawing). + */ + // Initialize a new Canvas to draw rounded bitmap + Canvas canvas = new Canvas(dstBitmap); + + // Initialize a new Paint instance + Paint paint = new Paint(); paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(color); - //canvas.drawCircle(min / 2, min / 2, min / 2, paint); - canvas.drawRoundRect(rectF, 333, 333, paint); - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, rect, rect, paint); - return output; + /* + Rect + Rect holds four integer coordinates for a rectangle. The rectangle is represented by + the coordinates of its 4 edges (left, top, right bottom). These fields can be accessed + directly. Use width() and height() to retrieve the rectangle's width and height. + Note: most methods do not check to see that the coordinates are sorted correctly + (i.e. left <= right and top <= bottom). + */ + /* + Rect(int left, int top, int right, int bottom) + Create a new rectangle with the specified coordinates. + */ + // Initialize a new Rect instance + Rect rect = new Rect(0, 0, srcBitmap.getWidth(), srcBitmap.getHeight()); + + /* + RectF + RectF holds four float coordinates for a rectangle. The rectangle is represented by + the coordinates of its 4 edges (left, top, right bottom). These fields can be + accessed directly. Use width() and height() to retrieve the rectangle's width and + height. Note: most methods do not check to see that the coordinates are sorted + correctly (i.e. left <= right and top <= bottom). + */ + // Initialize a new RectF instance + RectF rectF = new RectF(rect); + + /* + public void drawRoundRect (RectF rect, float rx, float ry, Paint paint) + Draw the specified round-rect using the specified paint. The roundrect will be + filled or framed based on the Style in the paint. + + Parameters + rect : The rectangular bounds of the roundRect to be drawn + rx : The x-radius of the oval used to round the corners + ry : The y-radius of the oval used to round the corners + paint : The paint used to draw the roundRect + */ + // Draw a rounded rectangle object on canvas + canvas.drawRoundRect(rectF, cornerRadius, cornerRadius, paint); + + /* + public Xfermode setXfermode (Xfermode xfermode) + Set or clear the xfermode object. + Pass null to clear any previous xfermode. As a convenience, the parameter passed + is also returned. + + Parameters + xfermode : May be null. The xfermode to be installed in the paint + Returns + xfermode + */ + /* + public PorterDuffXfermode (PorterDuff.Mode mode) + Create an xfermode that uses the specified porter-duff mode. + + Parameters + mode : The porter-duff mode that is applied + + */ + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); + + /* + public void drawBitmap (Bitmap bitmap, float left, float top, Paint paint) + Draw the specified bitmap, with its top/left corner at (x,y), using the specified + paint, transformed by the current matrix. + + Note: if the paint contains a maskfilter that generates a mask which extends beyond + the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be + drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the + original width/height will be the edge color replicated. + + If the bitmap and canvas have different densities, this function will take care of + automatically scaling the bitmap to draw at the same density as the canvas. + + Parameters + bitmap : The bitmap to be drawn + left : The position of the left side of the bitmap being drawn + top : The position of the top side of the bitmap being drawn + paint : The paint used to draw the bitmap (may be null) + */ + // Make a rounded image by copying at the exact center position of source image + canvas.drawBitmap(srcBitmap, 0, 0, paint); + + // Free the native object associated with this bitmap. + srcBitmap.recycle(); + + // Return the circular bitmap + return dstBitmap; + } + + // Custom method to add a border around rounded bitmap + public static Bitmap addBorderToRoundedBitmap(Bitmap srcBitmap, int cornerRadius, int borderWidth, int borderColor){ + // We will hide half border by bitmap + borderWidth = borderWidth*2; + + // Initialize a new Bitmap to make it bordered rounded bitmap + Bitmap dstBitmap = Bitmap.createBitmap( + srcBitmap.getWidth() + borderWidth, // Width + srcBitmap.getHeight() + borderWidth, // Height + Bitmap.Config.ARGB_8888 // Config + ); + + // Initialize a new Canvas instance + Canvas canvas = new Canvas(dstBitmap); + + // Initialize a new Paint instance to draw border + Paint paint = new Paint(); + paint.setColor(borderColor); + paint.setStyle(Paint.Style.STROKE); + paint.setStrokeWidth(borderWidth); + paint.setAntiAlias(true); + + // Initialize a new Rect instance + Rect rect = new Rect( + borderWidth/2, + borderWidth/2, + dstBitmap.getWidth() - borderWidth/2, + dstBitmap.getHeight() - borderWidth/2 + ); + + // Initialize a new instance of RectF; + RectF rectF = new RectF(rect); + + // Draw rounded rectangle as a border/shadow on canvas + canvas.drawRoundRect(rectF,cornerRadius,cornerRadius,paint); + + // Draw source bitmap to canvas + canvas.drawBitmap(srcBitmap, borderWidth / 2, borderWidth / 2, null); + + /* + public void recycle () + Free the native object associated with this bitmap, and clear the reference to the + pixel data. This will not free the pixel data synchronously; it simply allows it to + be garbage collected if there are no other references. The bitmap is marked as + "dead", meaning it will throw an exception if getPixels() or setPixels() is called, + and will draw nothing. This operation cannot be reversed, so it should only be + called if you are sure there are no further uses for the bitmap. This is an advanced + call, and normally need not be called, since the normal GC process will free up this + memory when there are no more references to this bitmap. + */ + srcBitmap.recycle(); + + // Return the bordered circular bitmap + return dstBitmap; } } diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java index fa63722..e8ce15e 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java @@ -55,7 +55,7 @@ public static native void dbgFaceAdd(NativeImg faceImage); public static native String dbgGetLog(); - + public static native void dbgSetStfaceLicense(String lic); public static int COMPANY_ID = 1001; diff --git a/VisitFace/DemoForBsk/app/src/main/jniLibs/armeabi-v7a/librtspface.so b/VisitFace/DemoForBsk/app/src/main/jniLibs/armeabi-v7a/librtspface.so index ecdd8a7..ff1f3d5 100644 --- a/VisitFace/DemoForBsk/app/src/main/jniLibs/armeabi-v7a/librtspface.so +++ b/VisitFace/DemoForBsk/app/src/main/jniLibs/armeabi-v7a/librtspface.so Binary files differ diff --git a/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml b/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml index 1672d5a..1737038 100644 --- a/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml +++ b/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml @@ -30,10 +30,12 @@ </RelativeLayout> <LinearLayout android:layout_width="match_parent" - android:layout_height="@dimen/h350dp" + android:layout_height="0dp" android:orientation="horizontal" android:paddingLeft="2dp" - android:paddingRight="2dp"> + android:paddingRight="2dp" + android:layout_weight="1" + > <RelativeLayout android:layout_width="@dimen/view_size_0" android:layout_height="match_parent" @@ -118,10 +120,12 @@ <LinearLayout android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="@dimen/h280dp" android:layout_marginTop="@dimen/h4dp" android:paddingRight="@dimen/h4dp" - android:orientation="horizontal"> + android:orientation="horizontal" + android:layout_weight="0" + > <RelativeLayout android:layout_width="wrap_content" android:layout_height="match_parent"> @@ -159,7 +163,6 @@ android:layout_width="@dimen/w5dp" android:layout_height="match_parent" android:orientation="vertical"> - <View android:id="@+id/fragment_supervisory_bottom_visitor_background" android:layout_width="match_parent" @@ -186,7 +189,6 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"/> - <cn.com.basic.face.widget.surveilance.SurveillanceBottomAttendanceListView android:id="@+id/fragment_supervisory_bottom_attendance_list_view" android:layout_width="wrap_content" -- Gitblit v1.8.0