Folder Monitor: 25 Projects in 25 Days

This is the first project in a series of examples created by the LEADTOOLS Support Department. As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Aaron.

What it Does

This C# console application monitors a directory and converts all the files pasted or dropped into the directory to searchable PDF files using LEADTOOLS Version 19.

Features Used

Development Progress Journal

Hello, my name is Aaron I am going to write a C# sample console application that continuously watches a directory and converts all files that are pasted or dropped into this directory into searchable PDF files using the LEADTOOLS Document Converter Toolkit.

When thinking about how I was going to write this application, I decided it would be a nice addition to show how the application could be run using a Windows Service. I am going to use our OCR Advantage Engine to recognize the document so I can save it as a searchable PDF file.
Documentation: IOcrEngine

I have finished setting up the application to continuously monitor a certain directory that is created when the application starts. This took about half an hour.

I am now starting to implement the OCR Advantage Engine and loading the input file into an OCR Document.
Documentation: IOcrDocument

I have completed implementing these features but while doing some testing with this functionality I realized I was missing some required codecs for certain files. I added the needed codecs to the project. This took about an hour.
Documentation: Files to be Included With Your Application

I will now begin implementing the OCR Document recognition and saving the OCR Document as a searchable PDF file. This took about fifteen minutes.

It took about fifteen minutes to implement the recognition and saving. My application is mostly complete now. I am beginning to do some sanity testing and making sure I have all the necessary comments in my code. This took about half an hour.

It took about half an hour to sanity test and finish commenting my code. I have completed the main application (Folder Monitor) and I will now begin setting up the application for inserting this application into a Windows Service. I originally planned to put the entire application in a Windows Service but it seems that would require modifying your registry to increase the timeout for loading a Windows Service, since it takes a while to load the application, so I just simply wrapped the FolderMonitor.exe into the Windows Service.

I have completed setting up the Windows Service for this application. If you wish to test the application using a Windows Service, I have included a readme on how to set it up.

My application is now ready to deploy. It took me a total of 4 hours. Without LEADTOOLS, this would have taken me weeks just to convert the files to searchable PDF files.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Posted in Document Imaging | Tagged , , , , , , , , , , | Leave a comment

File Conversion Right-click Shell Extension: 25 Projects in 25 Days

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Nick.

What it Does

This project shows how to convert any image file format by right-clicking on it using LEADTOOLS Version 19.

Features Used

Development Progress Journal

Hello, I’m Nick and I’ll be creating a shell extension to convert image files.

From a personal experience, I’ve dealt with opening files in high-end graphics programs before for the sole purpose of converting them to another format. Loading up and shutting down these applications can be a time-consuming process just to convert a single file. I’ve also done some batch scripts before to automate conversions from the command line and while this is useful, it’s more so when converting multiple images at once. But, for one at a time, a shell extension which puts these options at a right-mouse click would be ideal.

Using the LEADTOOLS codecs will save quite a bit of time, rather than using .NET code directly. Furthermore, LEADTOOLS makes file conversion for over 150 image file formats quite simple, which will give me more time to focus on the context menu.

I’ve dug up some example code on implementing a context menu. Turns out there are quite a few things I didn’t consider, but I should be able to use this as a starting point for my implementation.

I’ve modified the code to insert registry keys which associates the shell extension with the file formats. It was a bit tedious digging into the registry to learn how the keys were structured, so this took a few hours to complete.

I’ve achieved a proof of concept by registering my extension with the CMP format, so the option “LEADTOOLS Convert” appears as an entry when right-clicking any CMP file in Windows Explorer. However, the menu item has no functionality at this point. It’s taken me maybe four hours to get to this point.

Now I’m wiring in the actual logic to handle the menu item being clicked, and extended the proof of concept to convert the file to a PNG. For this, I’m just loading the file using RasterCodecs.Load(), then saving it back with RasterCodecs.Save() in the new format:
Documentation: RasterCodecs.Load
Documentation: RasterCodecs.Save

I could create a custom GUI that would offer additional format conversions. Luckily, LEADTOOLS has already done the legwork for me by providing RasterSaveDialog. Creating that dialog box, and the background logic that goes with it, took maybe six lines of code, about an hour, and another DLL reference.
Documentation: RasterSaveDialog

At this point, the first time the program runs it integrates the necessary keys into the registry for the file types. After that, right-clicking a file of that type displays “LEADTOOLS Convert” on the context menu. Selecting that option dipslays the LEADTOOLS Save dialog box, where output format, filename, and other options can be set.

A coworker recommended an icon. I extended the program to set registry keys pointing to a default icon file to use. After establishing that the change worked, I tracked down an image of the LEADTOOLS “triangle” logo to use. However, it was a JPG. I right-clicked it, selected LEADTOOLS Convert from the context menu, chose “Ico” as the output format, and hit save, making it easy to add to the project.

Digging up examples, researching, and ultimately ditching one implementation for another took maybe eight hours, but I’m pleased with the results.

Originally, my implementation involved loading the file to be converted into memory as a RasterImage, then to be saved to the output filename and format. However, during peer review, it was suggested I use RasterCodecs.Convert() instead. I modified my program and, using this, was able to perform the image conversion in a single line of code!
Documentation: RasterCodecs.Convert

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Posted in General Imaging | Tagged , , , , , , , | 2 Comments

