眼前多少难甘事,自古男儿当自强。这篇文章主要讲述Android | 瓒呯畝鍗曢泦鎴怘MS ML Kit瀹炵幇鏈€澶ц劯寰瑧鎶撴媿相关的知识,希望能为你提供帮助。
鏍囩锛?a href='http://www.mamicode.com/so/1/state' title='state'>state
鍐呭
clear
htm
sage
tle
鎿嶄綔
html
娴佺▼
鍓嶈█??濡傛灉澶у瀵笻MS ML Kit 浜鸿劯妫€娴嬪姛鑳芥湁鎵€浜嗚В锛岀浉淇″凡缁忓姩鎵嬭皟鐢ㄦ垜浠彁渚涚殑鎺ュ彛缂栧啓鑷繁鐨凙PP鍟︺€傜洰鍓嶅氨鏈夊皬浼欎即鍦ㄨ皟鐢ㄦ帴鍙g殑杩囩▼涓弽棣堬紝涓嶅お娓呮HMS ML Kit 鏂囨。涓殑MLMaxSizeFaceTransactor杩欎釜鎺ュ彛鐨勪娇鐢ㄦ柟娉曘€備负浜嗚澶у鏇村姞娣卞埢鐨勪簡瑙f垜浠殑鎺ュ彛锛屾柟渚垮湪鍦烘櫙涓娇鐢紝鍦ㄨ繖绡囨枃绔犱腑灏忕紪鍑嗗鎶涚爾寮曠帀锛屽ぇ瀹跺彲浠ユ墦寮€鎬濊矾锛屽澶氬皾璇曘€傚鏋滄湁灏忎紮浼存兂瑕佹繁鍏ョ殑浜嗚В鏇村姞鍏ㄩ潰鍏蜂綋鐨勫姛鑳斤紝璇峰ぇ瀹剁Щ姝?a href="https://developer.huawei.com/consumer/cn/hms/huawei-mlkit" rel="nofollow">https://developer.huawei.com/consumer/cn/hms/huawei-mlkit銆?/p>鍦烘櫙??鐩镐俊澶у閮芥湁鍦ㄤ簲涓€銆佸崄涓€鍑哄幓娓哥帺鐨勭粡鍘嗭紝鏄笉鏄兘鏄繖鏍风殑people mountain people sea.
文章图片
??濂戒笉瀹规槗鎵句釜浜哄皯鐨勫湴鏂癸紝缁撴灉鎷嶅嚭鏉ョ殑鐓х墖鏄繖鏍风殑銆?/p>
文章图片
??杩欐牱鐨?/p>
文章图片
??杩樻湁杩欐牱鐨?/p>
文章图片
??涓嶇湅涓嶇煡閬擄紝鍘熸潵鎴戠殑闈㈤儴琛ㄦ儏杩欎箞涓板瘜銆傘€傛槸涓嶆槸寰堝績绱紵姣忔鎯宠鍙戜釜鍑哄幓娴殑鏈嬪弸鍦堬紝閮借鍦ㄧ櫧澶╂媿鐨勬垚鐧句笂鍗冨紶绫讳技娆剧殑鐓х墖閲岋紝鑺变笂涓€灏忔椂鎵嶈兘鎵惧埌涓€寮犺兘鐪嬬殑鐓х墖銆傘€傘€?/p>
文章图片
??涓轰簡瑙e喅绫讳技闂锛孒MS ML Kit 鎻愪緵浜嗚拷韪瘑鍒敾闈腑鏈€澶ц劯鐨勬帴鍙o紝鑳藉璇嗗埆鍥惧儚涓殑鏈€澶ц劯锛屾柟渚垮璺熻釜鍥惧儚涓殑鈥濋噸鐐圭洰鏍団€滃仛鐩稿叧鎿嶄綔鍜屽鐞嗐€傛湰鏂囦腑灏辩畝鍗曠殑璋冪敤MLMaxSizeFaceTransactor杩欎釜鎺ュ彛锛屽疄鐜版渶澶ц劯寰瑧鎶撴媿鐨勫姛鑳姐€?/p>寮€鍙戝墠鍑嗗 android studio 瀹夎??寰堢畝鍗曪紝涓嬭浇瀹夎鍗冲彲銆傚叿浣撲笅杞介摼鎺ワ細
??Android studio 瀹樼綉涓嬭浇閾炬帴锛?a href="https://developer.android.com/studio" rel="nofollow">https://developer.android.com/studio
??Android studio瀹夎娴佺▼鍙傝€冮摼鎺ワ細https://www.cnblogs.com/xiadewang/p/7820377.html
鍦ㄩ」鐩骇gradle閲屾坊鍔犲崕涓簃aven浠?/h2>??鎵撳紑AndroidStudio椤圭洰绾uild.gradle鏂囦欢
文章图片
??澧為噺娣诲姞濡備笅maven鍦板潃锛?/p>
buildscript {
{
maven {url 鈥榟ttp://developer.huawei.com/repo/鈥榼
}
}
allprojects {
repositories {
maven { url 鈥榟ttp://developer.huawei.com/repo/鈥榼
}
}
鍦ㄥ簲鐢ㄧ骇鐨刡uild.gradle閲岄潰鍔犱笂SDK渚濊禆
文章图片
鍦ˋndroidManifest.xml鏂囦欢閲岄潰澧為噺娣诲姞妯″瀷鑷姩涓嬭浇【Android | 瓒呯畝鍗曢泦鎴怘MS ML Kit瀹炵幇鏈€澶ц劯寰瑧鎶撴媿】??瑕佷娇搴旂敤绋嬪簭鑳藉鍦ㄧ敤鎴蜂粠鍗庝负搴旂敤甯傚満瀹夎鎮ㄧ殑搴旂敤绋嬪簭鍚庯紝鑷姩灏嗘渶鏂扮殑鏈哄櫒瀛︿範妯″瀷鏇存柊鍒扮敤鎴疯澶囷紝璇峰皢浠ヤ笅璇彞娣诲姞鍒拌搴旂敤绋嬪簭鐨凙ndroidManifest.xml鏂囦欢涓細
<
manifest
...
<
meta-data
android:name="com.huawei.hms.ml.DEPENDENCY"
android:value= "https://www.songbingjia.com/android/face"/>
...
<
/manifest>
鍦ˋndroidManifest.xml鏂囦欢閲岄潰鐢宠鐩告満銆佽闂綉缁滃拰瀛樺偍鏉冮檺
<
!--鐩告満鏉冮檺-->
<
uses-feature android:name="android.hardware.camera" />
<
uses-permission android:name="android.permission.CAMERA" />
<
!--鍐欐潈闄?->
<
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
浠g爜寮€鍙戝叧閿楠?/h1> 鍔ㄦ€佹潈闄愮敵璇?/h2>
@Override
public void onCreate(Bundle savedInstanceState) {
鈥︹€?if (!allPermissionsGranted()) {
getRuntimePermissions();
}
鍒涘缓浜鸿劯璇嗗埆妫€娴嬪櫒??鍙互閫氳繃浜鸿劯璇嗗埆妫€娴嬮厤缃櫒鈥淢LFaceAnalyzerSetting鈥濆垱寤轰汉鑴歌瘑鍒娴嬪櫒銆?/p>
MLFaceAnalyzerSetting setting =
new MLFaceAnalyzerSetting.Factory()
.setFeatureType(MLFaceAnalyzerSetting.TYPE_FEATURES)
.setKeyPointType(MLFaceAnalyzerSetting.TYPE_UNSUPPORT_KEYPOINTS)
.setMinFaceProportion(0.1f)
.setTracingAllowed(true)
.create();
??閫氳繃MLMaxSizeFaceTransactor.Creator鍒涘缓鈥淢LMaxSizeFaceTransactor鈥濆璞$敤浜庡鐞嗘娴嬪埌鐨勬渶澶ц劯锛屽叾涓璷bjectCreateCallback()鏂规硶鏄湪妫€娴嬪埌瀵硅薄鐨勬椂鍊欒皟鐢ㄧ殑锛宱bjectUpdateCallback()鏂规硶鏄湪瀵硅薄鏇存柊浜嗙殑鏃跺€欒皟鐢ㄧ殑锛屽湪鏂规硶閲岄€氳繃Overlay鍦ㄨ瘑鍒埌鐨勬渶澶т汉鑴镐笂鏍囪浜嗕竴涓柟鍧楋紝骞堕€氳繃妫€娴嬬粨鏋滆幏鍙朚LFaceEmotion鏉ヨ瘑鍒井绗戣〃鎯呰Е鍙戞媿鐓с€?/p>
MLMaxSizeFaceTransactor transactor = new MLMaxSizeFaceTransactor.Creator(analyzer, new MLResultTrailer<
MLFace>
() {
@Override
public void objectCreateCallback(int itemId, MLFace obj) {
LiveFaceAnalyseActivity.this.overlay.clear();
if (obj == null) {
return;
}
LocalFaceGraphic faceGraphic =
new LocalFaceGraphic(LiveFaceAnalyseActivity.this.overlay, obj, LiveFaceAnalyseActivity.this);
LiveFaceAnalyseActivity.this.overlay.addGraphic(faceGraphic);
MLFaceEmotion emotion = obj.getEmotions();
if (emotion.getSmilingProbability() >
smilingPossibility) {
safeToTakePicture = false;
mHandler.sendEmptyMessage(TAKE_PHOTO);
}
}@Override
public void objectUpdateCallback(MLAnalyzer.Result<
MLFace>
var1, MLFace obj) {
LiveFaceAnalyseActivity.this.overlay.clear();
if (obj == null) {
return;
}
LocalFaceGraphic faceGraphic =
new LocalFaceGraphic(LiveFaceAnalyseActivity.this.overlay, obj, LiveFaceAnalyseActivity.this);
LiveFaceAnalyseActivity.this.overlay.addGraphic(faceGraphic);
MLFaceEmotion emotion = obj.getEmotions();
if (emotion.getSmilingProbability() >
smilingPossibility &
&
safeToTakePicture) {
safeToTakePicture = false;
mHandler.sendEmptyMessage(TAKE_PHOTO);
}
}@Override
public void lostCallback(MLAnalyzer.Result<
MLFace>
result) {
LiveFaceAnalyseActivity.this.overlay.clear();
}@Override
public void completeCallback() {
LiveFaceAnalyseActivity.this.overlay.clear();
}
}).create();
this.analyzer.setTransactor(transactor);
閫氳繃LensEngine.Creator鍒涘缓LensEngine瀹炰緥杩涜瑙嗛娴佺殑浜鸿劯妫€娴嬫娴?/h2>
this.mLensEngine = new LensEngine.Creator(context, this.analyzer).setLensType(this.lensType)
.applyDisplayDimension(640, 480)
.applyFps(25.0f)
.enableAutomaticFocus(true)
.create();
鍚姩鐩告満棰勮杩涜浜鸿劯妫€娴?/h2>
this.mPreview.start(this.mLensEngine, this.overlay);
寰€鏈熼摼鎺ワ細蹇湇鍔″父瑙乀OP3瀹℃牳闆峰尯锛屽啀涓嶈繃瀹″氨瑕佸穿婧冨暒锛?/a>
鍐呭鏉ユ簮锛?a href="https://developer.huawei.com/consumer/cn/forum/topicview?tid=0201256372685820478& fid=18" rel="nofollow">https://developer.huawei.com/consumer/cn/forum/topicview?tid=0201256372685820478&fid=18
鍘熶綔鑰咃細littlewhite
推荐阅读
- ASP.NET Core 3.1--中间件源码解读--RequestDelegate--ApplicationBuilder.Use
- appium +夜神模拟器 操作元素
- 手机上写歌词的软件,原创歌词创作软件app下载,有吗()
- win8系统好用吗,本文教您怎样运用U盘重装win8系统
- 硬盘分区工具,本文教您怎样给电脑硬盘分区
- u盘打开不了,本文教您u盘打开不了怎样修好
- windows7系统安装,本文教您win7系统怎样运用U盘安装
- u盘打开盘制作,本文教您如何迅速制作一个PE系统
- usb无法识别怎样办,本文教您处理usb无法识别