I am using Leadtools OCR
I referenced the following DLLS:
Leadtools.dll
Leadtools.Barcode.oneD.dll
Leadtools.codecs.dll
Leadtools.codecs.fax.dll
Leadtools.codecs.png.dll
Leadtools.codecs.tif.dll
Leadtools.Forms.DocumentWriters.dll
Leadtools.forms.ocr.dll
Leadtools.forms.ocr.Advantage.dll
And the following code to convert a Png file to Pdf
private void button1_Click(object sender, EventArgs e)
{
try
{
string sourceFile = #"C:\Users\cf\Desktop\OcrTest\Images\Capture.PNG";
string targetFile = Path.ChangeExtension(sourceFile, "pdf");
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
ocrEngine.Startup(null, null, null, #"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");
ocrEngine.AutoRecognizeManager.Run(sourceFile, targetFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, null, null);
Process.Start(targetFile);
}
}
catch (OcrSupportLockedException ex)
{
Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType);
}
catch (OcrException ex)
{
Console.WriteLine("OCR Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
}
catch (RasterException ex)
{
Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("System Error\nMessage:{0}", ex.Message);
}
}
The following line is returning an OcrException
Ocr Not Enabled
With the code: -1760
I cant figure out why this is happening
Any help would be appreciated
Error -1760 "OCR not enabled" is most likely caused by trying to use one of LEADTOOLS OCR engines without an appropriate license file or unlock key.
You could check before using CreateEngine() by calling RasterSupport.IsLocked( RasterSupportType.OcrAdvantage ). If the function returns TRUE, which means Locked, you should not try to use the OCR features.
To use OCR, you need to either own a valid toolkit license with OCR support in it, such as LEADTOOLS Document Imaging Suite, or have a valid free evaluation license.
The mechanism to enable OCR features depends on the toolkit version. If you already have a valid unlock key (v17 and earlier) or valid license file (version 17.5 and later), but it still fails, please send that license/unlock information to support#leadtools.com, since you should not post such details on a public forum.
If you don't have these details, send your toolkit serial number to sales#leadtools.com (also don't post it here!) You can also use our online chat service during working hours to contact support or sales.
Related
I am working with IP camera and EmguCV to detect person in an area.
Everything is work normally with Highgui capture source.
But with Arlo camera which use FFMPEG format, I am unable to get stream without any exception.
Here is the code I have tried:
if (capture == null)
{
try
{
capture = new Capture("rtsp://<IP>:8554/live");
capture.ImageGrabbed += Capture_ImageGrabbed;
capture.Grab();
capture.Start();
}
catch (NullReferenceException exception)
{
MessageBox.Show(exception.Message);
}
catch (TypeInitializationException exc)
{
MessageBox.Show(
"Attention: You have to copy all the assemblies and native libraries from an official release of EmguCV to the directory of the demo." +
Environment.NewLine + Environment.NewLine + exc);
}
}
and here is Capture_ImageGrabbed event which is not fired.
private void Capture_ImageGrabbed(object sender, EventArgs e)
{
Mat image = new Mat();
capture.Retrieve(image);
picCAM.Image = image.Bitmap;
}
Thanks so much for your help!
This might be old, but until now I'm also facing the same issue, even using the newest version (which is version 3.3). Probably not the best solution, but after took some trial and error, what I did is to downgrade to version 2.4.2. You can download here.
I also recently submitted this issue in github. This is probably a bug.
As stated here I'm rebuilding tables from SQL Server to Access by using C#
Thanks to the help I received I could finish the process but since the .accdb files are pretty large, I need to compact and repair them afterwards.
For that, I used the marked answer from here. Strangely, there was only a reference for "Microsoft Office 16.0 Access Database Engine Object Library" that I could add to my project.
using Microsoft.Office.Interop.Access.Dao;
var engine = new DBEngine(); // Exception
var destFile = Path.GetFileNameWithoutExtension(filepath) + "_Compact" + ".accdb";
var destFilePath = Path.Combine(Path.GetDirectoryName(filepath), destFile);
engine.CompactDatabase(filepath, destFilePath);
At the Initialization of the DBEngine - Object, an exception is thrown:
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Also, is there a way to use ADOX for this task, since I'm already using it for creating my catalogs?
Unfortunately, JRO, ADO, nor ADOX can be used to Compact and Repair a Microsoft Access .accdb (Access 2007 and above) database file. However, you are on the right track by using the DBEngine object. One method you can use to avoid relying on the PIA would be to use late binding on the ACE DAO engine (which replaced the JET DAO engine for the older .mdb format).
This method requires no PIA's or Project References. But it does require that the ACE Engine be installed on the machine. The ACE is freely distributable and can be downloaded from Microsoft - Microsoft Access Database Engine 2010 Redistributable
using System;
// Use ACE DAO to Compact an Access .ACCDB file
// This method uses late binding to create the ACE DAO.DBEngine object
public bool CompactDatabaseACE(string SourceDb, string TempPath)
{
string Temp1Db, Temp2Db;
object[] oParams;
bool retVal = false;
Temp1Db = Path.Combine(TempPath, Path.GetFileNameWithoutExtension(SourceDb) + ".cmp");
Temp2Db = Path.Combine(Path.GetDirectoryName(SourceDb),Path.GetFileNameWithoutExtension(SourceDb) + ".old");
if (File.Exists(Temp1Db))
File.Delete(Temp1Db);
if (File.Exists(Temp2Db))
File.Delete(Temp2Db);
oParams = new object[]
{
SourceDb, Temp1Db
};
try
{
object DBE = Activator.CreateInstance(Type.GetTypeFromProgID("DAO.DBEngine.120"));
DBE.GetType().InvokeMember("CompactDatabase", System.Reflection.BindingFlags.InvokeMethod, null, DBE, oParams);
if (File.Exists(Temp1Db))
{
try
{
File.Move(SourceDb, Temp2Db);
}
catch { }
if (File.Exists(Temp2Db))
{
try
{
File.Move(Temp1Db, SourceDb);
}
catch { }
if (File.Exists(SourceDb))
{
retVal = true;
}
}
if (File.Exists(Temp1Db))
File.Delete(Temp1Db);
if (File.Exists(Temp2Db))
File.Delete(Temp2Db);
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(DBE);
DBE = null;
}
catch (Exception ex)
{
// Do something with the error
}
return retVal;
}
I am creating an import / export tool for CRM using C#.
Sometimes, I am facing to an import error, with only this message "Solution manifest import: FAILURE" in my catch. I tried to cast it to its type (FaultException), but I haven't any more details.
If I do the import of the same file directly in CRM, I have a better error message (this one for exemple : "Import of solution xxxx failed. The following components are missing in yout system [...]").
Is there a way to get this complete message ?
Here is my code :
try
{
_serviceProxy.Execute(impSolReq);
}
catch (Exception ex)
{
if (ex is FaultException<OrganizationServiceFault>)
MessageBox.Show("Error during import. More details: " + ((FaultException<OrganizationServiceFault>)ex).Detail);
else
MessageBox.Show("Error during import. More details: " + ex.Message);
}
Thanks for your answers !
Dynamics CRM solutions are imported using the ImportSolutionRequest.
The ImportSolutionRequest has a property containing the ID of the solution import job. You need this ID to be able to monitor the progress of the job and to get error details when the import fails.
Instantiation of the request could look like this:
Guid importJobId = Guid.NewGuid();
var request = new ImportSolutionRequest
{
ConvertToManaged = true,
CustomizationFile = buffer, // a byte[] array holding the solution contents
ImportJobId = importJobId,
OverwriteUnmanagedCustomizations = true,
PublishWorkflows = true,
SkipProductUpdateDependencies = false
};
Execute the request. When an import error occurs, you can retrieve the error details using the job id.
try
{
_service.Execute(request);
}
catch (FaultException<OrganizationServiceFault> ex)
{
if (ex.Detail.ErrorCode == -2147188685) // ImportSolutionError
{
Entity job = _service.Retrieve("importjob", importJobId, new ColumnSet { AllColumns = true });
// TODO: process job error details.
}
throw;
}
Attribute importjob.data contains an XML document with the details you are looking for.
The ImportSolutionRequest is executed synchronously and can easily time-out. Time-outs however can safely be ignored, because the import process continues to run in the background. You can track progress by retrieving the import job record at regular intervals. As long as attribute importjob.completedon is null, the job is still running.
I have the following function which opens a dxf file in an Autocad Exe, by zooming a specific coordinate via my C# desktop application.
public static void zoomDrwaing(String drawingFile, String lotId)
{
AcadApplication acadApp = null;
AcadDocument doc = null;
double[] coordinates = new double[3];
String errorMessage = "";
try
{
coordinates = ReadCoordinates(drawingFile, lotId); // done via netDxf api
acadApp = new Autodesk.AutoCAD.Interop.AcadApplication();
acadApp.Visible = true;
doc = acadApp.Documents.Open(drawingFile, true);
double[] points = new double[3] { coordinates[0], coordinates[1], coordinates[2] };
acadApp.ZoomCenter(points, 30);
}
catch (Exception ex)
{
errorMessage = ex.ToString();
}
finally
{
if (acadApp != null) Marshal.FinalReleaseComObject(acadApp);
}
}
I would like to know whether there is any possibility of loading the Autocad Exe (with the zoomed dxf file) inside one of the Windows forms in my desktop application it-self rather than opening the exe separately.
I haven't tried it but apparently you can use the ActiveX control from DWG Trueview Here is a forum post on the Autodesk forum with some sample code. Googling DWG Trueview Activex should generate some reading material. Or you may just read this and abandon all hope. The $$ alternative is RealDwg or Open Design. Read the AutoCAD Tag wiki for more resources and info on that.
Because Autodesk love to destroy their inbound links from time to time, you should be able to land on the first topic I mentioned using Google if they kill it again. Don't get me started on that.
I wrote a WiX custom MBA that I have been using which embeds all of the setup packages (msis, cabs and exes) I need for my installation. However I would now like to make a lightweight web bootstrapper which will download the packages that need to be installed. I thought you would get that for free with the underlying WiX bootstrapper engine, but I guess I was wrong.
I tried subscribing to the ResolveSource event to get a package's download url and download it to the local source location, but it seems like at that point it's too late in the process as my installation fails with an error "Failed to resolve source for file: " (even though the download is successful).
Sample of what I tried:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
string localSource = e.LocalSource;
string downloadSource = e.DownloadSource;
if (!File.Exists(localSource) && !string.IsNullOrEmpty(downloadSource))
{
try
{
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(e.DownloadSource, e.LocalSource);
}
}
catch (ArgumentNullException ex)
{
e.Result = Result.Error;
}
catch (WebException ex)
{
e.Result = Result.Error;
}
}
}
Thanks to Rob Mensching answering this on the wix-users mailing list:
Make sure your packages of URLs provided (authored is easiest but you can
programmatically set them all) then return IDDOWNLOAD from the
ResolveSource call.
I edited my code as follows:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
if (!File.Exists(e.LocalSource) && !string.IsNullOrEmpty(e.DownloadSource))
e.Result = Result.Download;
}
Setting the result to Result.Download instructs the bootstrapper engine to download the package. No need to try to download the file myself.