Media Streaming Server Video

We hope you are enjoying all the buzz surrounding our 25 projects in 25 days. This afternoon we’re making a quick interruption to announce a new Media Streaming Server video published to our YouTube channel.

This video provides an overview of the Media Streaming Server and its ability to use a single source file and stream it to multiple devices and formats such as Flash, HTML5, Apple HTTP Live Streaming, RTSP, MPEG-DASH, Adobe HDS and Microsoft Smooth Streaming.

In case you missed it, we also wrote a white paper on this feature which goes into greater detail regarding the setup, usage and benefits of this amazing new technology in LEADTOOLS.

Posted in Multimedia Imaging | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

Zonal OCR REST Service: 25 Projects in 25 Days

Testing OCR Web Service
Testing OCR Web Service
Testing OMR Web Service
Testing OMR Web Service
Testing MICR Web Service
Testing MICR Web Service

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Maen.

What it Does

This project extends the OCR REST service to accept multiple zones using LEADTOOLS Version 19.

Features Used

Development Progress Journal

Hello, my name is Maen and I am going to add a new method to our OCR REST service that takes the URI of a zone file (ozf) and an array of objects that contains the bounds and type of each zone.

I am going to use LEADTOOLS Document Imaging Suite SDK, because it provides me with the support of different recognition features including OCR, MICR, OMR, zoning and many other features. The main advantage (in my opinion) of using LEADTOOLS Document toolkits is saving time and effort when dealing with images and documents.

I am going to create a new method named GetTextWithPredefinedZones. This method will take the URI of a zone file (ozf) and an instance of a user-defined class named ZonesData. The ZonesData class will have two members:

  • ZonesBounds: This array of LeadRect objects that contains the bounds of each zone.
  • ZonesTypes: This array of integers contains the type of each zone. For more details about the zone types, please see the Leadtools.Forms.Ocr.OcrZoneTypeenum.

Note that this method will use the zones file (.ozf) by default even if you pass an instance of ZonesData class. If you pass an empty string to the zones file name parameter, the function will use the ZonesData instance.

I have finished adding the new method with the required classes and types based on the following online help topics:

So far, I have 5 hours total invested in modifying the OCR REST service including the coding and debugging time. I am now creating a test C# application to check the OCR service.

I successfully ran the test application and tried different images with different zones bounds and types and it worked as expected, and finally the application and OCR service are done! It took me around 8 hours to put this together, including designing, testing and debugging.

The greatest credit of completing this application belongs to my beloved tools for providing excellent features and fully tested functions that made programming much easier for me and for programmers all over the world.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\REST directory.

Posted in OCR | Tagged , , , , , , , | Leave a comment

Express PACS Import: 25 Projects in 25 Days

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from James.

What it Does

This project will monitor a folder and import DICOM files into a PACS Storage Server using LEADTOOLS Version 19.

Features Used

Development Progress Journal

Hello, my name is James I’m going to write a service that monitors a folder that will automatically import DICOM files directly into the LEADTOOLS PACS Storage Server database without using DICOM C-STORE when you drop them into the folder. I will also be writing a Service Manager interface to go along with this.

Using LEADTOOLS Medical SDKs will save me valuable time while extracting and storing the information out of DICOM files. Otherwise, this would require many hours to learn and code.

First, I am going to need to determine a way to insert all of the data from the file into the PACS Storage Server database. I know there is a way to do this with the LEADTOOLS data access layer. Let me take a look at the documentation.

Ok, it looks like I can use the LEADTOOLS StorageSQLDbDataAccessAgent to take care of this for me.
Documentation: StorageSqlDbDataAccessAgent Class

I am going to need to use the LEADTOOLS DicomDataSet class as this, combined with the StorageSQLDbDataAccessAget, is going to make easy work of extracting and storing all of the information I am going to need from the DICOM files.
Documentation: DicomDataSet class

I have finished writing the Service Manager interface which controls the service, displays the current state of the service, and allows the user to configure their settings. This took approximately 1.5 hours to complete.

I am going to use the StoreDicom method of the StorageSQLDbDataAccessAgent class to store the information I need from the DICOM files.
Documentation: StoreDicom Method

I have finished writing out the StoreDicom method that will validate the file the user puts in the folder and extract all of the information I am going to need to proceed. This only took approximately 1 hour to complete with the help of the LEADTOOLS StorageSQLDbDataAccessAgent class.

I need to make sure I put the files that the service says are invalid somewhere so they can still be accessed later for review

Now, I just need to put all of this together in a Work class that I’ll create and wrap everything up.

Everything has been consolidated into my Work class. This took approximately 1 hour to complete.

I successfully stored a DICOM file to the PACS Storage Server by dragging it into the monitored folder. So far, I have 3.5 hours total invested in this application. Now, I want to test some DICOM files that do not have all the information in them to be sure they are caught and properly stored by the service.

I have added some more error checking to handle any type of file being dropped into the folder. I also added some comments to the code for easier reading.

This application is done and done! It only took me a total of 4.5 hours to put this together, including testing and debugging. Without LEADTOOLS Medical Imaging SDKs, I cannot even imagine how long a task like this would take.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Posted in Medical Imaging | Tagged , , , , , , , | Leave a comment