Code: Select all
Application: Soskb.Main.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at j.c(IntPtr, System.String, System.String, System.String, IntPtr ByRef, Int32 ByRef, Int32, Int32, IntPtr, Int32, Int32, Int32 ByRef, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
at j.a(IntPtr, System.String, System.String, System.String, IntPtr ByRef, Int32 ByRef, Int32, Int32, IntPtr, Int32, Int32, Int32 ByRef, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
at aq.a(Int32, Int32, Int32, Int32, Int32, System.String, System.String, System.String, IntPtr ByRef, Int32 ByRef, Int32)
at GdPicture.GdPictureImaging.OCRTesseractDoOCR(Int32, System.String, System.String, System.String)
at Soskb.OpenImagingTools.WpfImaging.OcrPage(Byte[], System.String ByRef, System.String ByRef)
at Soskb.Main.OcrPageThread.SendPage()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
Code: Select all
Public Sub SendPage()
Dim sEName As String = String.Empty
Dim sSosid As String = String.Empty
Dim oBatch As New DimeBatchScanClient
Try
SyncLock locker
Soskb.OpenImagingTools.WpfImaging.OcrPage(mbData, sSosid, sEName)
End SyncLock
'call the search object async -NC KE 1/24/2006
Dim oMsg As New SendOcrPageMessage
oMsg.Certificate = gCertificate
oMsg.Data.Identifier = miIVaultId
oMsg.Data.Page = mbData
oMsg.Data.PageCount = miPageCount
oMsg.Data.SosId = sSosid
oMsg.Data.EName = sEName
oBatch.SendOcrPage(oMsg)
RaiseEvent PageSent(miPageCount)
Catch ex As Exception
LogEvent(ex)
If Debugger.IsAttached Then Debugger.Break()
End Try
End Sub
Code: Select all
public static void OcrPage( byte[] xoBitmap, ref string xsSosid, ref string xsEName)
{
string sOCR;
string[] sOCRLine;
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
Int32 m_ImageID = 0;
string[] sSosIdLine = null;
string[] sENameLine = null;
string sSosId = null;
string sEName = null;
OCRContext context;
byte[] Image = xoBitmap;
try
{
//enter license -NC KE 8/3/2011
oGdPictureImaging.SetLicenseNumber("xxx"); // Please, replace XXXX by a valid demo or commercial license key.
oGdPictureImaging.SetLicenseNumber1DBarcodeRecognition("xxx"); // Please, replace XXXX by a valid demo or commercial license key.
//load image -NC KE 8/3/2011
m_ImageID = oGdPictureImaging.CreateGdPictureImageFromByteArray(ref Image);
if (m_ImageID > 0) //good image -NC KE 8/3/2011
{
//init and do ocr -NC KE 8/3/2011
context = OCRContext.OCRContextDocument;
oGdPictureImaging.OCRTesseractSetOCRContext(context);
oGdPictureImaging.SetROI(0, 0, oGdPictureImaging.GetWidth(m_ImageID), oGdPictureImaging.GetHeight(m_ImageID) / 4);
oGdPictureImaging.OCRTesseractReinit();
sOCR = oGdPictureImaging.OCRTesseractDoOCR(m_ImageID, "eng", "C:\\program files\\soskb", "");
//split ocr lines -NC KE 8/3/2011
sOCRLine = sOCR.Split("\r\n".ToCharArray());
foreach (string oLine in sOCRLine) //loop each line -NC KE 8/3/2011
{
if (oLine.ToLower().Contains("corporation:") == true && sENameLine == null) // ename -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sENameLine = oLine.Split(":".ToCharArray());
}
else if (oLine.ToLower().Contains("number:") == true && sSosIdLine == null) //sosid -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sSosIdLine = oLine.Split(":".ToCharArray());
break;
}
else if (oLine.ToLower().Contains("number;") == true && sSosIdLine == null) //sosid -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sSosIdLine = oLine.Split(";".ToCharArray());
break;
}
else if (oLine.ToLower().Contains("number.") == true && sSosIdLine == null) //sosid -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sSosIdLine = oLine.Split(".".ToCharArray());
break;
}
else if (oLine.ToLower().Contains("number?") == true && sSosIdLine == null) //sosid -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sSosIdLine = oLine.Split("?".ToCharArray());
break;
}
else if (oLine.ToLower().Contains("id number") == true && sSosIdLine == null) //sosid -NC KE 8/3/2011
{
//split after : -NC KE 8/3/2011
sSosIdLine = oLine.ToLower().Replace("id number","id number:").Split(":".ToCharArray());
break;
}
}
if (sENameLine != null && sENameLine.GetUpperBound(0) > 0) // got ename -NC KE 8/3/2011
{
//do some char replacements on ename -NC KE 8/3/2011
sEName = sENameLine[1].Trim().ToLower().Replace(" ", "").Replace(".", "").Replace(",", "");
if (sEName.EndsWith("inc") == true)
{
sEName = sEName.Substring(0, sEName.Length - 3).Trim();
}
if (sEName.EndsWith("ltd") == true)
{
sEName = sEName.Substring(0, sEName.Length - 3).Trim();
}
if (sEName.EndsWith("llc") == true)
{
sEName = sEName.Substring(0, sEName.Length - 3).Trim();
}
if (sEName.EndsWith("llp") == true)
{
sEName = sEName.Substring(0, sEName.Length - 3).Trim();
}
}
if (sSosIdLine.GetUpperBound(0) > 0) // got sosid -NC KE 8/3/2011
{
if (sSosIdLine[1].ToLower().Contains("s") == true) // not do report more data on same line -NC KE 8/3/2011
{
//split off other data -NC KE 8/3/2011
sSosId = sSosIdLine[1].ToLower().Split("s".ToCharArray ())[0].Trim();
}
else if (sSosIdLine[1].ToLower().Contains("f") == true) // not do report more data on same line -NC KE 8/3/2011
{
//split off other data -NC KE 8/3/2011
sSosId = sSosIdLine[1].ToLower().Split("f".ToCharArray())[0].Trim();
}
else
{
//us whole line -NC KE 8/3/2011
sSosId = sSosIdLine[1].Trim().ToLower();
}
//do some common replacements -NC KE 8/3/2011
sSosId = sSosId.Trim().ToLower().Replace("o", "0").Replace("i", "1").Replace("()", "0").
Replace("l", "1").Replace("z", "2"). Replace("u", "0").Replace("q", "0").Replace("]", "1").
Replace("b", "8").Replace("?", "7").
Replace(" ", "").Replace("-", "").Replace("'", "").Replace("`", "").Replace("=", "").
Replace("<", "").Replace(">", "").Replace("‘", "");
//finally remove any non numeric . loop all chars -NC KE 8/10/2011
for (Int32 iCount = 0; iCount < sSosId.Length; iCount++)
{
if (Soskb.Common.Utilities.C.Utility.IsNumericStrict(sSosId.Substring(iCount, 1)) == false) //not numeric -NC KE 8/10/2011
{
//remove char -NC KE 8/10/2011
sSosId= sSosId.Remove(iCount, 1);
iCount--;
}
}
}
}
//return data -NC KE 8/2/2011
xsEName = sEName;
xsSosid = sSosId;
}
catch (Exception)
{
xsEName = string.Empty;
xsSosid = string.Empty;
}
finally
{
if (oGdPictureImaging != null)
{
oGdPictureImaging.OCRTesseractClear();
oGdPictureImaging.ReleaseGdPictureImage(m_ImageID);
oGdPictureImaging = null;
}
Image = null;
}
}
}