Skip to content

Commit 3b95363

Browse files
committed
adjust scanPoint size
1 parent 5dd67c7 commit 3b95363

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

czxing/src/main/cpp/ImageScheduler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ std::vector<ScanResult> ImageScheduler::decodeWeChat(const cv::Mat& gray)
132132
ScanResult result(res[i], codeRect);
133133
resultVector.push_back(result);
134134

135+
// cv::Point point(rect.x + rect.width / 2, rect.y + rect.height / 2);
136+
// cv::circle(gray, point, 20, {255, 0, 0}, -1);
137+
// saveMat(gray, "result");
138+
135139
LOGE("result = %s", res[i].c_str())
136140
LOGE("rect: x = %d, y = %d, width = %d, height = %d", rect.x, rect.y, rect.width, rect.height)
137141
}

czxing/src/main/cpp/native-lib.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ Java_me_devilsen_czxing_code_NativeSdk_readByte(JNIEnv *env, jobject instance, j
8080
return -1;
8181
}
8282

83+
if (bytes_ == nullptr) {
84+
return -1;
85+
}
86+
8387
jbyte *bytes = env->GetByteArrayElements(bytes_, nullptr);
8488

8589
auto imageScheduler = reinterpret_cast<czxing::ImageScheduler *>(objPtr);

czxing/src/main/java/me/devilsen/czxing/code/BarcodeReader.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
public class BarcodeReader {
1515

1616
private long _nativePtr;
17-
private static BarcodeReader instance;
17+
18+
private static final class InstanceHolder {
19+
static final BarcodeReader instance = new BarcodeReader();
20+
}
1821

1922
public static BarcodeReader getInstance() {
20-
if (instance == null) {
21-
synchronized (BarcodeReader.class) {
22-
if (instance == null) {
23-
instance = new BarcodeReader();
24-
}
25-
}
26-
}
27-
return instance;
23+
return InstanceHolder.instance;
2824
}
2925

3026
private BarcodeReader() {
@@ -33,8 +29,7 @@ private BarcodeReader() {
3329
}
3430

3531
public void setDetectModel(String detectorPrototxtPath, String detectorCaffeModelPath, String superResolutionPrototxtPath, String superResolutionCaffeModelPath) {
36-
NativeSdk.getInstance().setDetectModel(_nativePtr,
37-
detectorPrototxtPath, detectorCaffeModelPath,
32+
NativeSdk.getInstance().setDetectModel(_nativePtr, detectorPrototxtPath, detectorCaffeModelPath,
3833
superResolutionPrototxtPath, superResolutionCaffeModelPath);
3934
}
4035

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ private void init(Context context) {
5050
mPaint.setColor(mColor);
5151
}
5252

53+
@Override
54+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
55+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
56+
int size = MeasureSpec.makeMeasureSpec(mBigRadius * 2, MeasureSpec.EXACTLY);
57+
setMeasuredDimension(size, size);
58+
}
59+
5360
@Override
5461
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
5562
super.onLayout(changed, left, top, right, bottom);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.devilsen.czxing.view.scanview;
22

33
import android.content.Context;
4-
import android.graphics.Color;
54
import android.util.AttributeSet;
65
import android.view.View;
76

@@ -169,15 +168,16 @@ private void addPointView(CodeResult result) {
169168
view.setColor(mResultColor);
170169
}
171170

172-
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
173171
int xOffset = (width - mPointSize) / 2;
174172
int yOffset = (height - mPointSize) / 2;
175173

176174
xOffset = Math.max(xOffset, 0);
177175
yOffset = Math.max(yOffset, 0);
178176

177+
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
179178
params.leftMargin = x + xOffset;
180179
params.topMargin = y + yOffset;
180+
181181
addView(view, params);
182182
}
183183

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import android.app.Application;
44
import android.content.Context;
55

6-
import com.tencent.bugly.crashreport.CrashReport;
7-
86
/**
97
* desc :
108
* date : 2019-06-25
@@ -19,7 +17,7 @@ public class MyApplication extends Application {
1917
public void onCreate() {
2018
super.onCreate();
2119
instance = this;
22-
CrashReport.initCrashReport(getApplicationContext(), "378dbc83d2", true);
20+
// CrashReport.initCrashReport(getApplicationContext(), "378dbc83d2", true);
2321
}
2422

2523
public static Context getContext() {

0 commit comments

Comments
 (0)