{"id":4534,"date":"2023-08-24T14:52:26","date_gmt":"2023-08-24T06:52:26","guid":{"rendered":"https:\/\/www.appbyme.cn\/myapp\/?p=4534"},"modified":"2023-08-24T14:52:26","modified_gmt":"2023-08-24T06:52:26","slug":"app%e5%bc%80%e5%8f%91%e4%ba%8c%e7%bb%b4%e7%a0%81%e6%89%ab%e6%8f%8f%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.appbyme.cn\/myapp\/2023\/4534\/","title":{"rendered":"app\u5f00\u53d1\u4e8c\u7ef4\u7801\u626b\u63cf\u600e\u4e48\u5b9e\u73b0\uff1f"},"content":{"rendered":"<p>\u4e8c\u7ef4\u7801\u626b\u63cf\u5df2\u7ecf\u6210\u4e3a\u4e86\u73b0\u4ee3\u4eba\u751f\u6d3b\u4e2d\u7684\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u626b\u63cf\u4e8c\u7ef4\u7801\u5b9e\u73b0\u591a\u79cd\u529f\u80fd\uff0c\u4f8b\u5982\u6253\u5f00\u7f51\u9875\u3001\u52a0\u597d\u53cb\u3001\u62e8\u6253\u7535\u8bdd\u7b49\u7b49\u3002\u4e8c\u7ef4\u7801\u626b\u63cf\u5728App\u5f00\u53d1\u4e2d\u975e\u5e38\u5e38\u89c1\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u4e8c\u7ef4\u7801\u626b\u63cf\u7684\u539f\u7406\u53ca\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<p>\u4e00\u3001\u539f\u7406<\/p>\n<p>\u4e8c\u7ef4\u7801\u751f\u6210\u548c\u626b\u63cf\u7684\u539f\u7406\u90fd\u662f\u57fa\u4e8e\u4e8c\u7ef4\u7801\u7684\u7f16\u7801\u548c\u89e3\u7801\u6280\u672f\uff0c\u8fd9\u91cc\u4ec5\u4ecb\u7ecd\u4e8c\u7ef4\u7801\u7684\u626b\u63cf\u539f\u7406\u3002\u4e8c\u7ef4\u7801\u626b\u63cf\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\uff0c\u7b2c\u4e00\u6b65\u662f\u627e\u5230\u4e8c\u7ef4\u7801\u4f4d\u7f6e\uff0c\u7b2c\u4e8c\u6b65\u662f\u89e3\u7801\u4e8c\u7ef4\u7801\u5185\u5bb9\u3002<\/p>\n<p>1\u3001\u627e\u5230\u4e8c\u7ef4\u7801\u4f4d\u7f6e<\/p>\n<p>\u4e8c\u7ef4\u7801\u7684\u5b9a\u4f4d\u6807\u5fd7\u533a\u57df\u5728\u4e8c\u7ef4\u7801\u56db\u4e2a\u89d2\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5bfb\u627e\u8fd9\u56db\u4e2a\u89d2\u7684\u4f4d\u7f6e\u6765\u786e\u5b9a\u4e8c\u7ef4\u7801\u7684\u4f4d\u7f6e\u3002\u5728\u5b9e\u73b0\u65f6\u53ef\u4ee5\u4f7f\u7528OpenCV\u7b49\u56fe\u50cf\u5904\u7406\u5e93\u6765\u8fdb\u884c\u5904\u7406\u5b9a\u4f4d\u6807\u5fd7\u533a\u57df\u3002<\/p>\n<p>2\u3001\u89e3\u7801\u4e8c\u7ef4\u7801\u5185\u5bb9<\/p>\n<p>\u5c06\u626b\u63cf\u5230\u7684\u4e8c\u7ef4\u7801\u56fe\u50cf\u7070\u5ea6\u5316\u540e\u4e8c\u503c\u5316\uff0c\u5373\u5c06\u7070\u5ea6\u503c\u4f4e\u4e8e\u67d0\u4e2a\u9608\u503c\u7684\u50cf\u7d20\u70b9\u8f6c\u6362\u4e3a\u9ed1\u8272\uff0c\u9ad8\u4e8e\u8be5\u9608\u503c\u7684\u50cf\u7d20\u70b9\u8f6c\u6362\u4e3a\u767d\u8272\u3002\u7136\u540e\u901a\u8fc7\u9ed1\u767d\u50cf\u7d20\u70b9\u7684\u6392\u5217\u7ec4\u5408\u627e\u51fa\u9ed1\u8272\u50cf\u7d20\u70b9\u7684\u4f4d\u7f6e\u548c\u5927\u5c0f\uff0c\u6700\u540e\u5229\u7528\u89e3\u7801\u7b97\u6cd5\u5c06\u9ed1\u767d\u50cf\u7d20\u70b9\u8f6c\u6362\u4e3a\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<p>\u4e8c\u3001\u5b9e\u73b0\u65b9\u6cd5<\/p>\n<p>\u5728iOS\u548cAndroid\u4e2d\uff0cApp\u5f00\u53d1\u8005\u90fd\u53ef\u4ee5\u5229\u7528\u7cfb\u7edf\u63d0\u4f9b\u7684\u76f8\u673a\u63a5\u53e3\u5b9e\u73b0\u4e8c\u7ef4\u7801\u7684\u626b\u63cf\u3002\u8fd9\u91cc\u5206\u522b\u4ecb\u7ecdiOS\u548cAndroid\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<p>1\u3001iOS\u5b9e\u73b0\u65b9\u6cd5<\/p>\n<p>\u4f7f\u7528iOS\u7cfb\u7edf\u81ea\u5e26\u7684\u4e8c\u7ef4\u7801\u626b\u63cf\u63a5\u53e3\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e8c\u7ef4\u7801\u7684\u626b\u63cf\u529f\u80fd\u3002\u9996\u5148\u9700\u8981\u5bfc\u5165AVFoundation\u6846\u67b6\u548cCoreGraphics\u6846\u67b6\uff0c\u7136\u540e\u521b\u5efaAVCaptureSession\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u8d1f\u8d23\u7ba1\u7406\u8f93\u5165\u8bbe\u5907\u3001\u8f93\u51fa\u8bbe\u5907\u548c\u6570\u636e\u6d41\u7684\u4f20\u8f93\u3002<\/p>\n<p>\u7136\u540e\u521b\u5efa\u4e00\u4e2aAVCaptureDevice\u5bf9\u8c61\u6765\u4ee3\u8868\u6444\u50cf\u5934\uff0c\u7136\u540e\u5c06\u8be5\u8bbe\u5907\u4f5c\u4e3aAVCaptureDeviceInput\u5bf9\u8c61\u7684\u8f93\u5165\uff0c\u4e4b\u540e\u521b\u5efa\u4e00\u4e2aAVCaptureMetadataOutput\u5bf9\u8c61\u6765\u83b7\u53d6\u626b\u63cf\u7ed3\u679c\u3002\u5c06AVCaptureMetadataOutput\u5bf9\u8c61\u7684\u7c7b\u578b\u8bbe\u7f6e\u4e3aAVMetadataObjectTypeQRCode\uff0c\u8fd9\u6837\u5c31\u53ea\u4f1a\u626b\u63cf\u4e8c\u7ef4\u7801\u3002\u540c\u65f6\u8bbe\u7f6e\u4ee3\u7406\uff0c\u5b9e\u73b0\u626b\u63cf\u7ed3\u679c\u7684\u56de\u8c03\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>\/\/ \u521b\u5efa AVCaptureSession \u5bf9\u8c61\u6765\u7ba1\u7406\u8f93\u5165\u8bbe\u5907\u548c \u8f93\u51fa\u8bbe\u5907<\/p>\n<p>AVCaptureSession *session = [[AVCaptureSession alloc] init];<\/p>\n<p>\/\/ \u83b7\u53d6 AVCaptureDevice \u5b9e\u4f8b\u6765\u8868\u793a\u6444\u50cf\u5934<\/p>\n<p>AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];<\/p>\n<p>\/\/ \u521b\u5efa AVCaptureDeviceInput \u5bf9\u8c61<\/p>\n<p>AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];<\/p>\n<p>\/\/ \u5c06 AVCaptureDeviceInput \u52a0\u5230\u4f1a\u8bdd\u4e2d<\/p>\n<p>[session addInput:input];<\/p>\n<p>\/\/ \u521b\u5efa AVCaptureMetadataOutput \u5bf9\u8c61\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u8f93\u51fa\u6d41<\/p>\n<p>AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];<\/p>\n<p>[session addOutput:output];<\/p>\n<p>\/\/ \u8bbe\u7f6e\u8f93\u51fa\u5bf9\u8c61\u7684\u4ee3\u7406\uff0c\u5e76\u5b9e\u73b0\u4ee3\u7406\u65b9\u6cd5<\/p>\n<p>[output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];<\/p>\n<p>\/\/ \u8bbe\u7f6e\u652f\u6301\u7684\u4e8c\u7ef4\u7801\u7c7b\u578b<\/p>\n<p>[output setMetadataObjectTypes:@[AVMetadataObjectType<a href=\"https:\/\/www.yimenapp.com\/\">APP<\/a>QRCode]];<\/p>\n<p>\/\/ \u521b\u5efa\u9884\u89c8\u56fe\u5c42\uff0c\u5e76\u8bbe\u7f6e\u4f1a\u8bdd<\/p>\n<p>AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];<\/p>\n<p>previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728\u5b9e\u73b0\u4ee3\u7406\u65b9\u6cd5\u4e2d\uff0c\u901a\u8fc7\u626b\u63cf\u7ed3\u679c\u5f97\u5230\u4e8c\u7ef4\u7801\u5185\u5bb9\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>&#8211; (void)ca<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/ag\/98\/sucai\/34.jpg\" \/><\/figure>\n<\/p>\n<p>ptureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection {<\/p>\n<p>    if (metadataObjects.count &gt; 0) {<\/p>\n<p>        AVMetadataMachineReadableCodeObject *metadataObject = metadataObjects.firstObject;<\/p>\n<p><a href=\"https:\/\/www.yimenapp.com\/\">APP\u5f00\u53d1<\/a><\/p>\n<p>        \/\/ \u83b7\u53d6\u626b\u63cf\u5230\u7684\u5b57\u7b26\u4e32\u5185\u5bb9<\/p>\n<p>        NSString *stringValue = metadataObject.stringValue;<\/p>\n<p>        \/\/ \u8c03\u7528\u4ee3\u7406\uff0c\u5c06\u626b\u63cf\u7ed3\u679c\u4f20\u7ed9\u8c03\u7528\u8005<\/p>\n<p>        if ([self.delegate respondsToSelector:@selector(scanResult:)]) {<\/p>\n<p>            [self.delegate scanResult:stringValue];<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>2\u3001Android\u5b9e\u73b0\u65b9\u6cd5<\/p>\n<p>\u5bf9\u4e8eAndroid\u5f00\u53d1\u8005\uff0c\u4e5f\u53ef\u4ee5\u5229\u7528\u7cfb\u7edf\u81ea\u5e26\u7684\u76f8\u673a\u63a5\u53e3\u5b9e\u73b0\u4e8c\u7ef4\u7801\u7684\u626b\u63cf\u529f\u80fd\u3002\u9996\u5148\u9700\u8981\u5728gradle\u914d\u7f6e\u4e2d\u6dfb\u52a0zxing\u5e93\u4f9d\u8d56\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>compile &#8216;com.google.zxing:core:3.2.1&#8217;<\/p>\n<p>compile &#8216;com.journeyapps:zxing-android-embedded:3.6.0&#8217;<\/p>\n<p>&#8220;`<\/p>\n<p>\u7136\u540e\u521b\u5efa\u4e00\u4e2aCaptureManager\u5bf9\u8c61\u6765\u7ba1\u7406\u76f8\u673a\u3001\u9884\u89c8\u548c\u89e3\u7801\u5668\u7b49\u5bf9\u8c61\uff0c\u4e4b\u540e\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4e8c\u7ef4\u7801\u7684\u626b\u63cf\u529f\u80fd\u4e86\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>\/\/ \u521b\u5efa CaptureManager \u5bf9\u8c61<\/p>\n<p>mCaptureManager = new CaptureManager(getActivity(), mBarcodeView);<\/p>\n<p>mCaptureManager.initializeFromIntent(getActivity().getIntent(), savedInstanceState);<\/p>\n<p>mCaptureManager.decode();<\/p>\n<p>&#8220;`<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0czxing\u5e93\u63d0\u4f9b\u4e86\u9ed8\u8ba4\u7684\u626b\u63cfUI\u754c\u9762\uff0c\u5982\u679c\u4e0d\u9700\u8981\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u626b\u63cf\u754c\u9762\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u9ed8\u8ba4\u6a21\u677f\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u4e8c\u7ef4\u7801\u626b\u63cf\u7684\u539f\u7406\u53ca\u5b9e\u73b0\u65b9\u6cd5\uff0c\u5728\u5b9e\u73b0\u65f6\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u6765\u9009\u62e9\u9002\u5408\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u5f00\u53d1\u4e2d\u63d0\u9ad8\u6548\u7387\uff0c\u5e76\u63d0\u4f9b\u66f4\u597d\u7684\u4f7f\u7528\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8c\u7ef4\u7801\u626b\u63cf\u5df2\u7ecf\u6210\u4e3a\u4e86\u73b0\u4ee3\u4eba\u751f\u6d3b\u4e2d\u7684\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u626b\u63cf\u4e8c\u7ef4\u7801\u5b9e\u73b0\u591a\u79cd\u529f\u80fd\uff0c\u4f8b\u5982\u6253\u5f00\u7f51\u9875\u3001\u52a0\u597d\u53cb\u3001\u62e8\u6253\u7535\u8bdd\u7b49\u7b49\u3002\u4e8c\u7ef4\u7801\u626b\u63cf\u5728App\u5f00\u53d1\u4e2d\u975e\u5e38\u5e38\u89c1\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u4e8c\u7ef4\u7801\u626b\u63cf\u7684\u539f\u7406\u53ca\u5b9e\u73b0\u65b9\u6cd5\u3002\u4e00\u3001\u539f\u7406\u4e8c\u7ef4<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[4746,2055,648,1531,7980],"topic":[],"class_list":["post-4534","post","type-post","status-publish","format-standard","hentry","category-appkaifa","tag-4746","tag-2055","tag-648","tag-exe","tag-app"],"_links":{"self":[{"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/posts\/4534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/comments?post=4534"}],"version-history":[{"count":0,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/posts\/4534\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/media?parent=4534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/categories?post=4534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/tags?post=4534"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.appbyme.cn\/myapp\/wp-json\/wp\/v2\/topic?post=4534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}