请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
visionpro字符识别
CogImage8Grey aImage = (CogImage8Grey)aImageFile[0];
aImageFile.Close();
// Define an appropriate region of interest ...
CogRectangleAffine aROI = new CogRectangleAffine();
aROI.SetOriginLengthsRotationSkew(340, 748, 1010, 93, 0, 0);
// Create a CogOCRMaxTool ...
mTool = new CogOCRMaxTool();
// Start to configure the tool ...
mTool.InputImage = aImage;
mTool.Region = aROI;
// Initially, run just the tool's segmenter. We'll use
// segmentation results to populate a font object for
// use by the classifier ...
CogOCRMaxSegmenterParagraphResult aSegmenterParagraphResult = null;
try
{
aSegmenterParagraphResult = mTool.Segmenter.Execute(aImage, aROI);
}
catch (Exception aX)
{
DisplayErrorAndExit(aX.Message);
return;
}
CogOCRMaxSegmenterLineResult aSegmenterLineResult =
aSegmenterParagraphResult[0];
// We know apriori that this image with this ROI will yield
// segmented images of the alphabet A through Z ...
int[] aAlphabet = new int[] {
(int)'A', (int)'B', (int)'C', (int)'D', (int)'E', (int)'F',
(int)'G', (int)'H', (int)'I', (int)'J', (int)'K', (int)'L',
(int)'M', (int)'N', (int)'O', (int)'P', (int)'Q', (int)'R',
(int)'S', (int)'T', (int)'U', (int)'V', (int)'W', (int)'X',
(int)'Y', (int)'Z'};
int iC = 0;
foreach(CogOCRMaxSegmenterPositionResult aSegmenterPositionResult in
aSegmenterLineResult)
{
CogOCRMaxChar aC = aSegmenterPositionResult.Character;
aC.CharacterCode = aAlphabet[iC];
mTool.Classifier.Font.Add(aC);
iC ;
} // for each(CogOCRMaxSegmenterPositionResult ...
// Now we can train the classifier ...
try
{
mTool.Classifier.Train();
}
catch (Exception aX)
{
DisplayErrorAndExit(aX.Message);
return;
}
if (!mTool.Classifier.Trained)
{
DisplayErrorAndExit("Could not train classifier.");
return;
}
// Enable the fielding
mTool.FieldingEnabled = true;
// Now some final form setup from the tool ...
txtFieldString.Text = mTool.Fielding.FieldString;
chkFieldingAliasAlpha.Checked =
mTool.Fielding.FieldingDefinitions['A'].Enabled;
chkFieldingAliasNumeric.Checked =
mTool.Fielding.FieldingDefinitions['N'].Enabled;
chkFieldingAliasAny.Checked =
mTool.Fielding.FieldingDefinitions['*'].Enabled;
ctrlToolDisplay.Tool = mTool;