AlphaWallet / alpha-wallet-ios

An advanced Ethereum/EVM mobile wallet
https://www.alphawallet.com
MIT License
599 stars 372 forks source link

import Foundation #7114

Closed hboon closed 5 months ago

hboon commented 5 months ago

import SVGKit import AppKit import Vision

func convertSVGToImage(svgURL: URL) -> NSImage? { guard let svgImage = SVGKImage(contentsOf: svgURL) else { print("Failed to load SVG file.") return nil }

return svgImage.nsImage

}

func processImageWithVision(_ image: NSImage) { guard let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { print("Failed to convert NSImage to CGImage.") return }

let requestHandler = VNImageRequestHandler(cgImage: cgImage, options: [:])
let request = VNRecognizeTextRequest { (request, error) in
    guard let observations = request.results as? [VNRecognizedTextObservation] else {
        print("Unexpected result type from VNRecognizeTextRequest.")
        return
    }

    for observation in observations {
        guard let topCandidate = observation.topCandidates(1).first else { continue }
        print("Recognized text: \(topCandidate.string)")
    }
}

do {
    try requestHandler.perform([request])
} catch {
    print("Failed to perform text recognition: \(error)")
}

}

func foo() { // Example usage: if let svgURL = URL(fileURLWithPath: "/Users/hboon/Documents/workspace/playground/remarkable-rmc-test/test.svg") let rasterImage = convertSVGToImage(svgURL: svgURL) { processImageWithVision(rasterImage) } }

janviaroraa commented 5 months ago

Can you please specify the title in more detailed form? And what will the AC (if needs to be changed) and expection here? I'd like to work on this.

hboon commented 5 months ago

I'm sorry, I accidentally created this with a runaway script.