Identify Parts Under Inspection

NI Vision 2019 for LabVIEW Help

Edition Date: March 2019

Part Number: 370281AG-01

»View Product Info
Vision Developoment Module 2019 Help
Vision Development Module 2020 Help

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 unknown samples based on their color or shape by comparing a set significant characteristics to a set of characteristics that conceptually represent classes of known samples.

Color Classification

Typical applications involving color classification include the following:

  • Sorting—For example, sorting bottles on a conveyor belt into different bins based on the color of the liquid in the bottle.
  • Inspection—For example, using the color of fruit to determine if it is ripe.
  • Identification—For example, using the color code painted on a part to determine the characteristics of the part.

Before you classify colors, you must create a classifier file with samples of the colors using the NI Color Classification Training Interface. Go to Start»All Programs»National Instruments»Color Classification Training to launch the NI Color Classification Training Interface. Refer to the NI Color Classification Training Interface Help for more information about the NI Color Classification Training Interface.

Particle Classification

Typical applications involving color 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 create a classifier file with samples of the objects using the NI Particle Classification Training Interface. Go to Start»All Programs»National Instruments»Particle Classification Training to launch the NI Particle Classification Training Interface. Refer to the NI Particle Classification Training Interface Help for more information about the NI Particle Classification Training Interface.

Performing Classification

After you have trained samples of the objects or colors that you want to classify, use the following VIs to perform classification:

  1. 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 Particle Classification Training Interface or the NI Color Classification Training Interface.
  2. Use the IMAQ Classify VI to classify the object inside the ROI of the image under inspection into one of the classes defined in the Classifier.
  3. 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:

  1. 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.
  2. Use the IMAQ OCR Read Text 3 VI to read the characters inside the ROI of the image under inspection.
  3. 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 2 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 2 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, GS1 DataBar Limited (previously referred to as RSS-14 Limited), and Pharmacode.

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 locate a PDF417 code in the image and read encoded values.

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.

Color Segmentation

Color segmentation partitions an image into different regions based on the color of the part in that region. Typical applications for color segmentation include the following:

  1. Counting the number of objects of a particular color composition that are present in an image. For example, segmenting different colored hand sanitizer bottles and inspecting the filling level.
  2. Determining the area as a percentage occupied by a particular color within a part and using that information to determine the overall quality of the part. For example, segmenting a potato chip into different color regions to identify the percentage area of the chip that is overcooked.

Performing Color Segmentation

After you have trained samples of the colors you want to classify, use the following VIs to perform color segmentation:

  1. Use the IMAQ Get Color Segmentation Distance VI to get the maximum distance allowed between color features belonging to the same color class. Use the output of this VI as an input to the IMAQ Color Segmentation Supervised VI.
  2. Use the IMAQ Color Segmentation Supervised VI to segment the color image and convert it to a labeled grayscale image.

Before you classify objects, you must create a classifier file with samples of the colors using the NI Color Classification Training Interface. Go to Start»All Programs»National Instruments»Color Classification Training to launch the NI Particle Classification Training Interface. Refer to the NI Color Classification Training Interface Help for more information about the NI Color Classification Training Interface.

WAS THIS ARTICLE HELPFUL?

Not Helpful