←Select platform

FindCandidateFormFieldsCommand Class

Summary

Extracts the candidate form fields from a bitmap using various options. There are two types of fields that can be extracted: OMR fields and text fields.

Syntax
C#
C++/CLI
Java
Python
public class FindCandidateFormFieldsCommand : RasterCommand 
public class FindCandidateFormFieldsCommand 
    extends RasterCommand 
public: 
   ref class FindCandidateFormFieldsCommand : RasterCommand 
class FindCandidateFormFieldsCommand(RasterCommand): 
Remarks

If an image is skewed, deskew it first before running FindCandidateFormFieldsCommand.

FindCandidateFormFieldsCommand supports 8-bit, 12-bit and 16-bit grayscale images, as well as 24-bit, 32-bit, 48-bit, and 64-bit colored images. This function does not support 32-bit grayscale images. If a 32-bit grayscale image is passed to this function, it returns the ERROR_GRAY32_UNSUPPORTED error code.

FindCandidateFormFieldsCommand does not support setting rectangular regions.

Example

Runs the FindCandidateFormFieldsCommand on an image.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
 
public void FindCandidateFormFieldsCommandExample() 
{ 
 
   RasterCodecs codecs = new RasterCodecs(); 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Forms to be Recognized\OMR\AnswerSheet_Pattern.jpg"), 0, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1); 
   FindCandidateFormFieldsCommand findFields = new FindCandidateFormFieldsCommand(); 
   findFields.HorizontalLineMinimumLength = 10; 
   findFields.VerticalLineMinimumLength = 3; 
   findFields.Run(image); 
 
   TextField[] textFields = findFields.TextFieldAreas; 
   OMRField[] omrFields = findFields.OMRFieldAreas; 
 
 
   foreach (TextField field in textFields) 
   { 
      TextFieldType textFieldType = field.FieldType; 
      StringBuilder stringBuilder = new StringBuilder("** Text Field Properties **\n"); 
      stringBuilder.AppendLine("Filled: " + field.IsFilled.ToString()); 
      stringBuilder.AppendLine("Empty space, if there is any on the top or the bottom of the filled area: " + field.SpaceBounds[0].ToString()); 
      stringBuilder.AppendLine("Empty space, if there is any on the right side of the filled area: " + field.SpaceBounds[1].ToString()); 
      stringBuilder.AppendLine("TextFieldType: " + textFieldType.ToString()); 
      stringBuilder.AppendLine("Bounds: " + field.Bounds.ToString()); 
      stringBuilder.AppendLine("FilledAreaBounds: " + field.FilledAreaBounds.ToString()); 
      System.Diagnostics.Debug.WriteLine(stringBuilder.ToString()); 
      // Function TODO : Drawing rectangle field.Bounds 
      // Function TODO : Drawing rectangle field.FilledAreaBounds 
   } 
 
   foreach (OMRField field in omrFields) 
   { 
 
      if (field.FieldType == OMRFieldType.BoxOMR) 
      { 
         // Function TODO : Drawing rectangle field.UnFilledBound 
      } 
      else 
      { 
         // Function TODO : Drawing circle field.UnFilledBound 
      } 
      StringBuilder stringBuilder = new StringBuilder("** OMR Field Properties **\n"); 
      stringBuilder.AppendLine("FilledBound: " + field.FilledBound.ToString()); 
      stringBuilder.AppendLine("FilledConfidence: " + field.FilledConfidence.ToString()); 
      stringBuilder.AppendLine("IsFilled: " + field.IsFilled.ToString()); 
      stringBuilder.AppendLine("OMRConfidence: " + field.OMRConfidence.ToString()); 
      stringBuilder.AppendLine("UnfilledBound: " + field.UnfilledBound.ToString()); 
      System.Diagnostics.Debug.WriteLine(stringBuilder.ToString()); 
   } 
 
   image.Dispose(); 
 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.11.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.