Identify Parts Under Inspection
In addition to making measurements after you set regions of inspection, you also can identify parts using classification, optical character recognition (OCR), and barcode reading.
Classifying Samples
Use classification to identify an unknown object by comparing a set of its significant features to a set of features that conceptually represent classes of known objects. Typical applications involving classification include the following:
- Sorting—Sorts objects of varied shapes. For example, sorting different mechanical parts on a conveyor belt into different bins.
- Inspection—Inspects objects by assigning each object an identification score and then rejecting objects that do not closely match members of the training set.
Before you classify objects, you must train the Classifier Session with samples of the objects using the NI Classification Training Interface. Select Start»All Programs»National Instruments»Vision»Classification Training to launch the NI Classification Training Interface.
After you have trained samples of the objects you want to classify, use the following VIs to classify the objects:
- In the initialization part the of code, use the IMAQ Read Classifier File VI to read in a Classifier that you created using the NI Classification Training Interface.
- Use the IMAQ Classify VI to classify the object inside the ROI of the image under inspection into one of the classes you created using the NI Classification Training Interface.
- Use the IMAQ Dispose Classifier VI to free the resources that the Classifier Session used.
The following figure shows LabVIEW pseudocode for a typical classification VI.
1 Read a Classifier File | 4 Classify the Sample | 7 Class |
2 Acquire and Preprocess the Image | 5 Dispose of the Classifier Session | 8 Stop |
3 Locate the Sample to Classify | 6 Path to the Trained Classifier File |
Reading Characters
Use OCR to read text and/or characters in an image. Typical uses for OCR in an inspection application include identifying or classifying components.
Before you read text and/or characters in an image, you must train the OCR Session with samples of the characters using the NI OCR Training Interface. Select Start»All Programs»National Instruments»Vision»OCR Training to launch the NI OCR Training Interface.
After you have trained samples of the characters you want to read, use the following VIs to read the characters:
- In the initialization part the of code, use the IMAQ OCR Read Character Set File VI to read in a session that you created using the NI OCR Training Interface.
- Use the IMAQ OCR Read Text 3 VI to read the characters inside the ROI of the image under inspection.
- Use the IMAQ OCR Dispose Session VI to free the resources that the OCR Session used.
Reading Barcodes
Use barcode reading VIs to read values encoded into 1D barcodes, Data Matrix codes, QR codes, and PDF417 codes.
Reading 1D Barcodes
Use the IMAQ Read Barcode VI to read values encoded in a 1D barcode. Locate the barcode in the image using one of the techniques described in the Locate Objects to Inspect and Set Search Areas sections. Then pass the ROI Descriptor of the location into the IMAQ Read Barcode VI. Specify the type of 1D barcode in the application using the Barcode Type control.
NI Vision supports the following 1D barcode types: Codabar, Code 39, Code 93, Code 128, EAN 8, EAN 13, Interleaved 2 of 5, MSI, UPCA, Pharmacode, and RSS Limited.
Reading Data Matrix codes
Use the IMAQ Read Data Matrix Barcode 2 VI to read values encoded in a Data Matrix code. The VI can automatically determine the appropriate search options for your application. However, you can improve the performance of the application by specifying control values specific to your application.
The IMAQ Read Data Matrix Barcode 2 VI can automatically locate the Data Matrix code in an image. However, you can improve the inspection performance by locating the barcode, using one of the techniques described in the Locate Objects to Inspect section, and then passing in ROI Descriptors of the locations into the IMAQ Read Data Matrix Barcode 2 VI.
Reading QR Codes
Use the IMAQ Read QR Code VI to read values encoded in a QR or micro-QR code. The VI can automatically determine the appropriate search options for your application. However, you can improve the performance of the application by specifying control values specific to your application.
The IMAQ Read QR Code VI can automatically locate the QR code in the image. However, you can improve the inspection performance by locating the barcode, using one of the techniques described in the Locate Objects to Inspect section, and then passing in ROI Descriptors of the locations into the IMAQ Read QR Code VI.
Reading PDF417 codes
Use the IMAQ Read PDF417 Barcode VI to read values encoded in a PDF417 code.
the IMAQ Read PDF417 Barcode VI can automatically locate one or multiple PDF417 codes in an image. However, you can improve the inspection performance by locating the codes, using one of the techniques described in the Locate Objects to Inspect section, and then passing in ROI Descriptors of the locations into the IMAQ Read PDF417 Barcode VI.
Tip If you need to read only one PDF417 code per image, set Search Mode to Single Barcode, Conservative to increase the speed of the VI. |