0

PDF417バーコードを検出するために、GoogleのMLKit Barcode Detectorとともに迅速でシンプルなAVCaptureSessionを使用しようとしています。ただし、終了行のない切り詰められた PDF417 バーコードは検出されません。画像レイヤーを追加してバーコードの最後にこれを追加できる迅速なライブラリはありますか? 私は現在、バーコードの角も持っています:

func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {

    let barcodeScanner = BarcodeScanner.barcodeScanner(options: barcodeOptions)

   // print("Capturing", Date())

    let image = VisionImage(buffer: sampleBuffer)
    image.orientation = imageOrientation(
      deviceOrientation: UIDevice.current.orientation,
      cameraPosition: AVCaptureDevice.Position.front)

    guard let barcodes = try? barcodeScanner.results(in: image) else {return}

    for barcode in barcodes {
     let corners = barcode.cornerPoints

    print(corners)

      //let displayValue = barcode.displayValue
      let rawValue = barcode.rawValue

コーナー: ここに画像の説明を入力

切り捨てられた:

ここに画像の説明を入力

非切り捨て

切り捨てられていない PDF417

4

1 に答える 1

1

1 つのオプションは、sampleBuffer を にロードし、CGContextその上に描画することです。

この回答で説明されている方法を使用してCMSampleBuffer、を に変換できます。CGImage

その後、CGImage を CGContext に描画できます。切り捨てられたコードの角の座標を使用して、左上隅と右上隅、および左下隅と右下隅がまたがる線を延長することにより、停止パターンの角を計算できます。

CGContext線とパスを描画するためのメソッドがあります。

では、、、、などのCGContextメソッドを使用できます。move(to: point)addLine(to: point)closePath()setFillColor(color)strokePath()fillPath()

すべての描画操作が完了したら、 を使用makeImage()して出力イメージを取得します。

その後、UIImage からビジョン イメージを作成できます。これは、 を使用して取得できますUIImage(cgImage: contextOutput)

于 2020-06-08T22:16:25.843 に答える