Skip to content

Commit 2400314

Browse files
committed
加入set format api
1 parent c3bc48a commit 2400314

7 files changed

Lines changed: 31 additions & 12 deletions

File tree

czxing/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include_directories(zxing)
1414
include_directories(include)
1515
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_SOURCE_DIR}/../../../libs/${ANDROID_ABI}")
1616

17-
add_compile_options(czxing "-O1" "-fPIC")
17+
#add_compile_options(czxing "-O1" "-fPIC")
1818

1919
# 静态方式导入库
2020
add_library(opencv_core STATIC IMPORTED)

czxing/src/main/cpp/ImageScheduler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void ImageScheduler::preTreatMat(const FrameData &frameData) {
130130

131131
// 分析亮度,如果亮度过低,不进行处理
132132
analysisBrightness(gray);
133-
if (cameraLight < 40) {
133+
if (cameraLight < 30) {
134134
return;
135135
}
136136

@@ -259,7 +259,7 @@ void ImageScheduler::recognizerQrCode(const Mat &mat) {
259259

260260
cv::Rect rect;
261261
qrCodeRecognizer->processData(mat, &rect);
262-
if (rect.empty() || rect.height < 110) {
262+
if (rect.empty() || rect.height < 100) {
263263
return;
264264
}
265265

czxing/src/main/cpp/zxing/src/MultiFormatReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ MultiFormatReader::MultiFormatReader(const DecodeHints& hints)
7979
}
8080
_readers.emplace_back(new QRCode::Reader(hints));
8181
_readers.emplace_back(new DataMatrix::Reader(hints));
82-
// _readers.emplace_back(new Aztec::Reader());
83-
// _readers.emplace_back(new Pdf417::Reader());
84-
// _readers.emplace_back(new MaxiCode::Reader());
82+
_readers.emplace_back(new Aztec::Reader());
83+
_readers.emplace_back(new Pdf417::Reader());
84+
_readers.emplace_back(new MaxiCode::Reader());
8585
if (tryHarder) {
8686
_readers.emplace_back(new OneD::Reader(hints));
8787
}

czxing/src/main/java/me/devilsen/czxing/ScanActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ private void initData() {
8484
if (option == null) {
8585
return;
8686
}
87+
mScanView.setScanMode(option.getScanMode());
88+
mScanView.setBarcodeFormat(option.getBarcodeFormat());
89+
8790
ScanBoxView scanBox = mScanView.getScanBox();
8891
scanBox.setCornerColor(option.getCornerColor());
8992
scanBox.setBorderColor(option.getBorderColor());
90-
mScanView.setScanMode(option.getScanMode());
9193
scanBox.setScanLineColor(option.getScanLineColors());
9294
scanBox.setFlashLightOnText(option.getFlashLightOnText());
9395
scanBox.setFlashLightOffText(option.getFlashLightOffText());
9496
scanBox.setScanNoticeText(option.getScanNoticeText());
9597

96-
// mScanView.setBarcodeFormat(BarcodeFormat.EAN_13);
97-
9898
// 标题栏
9999
String title = option.getTitle();
100100
if (title != null) {

czxing/src/main/java/me/devilsen/czxing/ScannerManager.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
import android.os.Parcelable;
77

88
import java.util.ArrayList;
9+
import java.util.Arrays;
910
import java.util.List;
1011

12+
import me.devilsen.czxing.code.BarcodeFormat;
1113
import me.devilsen.czxing.view.ScanActivityDelegate;
1214

1315
/**
@@ -76,6 +78,11 @@ public ScannerManager setScanLineColors(List<Integer> scanLineColors) {
7678
return this;
7779
}
7880

81+
public ScannerManager setBarcodeFormat(BarcodeFormat... barcodeFormats){
82+
scanOption.barcodeFormats = Arrays.asList(barcodeFormats);
83+
return this;
84+
}
85+
7986
public ScannerManager setOnScanResultDelegate(ScanActivityDelegate.OnScanDelegate delegate) {
8087
ScanActivityDelegate.getInstance().setScanResultDelegate(delegate);
8188
return this;
@@ -105,6 +112,7 @@ public static class ScanOption implements Parcelable {
105112
private String flashLightOffText;
106113
private String scanNoticeText;
107114

115+
private List<BarcodeFormat> barcodeFormats;
108116
private List<Integer> scanLineColors;
109117

110118
public int getCornerColor() {
@@ -147,6 +155,10 @@ public List<Integer> getScanLineColors() {
147155
return scanLineColors;
148156
}
149157

158+
public BarcodeFormat[] getBarcodeFormat() {
159+
return barcodeFormats.toArray(new BarcodeFormat[0]);
160+
}
161+
150162
@Override
151163
public int describeContents() {
152164
return 0;
@@ -163,6 +175,7 @@ public void writeToParcel(Parcel dest, int flags) {
163175
dest.writeString(this.flashLightOnText);
164176
dest.writeString(this.flashLightOffText);
165177
dest.writeString(this.scanNoticeText);
178+
dest.writeList(this.barcodeFormats);
166179
dest.writeList(this.scanLineColors);
167180
}
168181

@@ -179,6 +192,8 @@ protected ScanOption(Parcel in) {
179192
this.flashLightOnText = in.readString();
180193
this.flashLightOffText = in.readString();
181194
this.scanNoticeText = in.readString();
195+
this.barcodeFormats = new ArrayList<>();
196+
in.readList(this.barcodeFormats, BarcodeFormat.class.getClassLoader());
182197
this.scanLineColors = new ArrayList<>();
183198
in.readList(this.scanLineColors, Integer.class.getClassLoader());
184199
}

czxing/src/main/java/me/devilsen/czxing/view/ScanView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public void onPreviewFrame(byte[] data, int left, int top, int width, int height
6565
* 设置扫描格式
6666
*/
6767
public void setBarcodeFormat(BarcodeFormat... formats) {
68+
if (formats == null || formats.length == 0) {
69+
return;
70+
}
6871
reader.setBarcodeFormat(formats);
6972
}
7073

sample/src/main/java/me/sam/czxing/MainActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ public void openScan(View view) {
8484
.setScanLineColors(scanColors)
8585
.setScanMode(ScanView.SCAN_MODE_MIX)
8686
.setTitle("我的扫一扫")
87-
.setScanNoticeText("扫描二维码")
88-
.setFlashLightOnText("打开闪光灯")
89-
.setFlashLightOffText("关闭闪光灯")
87+
// .setBarcodeFormat(BarcodeFormat.EAN_13)
88+
// .setScanNoticeText("扫描二维码")
89+
// .setFlashLightOnText("打开闪光灯")
90+
// .setFlashLightOffText("关闭闪光灯")
9091
.showAlbum(true)
9192
.continuousScan()
9293
.setOnClickAlbumDelegate(new ScanActivityDelegate.OnClickAlbumDelegate() {

0 commit comments

Comments
 (0)