How to scan 1D Barcode in an image picked from device photos library in IOS?

I am not able to scan or read the 1D barcode present in the device photos library image, whereas the same I have achieved for QR code(2D barcode) image using the below code.

CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
if (detector)
{
    CIImage *img = [[CIImage alloc]initWithImage:image];
    NSArray* imgFeatures = [detector featuresInImage:img];
    NSString* contents;
    for (CIQRCodeFeature* imgFeature in imgFeatures)
    {
        DLog(@"decode %@ ",imgFeature.messageString);
        contents = imgFeature.messageString;
        if(contents){
            DLog(@"Success");
        }else{
            DLog(@"Failure");
        }
        
        return;
    }
}

As per my inference, the CIDetector has only the following types to detect from image

  • CIDetectorTypeFace
  • CIDetectorTypeRectange
  • CIDetectorTypeQRCode
  • CIDetectorTypeText

https://developer.apple.com/documentation/coreimage/cidetector/detector_types?language=objc

Please let me know how I can get my barcode images from the device photos library read/scanned.

Maybe you can utilize VNDetectBarcodesRequest.

You can find many sample codes on the web.

How to scan 1D Barcode in an image picked from device photos library in IOS?
 
 
Q