Using Microsoft InkAnalysis APIs without Tablet input? - c#

I recently discovered that all Windows 7 machines have an handwriting recognition API within them called Microsoft Ink Analysis ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms704040(v=vs.85).aspx ).
I would like to use the API for intelligent character recognition - to convert individually spaced handwritten letters from an image into text. I have found demos of the API being used with paper surveys ( http://msdn.microsoft.com/en-us/library/ms840402.aspx ), but it appears in all the demos the handwriting itself needs to be entered live -
Is it possible to use the Ink Analysis API to analyze images, instead of live input? If so, how is this done?

Ink Analysis uses stroke information inputted from ink panels to recognize handwriting (aka "live input"), and does not do analysis on raw image data.
Unfortunately, you'll need to find an OCR library for that.

I have been trying to answer that question myself, in theory it only works with live input, but ink analysis also enables developers to save and load ink strokes using Ink.Load and Ink.Save. Maybe you can turn a bitmap image into an array, and save this array into an ink object. Then you can use ink analysis to analyze your strokes.

Related

How to add LateX/Math to Windows 10 Ink API?

From highlights of Microsoft Build 2016, I saw Microsoft was pushing its new Ink API.
What exactly are the new additions?
Can Ink
Understand handwriting and digitize it?
Understand Math/Equations and digitize it (ie Latex)?
Are there any other APIs that can do this for UWP or Unity?
How would I go about creating one myself?
Jeans link refers to custom recognition. Is this what I'm looking for? I feel like there should be an option to add symbols to the lookup dictionary.
Yes for the first point, you can convert ink strokes to text using handwriting recognition.
Recognize ink strokes
For math and equations, didn't see any default Recognizer at the moment.
-Understand handwriting and digitize it?
Yes, that's the whole point of the API.
It's basically OCR 2.0
-Understand Math/Equations and digitize it (ie Latex)?
Nope. Or, at least, not yet because, of course, it would be a logical expansion of the API.
Are there any other APIs that can do this for UWP or Unity?
Not that I had heard of.
Finally, I don't think that Jeans link is what you are looking for. It's not simply a matter of adding a new symbol, but also to represent it conveniently.
For example, how would you do to display \frac{\,\frac{a}{b}\,}{\frac{c}{d}} ?
There is no correct way of positioning the a/b over the fraction bar and the c/d under it. Even if you can use superscript and subscript, there is no way for a standard police to align them vertically.
The good news is: Ink is an API, which means you could create a wrapper that would, for example, automate the latex pdf generation. So yes, you could create the functionality you're looking for with a bit on C# (as it looks you're on a Microsoft environment)
Take a look at this thread: https://tex.stackexchange.com/questions/53914/compile-tex-inside-microsoft-c-net
Best of luck!
For LaTex, there's a Xamarin library called CSharpMath, which uses SkiaSharp to render the math expression. It is ported from the iosMath project.
As the library is .NetStandard, so it also means you can use it in an UWP app.
The repository can be found here.

Tool to convert string to BackgroundImage for Windows Phone 8 Live Tile

