How do you OCR an tiff file using Tesseract's interface in c#?
Currently I only know how to do it using the executable.
Take a look at tessnet
The source code seemed to be geared for an executable, you might need to rewire stuffs a bit so it would build as a DLL instead. I don't have much experience with Visual C++ but I think it shouldn't be too hard with some research. My guess is that someone might have had made a library version already, you should try Google.
Once you have tesseract-ocr code in a DLL file, you can then import the file into your C# project via Visual Studio and have it create wrapper classes and do all the marshaling stuffs for you. If you can't import then DllImport will let you call the functions in the DLL from C# code.
Then you can take a look at the original executable to find clues on what functions to call to properly OCR a tiff image.
C# program launches tesseract.exe and then reads the output file of tesseract.exe.
Process process = Process.Start("tesseract.exe", "out");
process.WaitForExit();
if (process.ExitCode == 0)
{
string content = File.ReadAllText("out.txt");
}
I discovered today that EMGU now includes a Tesseract wrapper. While the number of unmanaged dlls of the opencv lib might seem a little daunting, it's nothing that a quick copy to your output directory won't cure. From there the actual OCR process is as simple as three lines:
Tesseract ocr = new Tesseract(Path.Combine(Environment.CurrentDirectory, "tessdata"), "eng", Tesseract.OcrEngineMode.OEM_TESSERACT_ONLY);
this.ocr.Recognize(clip);
optOCR.Text = this.ocr.GetText();
"robomatics" put together a very nice youtube video that demonstrates a simple but effective solution.
Disclaimer: I work for Atalasoft
Our OCR module supports Tesseract and if that proves to not be good enough, you can upgrade to a better engine and just change one line of code (we provide a common interface to multiple OCR engines).
Related
I want convert video from .wmv to .mp4 in c#. I was search around google and the result is ffmpeg library. But i don't know use it in c#. Please show me solution or source demo for this problem.
There is a number of .NET wrapper libraries for ffmpeg. A quick search gives these results:
Video Converter for .NET
fflib.net
AVBlocks
Another approach may be simply calling the ffmpeg executable from within your application and providing the proper command line arguments. Here is an example
Also, your question could be framed a bit better. Check out how to ask a question
I'm currently searching for a C# image recognition library.
What I want to do:
I want to write a function that scans an image and returns if another image is part of it. Or at least something that looks familiar in case that the angles of the two objects are different.
The link to a possible library and a short code example would be great!
Thank you in advance!
Since you didn't mention that you are only looking for free libraries, here are some paid ones:
MVTech HALCON
Cognex VisionPro
Both have demo versions and quite good .Net wrappers bundled to the SDK, and I think both have the functionality you need. In Halcon, you might want to try different matching algorightms (gray value based, descriptor based, etc.), while in VisionPro PatMax or PatQuick might suit your needs. But obviously you have to try which one is the best for your specific problem.
EmguCV (http://www.emgu.com/wiki/index.php/Main_Page) is a good .NET OpenCV wrapper. It has a bunch of sample projects bundled. Run samples and you will get the idea of what can be done and how.
The Accord.NET library is not actually an image recognition tool set, however it provides the base for what you are aiming for. It contains many Imaging classes required for building an image recognition system. Accord.NET is LGPL licensed, except for some parts of it (e.g. its FFmpeg wrapper project).
I would like to use NPOI library to get image from Word file (Doc [97-2003]).
I want to HWPFDocument class, but i can not find namespace, where this class is. I write code in c#.
I don't think you can achieve that using NPOI.
As tonyqus (the guy behind the project) states here and here HWPF is not stable and usable.
I've managed to work with MS Word and Excel with "OpenOffice uno SDK".
It's not straightforward but after a little bit of struggle you can have great results.
You can read how to extract and use the assemblies here and how to achieve what you're looking for here.
Of course you can always use MSOffice Interop but you need to install MS Office on the client where the application is executed.
Hope it helps.
i am currently exploring on how to create thumbnail from video file. so far, i am able to generate thumbnail using ffmpeg but can somebody suggest me if there any other ways to generate thumbnail without involving executable(.exe) file.
Thanks,
New Learner, Please guide me...
ffmpeg.exe is the best solution for Video Thumbnails generation as it is free software licensed under the LGPL or GPL.
There are few other places where you will find the solution:
C# Wrapper for the AviFile Library
DirectShow .NET
SlimDX is a free open source framework that enables developers to easily build DirectX applications using .NET technologies such as C#
If you just need a generic thumbnail an easy way to get one is through the WindowsAPICodePack.Shell package. A small, medium, large, or extra large thumbnail can be generated. There's not as much control over the output as ffmpeg but it's hard to beat this method when a generic thumbnail will do or when avoiding an outside exe.
using Microsoft.WindowsAPICodePack.Shell;
using System.Drawing;
namespace GetVideoThumbnail
{
class VideoThumbnail
{
static void Main(string[] args)
{
string videoPath = #"C:\Users\NotSure\Desktop\SampleVideo.MP4";
// Create shell object
ShellObject videoShellObject = ShellObject.FromParsingName(videoPath);
// Create bitmap and/or save locally
Bitmap thumbnailBmp = videoShellObject.Thumbnail.LargeBitmap;
thumbnailBmp.Save(#"C:\Users\NotSure\Desktop\SampleVideoThumbnail.bmp");
}
}
}
Yea!,good this interestingly Q.
I worked it issue,my diploma tasking-at Uni.
And more yet Articles.
1.OpenCV - This Open source project Best worked C/C++,C# and Java
2.Emg CV - This good worked C#
, and more...
Try it's open sources.
You may want to try the VideoFileReader from AForge, specifically AForge.Video.FFMPEG.VideoFileReader. It makes use of ffmpeg DLLs.
Alternatively, on Windows 7, you could use ShellFile.Thumbnail from WindowsAPICodePack or use DirectShow to save a frame with VideoRenderer.
I recently used the ShellFile method, with VideoFileReader as backup.
I am expoloring currently an AutoCAD .NET API to create a dwg files from winform.
Is this possible or should I look for another library?
Are there any new tutorials of doing so?
thanks
Thanks for all your answers .... I will stick with my old DXF implementation, since this is personal project.
Here you have exacly how to do it. AutoCad includes an API for doing that. The problem is that you need to have AutoCad in the computer where your application remains.
I think your only choice if you want DWG is to use OpenDesign. If you don't want to pay what that costs, you can write DXF instead. I have used VectorDraw, which does give a reasonable object model, and can export DXF without any extra component (I think), or use OpenDesign to write DWG.
Autodesk sell a library called RealDWG which allow you to read and write dwg file with C# without AutoCAD installed. ~ 2500 € / year.
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=770257
You can also use DXF, which is easier to read and write (text file). The reference can be found here : http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12272454&linkID=10809853
As mentioned by others, OpenDesign is one possibility. It is, however, prohibitively expensive for small companies; we have started using CadLib, which is far cheaper and seems to do the trick so far. It writes to DXF or DWG, and has fairly good documentation.
If you're planning to create the file without having autocad running, then you CANNOT use the .net API. The use of the .net API basically requires AutoCAD (or the CoreConsole) to be running for it to work. (You can open other databases but you'd be doing it in process from Autocad.
If you don't want it running in process you can use the Interop API.
Or the other alternative is to is to write to a DXF format which can then be imported into AutoCAD (or any other CAD program) which is capable of reading the format.