-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
170 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.barcode.BarcodeCameraScanActivity | ||
|
||
/** | ||
* 条形码/二维码扫描示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class BarcodeScanningActivity : BarcodeCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.barcode.QRCodeCameraScanActivity | ||
|
||
/** | ||
* 扫描多个二维码示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class MultipleQRCodeScanningActivity : QRCodeCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import com.king.mlkit.vision.app.R | |
import com.king.mlkit.vision.barcode.QRCodeCameraScanActivity | ||
|
||
/** | ||
* 扫描二维码示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class QRCodeScanningActivity : QRCodeCameraScanActivity() { | ||
|
@@ -67,13 +68,8 @@ class QRCodeScanningActivity : QRCodeCameraScanActivity() { | |
//取预览当前帧图片并显示,为结果点提供参照 | ||
ivResult.setImageBitmap(previewView.bitmap) | ||
val points = ArrayList<Point>() | ||
val frameMetadata = result.frameMetadata | ||
var width = frameMetadata.width | ||
var height = frameMetadata.height | ||
if(frameMetadata.rotation == 90 || frameMetadata.rotation == 270) { | ||
width = frameMetadata.height | ||
height = frameMetadata.width | ||
} | ||
var width = result.bitmapWidth | ||
var height = result.bitmapHeight | ||
for (barcode in results) { | ||
barcode.boundingBox?.let { box -> | ||
//将实际的结果中心点坐标转换成界面预览的坐标 | ||
|
@@ -115,5 +111,4 @@ class QRCodeScanningActivity : QRCodeCameraScanActivity() { | |
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.face.FaceCameraScanActivity | ||
|
||
/** | ||
* 人脸检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
open class FaceDetectionActivity : FaceCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.facemesh.FaceMeshCameraScanActivity | ||
|
||
/** | ||
* 人脸网格检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
open class FaceMeshDetectionActivity : FaceMeshCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import com.king.camera.scan.analyze.Analyzer | |
import com.king.mlkit.vision.face.analyze.FaceDetectionAnalyzer | ||
|
||
/** | ||
* 多个人脸检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class MultipleFaceDetectionActivity : FaceDetectionActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import com.king.camera.scan.AnalyzeResult | |
import com.king.mlkit.vision.image.ImageCameraScanActivity | ||
|
||
/** | ||
* 图像标签示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class ImageLabelingActivity : ImageCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import com.king.camera.scan.analyze.Analyzer | |
import com.king.mlkit.vision.`object`.analyze.ObjectDetectionAnalyzer | ||
|
||
/** | ||
* 多个对象检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class MultipleObjectDetectionActivity : ObjectDetectionActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.`object`.ObjectCameraScanActivity | ||
|
||
/** | ||
* 对象检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
open class ObjectDetectionActivity : ObjectCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.pose.accurate.AccuratePoseCameraScanActivity | ||
|
||
/** | ||
* 姿势检测(精确版)示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class AccuratePoseDetectionActivity : AccuratePoseCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import com.king.mlkit.vision.app.drawRect | |
import com.king.mlkit.vision.pose.PoseCameraScanActivity | ||
|
||
/** | ||
* 姿势检测示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class PoseDetectionActivity : PoseCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import com.king.mlkit.vision.app.R | |
import com.king.mlkit.vision.segmentation.SegmentationCameraScanActivity | ||
|
||
/** | ||
* 自拍分割示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class SelfieSegmentationActivity : SegmentationCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import com.king.mlkit.vision.text.TextCameraScanActivity | |
import com.king.mlkit.vision.text.analyze.TextRecognitionAnalyzer | ||
|
||
/** | ||
* 文字识别示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
class TextRecognitionActivity : TextCameraScanActivity() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jdk: | ||
- openjdk11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,13 @@ | |
*/ | ||
package com.king.mlkit.vision.barcode; | ||
|
||
import android.view.View; | ||
|
||
import com.google.mlkit.vision.barcode.common.Barcode; | ||
import com.king.camera.scan.BaseCameraScanFragment; | ||
import com.king.camera.scan.analyze.Analyzer; | ||
import com.king.mlkit.vision.barcode.analyze.BarcodeScanningAnalyzer; | ||
import com.king.view.viewfinderview.ViewfinderView; | ||
|
||
import java.util.List; | ||
|
||
|
@@ -32,6 +35,18 @@ | |
* @author <a href="mailto:[email protected]">Jenly</a> | ||
*/ | ||
public abstract class BarcodeCameraScanFragment extends BaseCameraScanFragment<List<Barcode>> { | ||
|
||
protected ViewfinderView viewfinderView; | ||
|
||
@Override | ||
public void initUI() { | ||
int viewfinderViewId = getViewfinderViewId(); | ||
if (viewfinderViewId != View.NO_ID && viewfinderViewId != 0) { | ||
viewfinderView = getRootView().findViewById(viewfinderViewId); | ||
} | ||
super.initUI(); | ||
} | ||
|
||
/** | ||
* 创建分析器,默认分析所有条码格式 | ||
* | ||
|
@@ -43,4 +58,24 @@ public Analyzer<List<Barcode>> createAnalyzer() { | |
return new BarcodeScanningAnalyzer(Barcode.FORMAT_ALL_FORMATS); | ||
} | ||
|
||
/** | ||
* 布局ID;通过覆写此方法可以自定义布局 | ||
* | ||
* @return 布局ID | ||
*/ | ||
@Override | ||
public int getLayoutId() { | ||
return R.layout.ml_barcode_camera_scan; | ||
} | ||
|
||
/** | ||
* {@link #viewfinderView} 的 ID | ||
* | ||
* @return 默认返回{@code R.id.viewfinderView}, 如果不需要扫码框可以返回{@link View#NO_ID} | ||
*/ | ||
|
||
public int getViewfinderViewId() { | ||
return R.id.viewfinderView; | ||
} | ||
|
||
} |
Oops, something went wrong.