Currently I'm trying to create a Live Tile where it pulls data from a JSON link, run some code to filter it and spits out the data on the FRONT side of the tile.
From Windows Phone 8's Flip Tile specification, only the back side of the tile can have text. I'd like to enable it for the front side so the user doesn't have to wait for the tile to flip. From what I understand, this can be achieved by converting my text to an image, and then set it as a BackgroundImage for my tile.
Windows Phone 7 had a tool called Ree7 which enables that, but I'd like to enable it for Windows Phone 8, medium and large tiles.
Additionally, it would be great if my tiles don't flip and remain on its front side.
Having extra images such as app icon on the tile would be an additional plus.
Can someone please point me to the right direction to proceed here? Using a pre-built tool (like a Ree7 for WP8) seems like the best way here.
see if this tool could be useful.
http://blogs.msdn.com/b/shintak/archive/2013/01/01/10418997.aspx
he hasn't provided the source, but you could possibly contact the blogger to get it.
http://www.telerik.com/products/windows-phone/overview/all-controls/livetilehelper.aspx
I believe I found the answer to my question. However, if there are better, free alternatives that do not distort the text too much (such as Lawrence Gripper's old BBC News Mobile app, where text is extremely legible with little distortion), please do share it here.
Thanks!

Make entire screen monochrome and other full screen effects

Does anyone know how to apply effects to the entire screen, in c# or any programming language.
I'm mostly interested in making the screen monochrome (specifically green-white instead of black white).
I know a cross-graphic card solution is possible because I found a program that can do it:
http://www.freedomscientific.com/products/lv/magic-bl-product-page.asp
Anyone knows how to accomplish something this or where to look?
Thanks !!
There is no easy Windows API to modify the entire screen contents. But this could be done at the device driver level.
Otherwise you have to resort to some Windows API tricks: place a "fake" window over the entire desktop, in a loop: grab the entire screen contents without grabbing fake window contents, do your processing to get the monochrome effect, then display that on the fake window. Yes, it's hacky and slow, but possible. Even more hacky, when you get mouse clicks to "go through" the fake window (lots of SetWindowsRgn calls).
So cross-platform here means using GDI, though some older DirectDraw APIs might work, in that case, you have a much easier time with hardware overlays (and better performance). Though I'm not sure how many cards actually support hardware overlays, and if newer versions of windows support the older DirectDraw APIs.
One more possibility is if the video card has a C# or C++ or C API, then you can do whatever you want with the card without writing device driver code.
Then there's CUDA, but I haven't yet tried that out. I know it's for stream processing on nVidia boards, but I wonder if it could get you an easy backdoor into the video display stuff.
To help people in the future who are interested in this:
This is possible with the Magnification API's color effect method. This allows one to use a matrix that can be applied to the whole screen.
NegativeScreen is an open source project that implements the feature you are describing in C#.
Unfortunately, this only works with affine transformations, as the API takes only an augmented matrices rather than a delegate or something.

C# Image Processing Whitespace

I have a ton of pdfs scans that I have converted to images. Most of these scans contain a lot of whitespace around the edges.
What is the best way to go about finding a boundingbox for the actual content and then subsequently removing the whitespace?
I've thought about writing a program that just displays the image, then you drag a box and its saves the image, and moves on to the next one. This would be VERY time consuming, but it would get the job done. I'd like to be able to automate this process somehow using C#.
Either buy just cropping the image or by perhaps by suggesting a bounding box.
Emgu CV (on SourceForge) is a .NET wrapper around OpenCV, which has numerous image manipulation capabilities, including image filters and a bounding box algorithm that could solve this pretty easily.
http://code.google.com/p/aforge/
Aforge is a complete C# library Not a wrapper. OpenCV is very professional tool in compare of AForge.
Are you talking about scanned documents or scanned photos ? What format are your images in ? It sounds like you need an AutoCrop function.
Here is a freeware C# component that has an autocrop function. It should work well on B/W documents. You will need to see if it works the way you want if you are using photos.
http://www.hi-components.com/nievolution_features.asp
This component would also allow you to write code to load your images, draw a bounding box and and then save the cropped images as needed.

Rendering graphics in C#

Is there another way to render graphics in C# beyond GDI+ and XNA?
(For the development of a tile map editor.)
SDL.NET is the solution I've come to love. If you need 3D on top of it, you can use Tao.OpenGL to render inside it. It's fast, industry standard (SDL, that is), and cross-platform.
Yes, I have written a Windows Forms control that wraps DirectX 9.0 and provides direct pixel level manipulation of the video surface.
I actually wrote another post on Stack Overflow asking if there are other better approaches: Unsafe C# and pointers for 2D rendering, good or bad?
While it is relatively high performance, it requires the unsafe compiler option as it uses pointers to access the memory efficiently. Hence the reason for this earlier post.
This is a high level of the required steps:
Download the DirectX SDK.
Create a new C# Windows Forms project and reference the installed
Microsoft DirectX assembly.
Initialize a new DirectX Device object with Presentation Parameters
(windowed, back buffering, etc.) you require.
Create the Device, taking care to record the surface "Pitch" and
current display mode (bits per pixel).
When you need to display something, Lock the backbuffer
surface and store the returned pointer to the start of surface
memory.
Use pointer arithmetic, calculate the actual pixel position in the
data based on the surface pitch,
bits per pixel and the actual x/y pixel coordinate.
In my case for simplicity I am sticking to 32 bpp, meaning setting a pixel is as simple as: *(surfacePointer + (y * pitch + x))=Color.FromARGB(255,0,0);
When finished drawing, Unlock the back buffer surface. Present the surface.
Repeat from step 5 as required.
Be aware that taking this approach you need to be very careful about checking the current display mode (pitch and bits per pxiel) of the target surface. Also you will need to have a strategy in place to deal with window resizing or changes of screen format while your program is running.
Managed DirectX (Microsoft.DirectX namespace) for faster 3D graphics. It's a solid .NET wrapper over DirectX API, which comes with a bit of performance hit for creating .NET objects and marshalling. Unless you are writing a full featured modern 3D engine, it will work fine.
Window Presentation Foundation (WPF) (Windows.Media namespace) - best choice for 2D graphics. Also has limited 3D abilities. Aimed to replace Windows Forms with vector, hardware accelerated resolution-independent framework. Very convenient, supports several flavours of custom controls, resources, data binding, events and commands... also has a few WTFs. Speed is usually faster than GDI and slower than DirectX, and depends greatly on how you do things (seen something to work 60 times faster after rewriting in a sensible way). We had a success implementing 3 1280x1024 screens full of real-time indicators, graphs and plots on a single (and not the best) PC.
You could try looking into WPF, using Visual Studio and/or Expression Blend. I'm not sure how sophisticated you're trying to get, but it should be able to handle a simple editor. Check out this MSDN Article for more info.
You might look into the Cairo graphics library. The Mono project has bindings for C#.
Cairo is an option. I'm currently rewriting my mapping software using both GDI+ and Cairo. It has a tile map generator, among other features.

Categories