How to use front camera to scan barcode in ipod

I use the rear camera to read barcode data ... and it scans perfectly. Now I want to use the front camera for this ... How can I do this? Where should I make a change? I used the ZBar barcode reader

my code is:

- (IBAction) scanButtonTapped { // ADD: present a barcode reader that scans from the camera feed ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; reader.supportedOrientationsMask = ZBarOrientationMaskAll; ZBarImageScanner *scanner = reader.scanner; // TODO: (optional) additional reader configuration here // EXAMPLE: disable rarely used I2/5 to improve performance [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0]; // present and release the controller [self presentModalViewController: reader animated: YES]; [reader release]; } - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info { // ADD: get the decode results id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol *symbol = nil; for(symbol in results) // EXAMPLE: just grab the first barcode break; // EXAMPLE: do something useful with the barcode data resultText.text = symbol.data; bid.text=symbol.data; // EXAMPLE: do something useful with the barcode image resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage]; // ADD: dismiss the controller (NB dismiss from the *reader*!) [reader dismissModalViewControllerAnimated: YES]; } 
+6
source share
1 answer

If I understand your question correctly, all you have to do is open the camera in Front mode instead of back mode, so write this inside the method when you call the collector for the first time:

  picker.cameraDevice=UIImagePickerControllerCameraDeviceFront; 

Hope this answers your question. If not, tell me.

+8
source

Source: https://habr.com/ru/post/908196/


All Articles