Pattern Recognition enables basic determination if the shapes within region of interest matches the shapes in predefined template images. The Transform returns an enumerated value for the closest matched shape. This method can be used for simple 'On-Off' check, (if a certain shape is present in the region of interest), or to check if one of many patterns is present (if a different icon is shown for a different state in the same region of interest).
To set up Pattern Recognition, create a full image for every different state to be recognized, or for simple 'On-Off' check just one full image showing the 'On' condition. Create a new directory for every signal under the RecoImages directory in the project folder. Place the full images under "Full_Image" directory.
1.Make sure the Camera Transform is set up.
2.In MxTransIt, click the Image Recognition transform' from the Toolbox panel to add it to the harness.
3.Configure Transform properties: Change the Transform name from the default name to the Signal name you would like to see in the MxVDev test case. This is the Signal name that is added to the Signal Dictionary.
4.Under Image Recognition Properties, make sure Image Recognition Mode is set to Pattern Recognition.
5.Set the Base Directory Path. The name of the folder should be the name of the Signal.
6.Click the button in Configure Image Recognition to bring up the configuration form for this Signal.
7.The first tab of the configuration form shows images found in the Full_Image subdirectory of the Base Directory for this signal. If no images are shown, click cancel and make sure that the Base Directory property is set to the correct directory and that the Full_Image folder contains your full images.
Click on the desired Full Image in the list box on the left and draw a rectangle for the ROI around the pattern to be used for Pattern Recognition. Alternatively, you can input the ROI pixel coordinates manually into the fields on the right. In general, the ROI should be a few pixels larger than the shape you are interested in. Using the toolbar under the image, you can Zoom In, Zoom Out, and Pan the Image. The Rectangle ROI tool is used to draw or modify the ROI rectangle on the image. You can move the rectangle by clicking in the middle, or drag bounding lines or corners.
8.Once you've selected the ROI, create a Sample image by clicking the Add button. A sample image is a version of the full image cropped to the selected ROI. Sample images are used for testing the search algorithm and Pattern creation. You can add a couple different Samples or click 'Add All' to create a Sample image out of all full images (useful for multi-state signals).
Note: Do not click OK. Proceed to the next step.
9.Click Create Pattern tab to show the just created sample images.
10.Draw the rectangle around the pattern you would like to search for, leaving out as much of the background as possible. Click the Add button to create a pattern image. Click 'Add All' only if you want to create a pattern image for all sample images (in the case where each sample image shows a different state of the multi-state signal; otherwise, if the signal can have only 3 values, create only 3 pattern images).
11.Click the Test Pattern Match tab to test the recognition algorithm.
12.Change the search options or use the default values and click the Run Test button. If the pattern is recognized in a sample image, a bounding box is drawn. The score indicates how closely the template image (pattern image) matches the image tested (sample image). For multi-state signals, click next/previous buttons to test all patterns. In case of multi-state signals, the value assigned to the pattern that returns the highest match score is passed to the test case as a result of the image recognition on the current image under test.
13.Click the Signal Port Properties tab to specify what values are returned during the test. Enumeration set up at this step is passed to the Signal Dictionary. If the pattern is not found in the image ROI, it returns default value 0. Click on the Cell for Enum ID or Enum Name to modify the values to be returned during the test. (In the example below, the signal returns 1 if pattern is found, and 0 if not found during the execution of the test).