Hacker News story: 16-HarmonyOS5-VisionKit-VisionImageAnalyzer-Case

16-HarmonyOS5-VisionKit-VisionImageAnalyzer-Case
Case Study of Vision Image Analyzer in VisionKit on HarmonyOS 5.0 Abstract This article introduces how to use visionImageAnalyzer from @kit.VisionKit to implement image text analysis in HarmonyOS 5.0. By creating the VisionKitVisionImageAnalyzer component, users can perform text analysis on specified images and display all the text and the selected text. import { visionImageAnalyzer } from '@kit.VisionKit' @Entry @Component struct VisionKitVisionImageAnalyzer { aiController = new visionImageAnalyzer.VisionImageAnalyzerController() @State text: string = '' @State selectedText: string = '' aboutToAppear(): void { this.aiController.on('textAnalysis', (text) => { this.text = text }) this.aiController.on('selectedTextChange', (selectedText) => { this.selectedText = selectedText }) } build() { Column({ space: 15 }) { Image(' `https://inews.gtimg.com/om_ls/O3W2Lv10CTyLNHOjw4k_Co1Kkb2-c42GHWvifzD-ka5OYAA_294195/0` ', { types: [ImageAnalyzerType.TEXT], aiController: this.aiController }) .enableAnalyzer(true) .objectFit(ImageFit.Contain) .width(300) .height(300) Text('All text: ' + this.text) Text('Selected text: ' + this.selectedText) } .alignItems(HorizontalAlign.Start) .padding(15) .height('100%') .width('100%') } } 0 comments on Hacker News.
Case Study of Vision Image Analyzer in VisionKit on HarmonyOS 5.0 Abstract This article introduces how to use visionImageAnalyzer from @kit.VisionKit to implement image text analysis in HarmonyOS 5.0. By creating the VisionKitVisionImageAnalyzer component, users can perform text analysis on specified images and display all the text and the selected text. import { visionImageAnalyzer } from '@kit.VisionKit' @Entry @Component struct VisionKitVisionImageAnalyzer { aiController = new visionImageAnalyzer.VisionImageAnalyzerController() @State text: string = '' @State selectedText: string = '' aboutToAppear(): void { this.aiController.on('textAnalysis', (text) => { this.text = text }) this.aiController.on('selectedTextChange', (selectedText) => { this.selectedText = selectedText }) } build() { Column({ space: 15 }) { Image(' `https://inews.gtimg.com/om_ls/O3W2Lv10CTyLNHOjw4k_Co1Kkb2-c42GHWvifzD-ka5OYAA_294195/0` ', { types: [ImageAnalyzerType.TEXT], aiController: this.aiController }) .enableAnalyzer(true) .objectFit(ImageFit.Contain) .width(300) .height(300) Text('All text: ' + this.text) Text('Selected text: ' + this.selectedText) } .alignItems(HorizontalAlign.Start) .padding(15) .height('100%') .width('100%') } }

Hacker News story: 16-HarmonyOS5-VisionKit-VisionImageAnalyzer-Case Hacker News story: 16-HarmonyOS5-VisionKit-VisionImageAnalyzer-Case Reviewed by Tha Kur on June 27, 2025 Rating: 5

No comments:

Powered by Blogger.