package com.wintone.smartvision_bankCard;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.graphics.ImageFormat;
import android.graphics.Point;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.ShutterCallback;
import android.hardware.Camera.Size;
import android.media.ToneGenerator;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.text.format.Time;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import com.wintone.R;
import com.wintone.ShowResult;
import com.wintone.bankcard.BankCardAPI;
import com.wintone.utils.Utils;
import com.wintone.view.ViewfinderView;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class ScanCamera extends Activity implements Callback, PreviewCallback {
private static final String PATH = new StringBuilder(String.valueOf(Environment.getExternalStorageDirectory().toString())).append("/DCIM/Camera/").toString();
private static double NORMAL_CARD_SCALE = 1.58577d;
private BankCardAPI api;
private ImageButton back;
private Bitmap bitmap;
private Camera camera;
private TextView copyright_label;
private int counter = 0;
private int counterCut = 0;
private int counterFail = 0;
private ImageButton flash;
private int height;
private ImageView help_word;
private boolean isFatty = false;
private boolean isROI = false;
private boolean isShowBorder = false;
List<Size> list;
private Vibrator mVibrator;
private ViewfinderView myView;
private int preHeight = 0;
private int preWidth = 0;
private RelativeLayout re_c;
public int srcHeight;
public int srcWidth;
public int surfaceHeight;
private SurfaceHolder surfaceHolder;
private SurfaceView surfaceView;
public int surfaceWidth;
private byte[] tackData;
private Timer time;
private TimerTask timer;
private int width;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scan_camera);
setScreenSize(this);
findView();
}
protected void onRestart() {
if (this.bitmap != null) {
this.bitmap.recycle();
this.bitmap = null;
}
this.counterFail = 0;
super.onRestart();
}
protected void onResume() {
super.onResume();
this.api = new BankCardAPI();
this.api.WTInitCardKernal("", 0);
}
@SuppressLint({"NewApi"})
private void setScreenSize(Context context) {
int x;
int y;
Display display = ((WindowManager) context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
if (VERSION.SDK_INT >= 13) {
Point screenSize = new Point();
if (VERSION.SDK_INT >= 17) {
display.getRealSize(screenSize);
x = screenSize.x;
y = screenSize.y;
} else {
display.getSize(screenSize);
x = screenSize.x;
y = screenSize.y;
}
} else {
x = display.getWidth();
y = display.getHeight();
}
this.srcWidth = x;
this.srcHeight = y;
}
private void findView() {
this.surfaceView = (SurfaceView) findViewById(R.id.surfaceViwe);
this.re_c = (RelativeLayout) findViewById(R.id.re_c);
this.help_word = (ImageView) findViewById(R.id.help_word);
this.copyright_label = (TextView) findViewById(R.id.copyright_label);
this.back = (ImageButton) findViewById(R.id.back_camera);
this.flash = (ImageButton) findViewById(R.id.flash_camera);
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
this.width = metric.widthPixels;
this.height = metric.heightPixels;
if (this.width * 3 == this.height * 4) {
this.isFatty = true;
}
int back_w = (int) (((double) this.width) * 0.066796875d);
int back_h = back_w;
LayoutParams layoutParams = new LayoutParams(back_w, back_h);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
int Fheight = this.height;
if (this.isFatty) {
Fheight = (int) (((double) this.height) * 0.75d);
}
layoutParams.leftMargin = (int) ((((((double) this.width) - ((((double) Fheight) * 0.8d) * 1.585d)) / 2.0d) - ((double) back_h)) / 2.0d);
layoutParams.bottomMargin = (int) (((double) this.height) * 0.10486111111111111d);
this.back.setLayoutParams(layoutParams);
int flash_w = (int) (((double) this.width) * 0.066796875d);
layoutParams = new LayoutParams(flash_w, flash_w);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
if (this.isFatty) {
Fheight = (int) (((double) this.height) * 0.75d);
}
layoutParams.leftMargin = (int) ((((((double) this.width) - ((((double) Fheight) * 0.8d) * 1.585d)) / 2.0d) - ((double) back_h)) / 2.0d);
layoutParams.topMargin = (int) (((double) this.height) * 0.10486111111111111d);
this.flash.setLayoutParams(layoutParams);
int help_word_w = (int) (((double) this.width) * 0.474609375d);
int help_word_h = (int) (((double) help_word_w) * 0.05185185185185185d);
layoutParams = new LayoutParams(help_word_w, help_word_h);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
this.help_word.setLayoutParams(layoutParams);
layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
if (this.isFatty) {
layoutParams.bottomMargin = (this.height / 10) - (help_word_h / 2);
} else {
layoutParams.bottomMargin = (this.height / 20) - (help_word_h / 2);
}
this.copyright_label.setLayoutParams(
没有合适的资源?快使用搜索试试~ 我知道了~
Android银行卡识别demo
共43个文件
png:11个
xml:9个
java:8个
5星 · 超过95%的资源 需积分: 25 96 下载量 109 浏览量
2017-07-26
16:23:36
上传
评论 6
收藏 910KB ZIP 举报
温馨提示
Android银行卡识别demo
资源推荐
资源详情
资源评论
收起资源包目录
BankCardScanner-master.zip (43个子文件)
BankCardScanner-master
gradlew.bat 2KB
gradlew 5KB
gradle.properties 730B
app
proguard-rules.pro 674B
.DS_Store 6KB
src
test
java
com
wintone
ExampleUnitTest.java 389B
androidTest
java
com
wintone
ExampleInstrumentedTest.java 726B
main
res
mipmap-xxxhdpi
ic_launcher.png 10KB
drawable-xhdpi-v4
flash_camera_btn.png 6KB
back_info.png 1KB
ic_launcher.png 12KB
camera_word.png 9KB
dividing_line.png 83B
back_camera_btn.png 4KB
mipmap-hdpi
ic_launcher.png 3KB
values
colors.xml 799B
strings.xml 1KB
styles.xml 363B
dimens.xml 211B
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-mdpi
ic_launcher.png 2KB
mipmap-xhdpi
ic_launcher.png 5KB
layout
activity_main.xml 761B
activity_result.xml 768B
activity_scan_camera.xml 1KB
values-w820dp
dimens.xml 358B
java
com
wintone
smartvision_bankCard
ScanCamera.java 21KB
view
ViewfinderView.java 7KB
MainActivity.java 578B
bankcard
BankCardAPI.java 1KB
utils
Utils.java 2KB
ShowResult.java 908B
AndroidManifest.xml 2KB
.gitignore 7B
build.gradle 1004B
libs
armeabi
libAndroidBankCard.so 1.25MB
arm64-v8a
libAndroidBankCard.so 1.31MB
sun.misc.BASE64Decoder.jar 7KB
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 233B
.gitignore 465B
settings.gradle 15B
build.gradle 498B
共 43 条
- 1
资源评论
- 小天狼狼心2017-08-30很好用。。平的和凸出的银行卡都试了一下。。还有些特殊银行卡没扫出来。。
- qq_290243252019-05-11不错的资源
- qq_171166612020-03-21git上面的demo,38积分过分了
- 姜屹2018-09-28谢谢分享,有帮助
- 铁血玲珑女2017-10-25很赞,感觉很好用
静染星辰
- 粉丝: 3
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功