Difference between revisions of "Barcode Scanner Code"

From ESE205 Wiki
Jump to navigation Jump to search
m (Ethanshry moved page Writing Code for a Barcode Scanner to Barcode Scanner Code: Fall 2018 Wiki Reworks)
 
(3 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
[[File:barcode.png|308px|160px|thumbnail|Our barcode scanner for the Grocery Guru app]]
 
[[File:barcode.png|308px|160px|thumbnail|Our barcode scanner for the Grocery Guru app]]
  
In order to scan a barcode in an application, you must use an AV Foundation to implement into your code.
+
In order to scan a barcode in an application, you must implement an AV Foundation into your code.
  
 
== Steps ==
 
== Steps ==
  
The following steps are the main components of coding a barcode scanner:
+
The following steps explain the main components of coding a barcode scanner:
# Create a new View Controller in Xcode to have the barcode scanner on a separate page in the app.
+
# Create a new View Controller in Xcode so that the barcode scanner is contained on a separate page in your application.
# Import the AV Foundation at the top of your code so that you can use barcodes that are already provided instead of trying to individually code barcode images and UPC numbers.
+
# Import the AV Foundation at the top of your code in order to allow your personal usage of barcodes that are already provided. Therefore, you do not need to individually code barcode images and UPC numbers.
 
# Create an object that captures low quality images of a barcode.
 
# Create an object that captures low quality images of a barcode.
 
# Set the type of barcode you want to scan (EAN-13, UPC, Code 128, etc.)
 
# Set the type of barcode you want to scan (EAN-13, UPC, Code 128, etc.)
# Stop running the scan if a barcode is found.
+
# If a barcode is found, quit running the scan
# Encode the image of the barcode into a UPC number, as a string in this case.
+
# Encode the image of the barcode into a UPC number. In this case, you will do so as a string.
# Let the user know that a barcode has been found with a notification.
+
# Let the user know a barcode has been found with a personalized notification.
# Send the UPC to the API to find the item that is connected to the barcode.
+
# Send the UPC to the API to find the item that is connected with this particular barcode.
  
For a more detailed description and code for the barcode, visit https://github.com/adelzell/GroceryGuru/blob/master/BarcodeScanner/BarcodeReaderViewController.swift. This contains the View Controller for the barcode scanner of our application.
+
For a more detailed description as well as the code we used in our implementation, visit https://github.com/adelzell/GroceryGuru/blob/master/BarcodeScanner/BarcodeReaderViewController.swift. This contains the View Controller used for the barcode scanner of our application.
  
 
[[Category:HowTos]]
 
[[Category:HowTos]]
 +
[[Category:Programming]]

Latest revision as of 22:33, 18 August 2018

Grocery Guru

Description

Our barcode scanner for the Grocery Guru app

In order to scan a barcode in an application, you must implement an AV Foundation into your code.

Steps

The following steps explain the main components of coding a barcode scanner:

  1. Create a new View Controller in Xcode so that the barcode scanner is contained on a separate page in your application.
  2. Import the AV Foundation at the top of your code in order to allow your personal usage of barcodes that are already provided. Therefore, you do not need to individually code barcode images and UPC numbers.
  3. Create an object that captures low quality images of a barcode.
  4. Set the type of barcode you want to scan (EAN-13, UPC, Code 128, etc.)
  5. If a barcode is found, quit running the scan
  6. Encode the image of the barcode into a UPC number. In this case, you will do so as a string.
  7. Let the user know a barcode has been found with a personalized notification.
  8. Send the UPC to the API to find the item that is connected with this particular barcode.

For a more detailed description as well as the code we used in our implementation, visit https://github.com/adelzell/GroceryGuru/blob/master/BarcodeScanner/BarcodeReaderViewController.swift. This contains the View Controller used for the barcode scanner of our application.