You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS16下Vision框架无法识别GS1条码中的GS特殊字符求助

iOS16下Vision框架扫描GS1条码丢失GS分隔符问题

我们使用Vision框架扫描GS1条码时,发现iOS16版本存在异常:框架无法识别条码中的GS分组分隔符(ASCII 29),但在iOS15.6及更低版本中无此问题。已上传GS1条码示例图。

  • 扫描预期结果:{GS}10BF50001A{GS}21003032{GS}1122012722VD020
  • iOS16实际扫描结果:10BF50001A210030321122012722VD020

代码未做任何修改,怀疑是iOS16引入的Bug。以下是使用Vision框架的核心代码:

func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
    guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else {
        return
    }

    let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .right)

    do {
        try imageRequestHandler.perform([detectBarcodeRequest])
    } catch {
        logger.error(tag: TAG, "barcode error: \(error)")
    }
}

private lazy var detectBarcodeRequest = VNDetectBarcodesRequest { [weak self] request, error in
    guard error == nil else {
        self?.logger.error(tag: self?.TAG, "barcode error: \(error)")
        return
    }
    self?.processVNRequest(request)
}

private func processVNRequest(_ request: VNRequest) {
    guard let barcodes = request.results else {
        return
    }

    for barcode in barcodes {
        guard let potentialBarcode = barcode as? VNBarcodeObservation else {
            return
        }

        guard let payload = potentialBarcode.payloadStringValue else {
            return
        }

        prepareToNotifyDetectionEvent(payload)
    }
}

恳请协助排查该问题。

内容的提问来源于stack exchange,提问作者AresProductions

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 05:15:39