Archive

Archive for May, 2018

Remote #ErrorLogging in C#

rlc

If you are running a C# Application on a client’s machine, and can’t run the debugger on it, then instead of asking your client to send you log files whenever something goes wrong, you can use a remote logging service to record error events, and view them, and even act on them before the client complains.

This example uses RemoteLogCat.com – a logging service designed for Android, but works equally well in C# / .NET. You will need to have an API Key, and store it as a setting as “RemoteLogCat” in your web.config / app.config

public class Logging
{
public static string key = ConfigurationManager.AppSettings[“RemoteLogCat”];
    public static void Log(string channel, string log)
{
var strUrl = “http://www.remotelogcat.com/log.php?apikey={0}&channel={1}&log={2}”;
strUrl = string.Format(strUrl, key, channel, log);
var wc = new WebClient();
wc.DownloadString(strUrl);
}
}
This is then called using
Logging.Log(“MyApp”,”Your Error”)
Advertisements
Categories: Uncategorized

#ImageRecognition #API with REST webservice

ai

Image Recognition API

This Image Recognition API allows images to be tagged with a label to describe the content of the image, and a confidence score percentage to indicate the level of trust in the algorithm’s judgement. View our homepage at http://imagerecognition.apixml.net

Image Recognition Web Service

The API endpoint can be accessed via this url:

http://imagerecognition.apixml.net/api.asmx

It requires an API Key, which can be applied for via this url:

https://goo.gl/7ND8jG

Recognise

The first API endpoint is http://imagerecognition.apixml.net/api.asmx?op=Recognise

It accepts a url to an image, for example “https://www.argospetinsurance.co.uk/assets/uploads/2017/12/cat-pet-animal-domestic-104827-1024×680.jpeg

And returns a result as follows;

<RecogntionResult xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://imagerecognition.apixml.net/”&gt;

<Label>Egyptian cat</Label>

<Confidence>3.63228369</Confidence>

</RecogntionResult>

Urls must be publicly accessible, you cannot use localhost urls, or intranet addresses.

RecogniseFromBase64

The next API Endpoint is http://imagerecognition.apixml.net/api.asmx?op=RecogniseFromBase64

It accepts a base64 encoded string containing the image, you must also provide the image format, such as “jpg”, “png”, “bmp” etc.

It returns a result as follows;

<RecogntionResult xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://imagerecognition.apixml.net/”&gt;

<Label>Egyptian cat</Label>

<Confidence>3.63228369</Confidence>

</RecogntionResult>

OCR Web Service

Optical character recognition converts an image containing text to the text itself, a microsite for this service can be reviewed at http://ocr.apixml.net/ , here, there are two API endpoints exposed

ProcessUrl

Extract text from an image that is available on the internet via a Url. It’s endpoint is here

http://ocr.apixml.net/ocr.asmx?op=ProcessUrl

Urls must be publicly accessible, you cannot use localhost urls, or intranet addresses.

ProcessBase64

Extract text from an image which has been base64 encoded. You also require a file extension (png/jpg/etc) to indicate the format. It’s endpoint is here;

http://ocr.apixml.net/ocr.asmx?op=ProcessBase64

By default, this service will assume a single line of text, rather than a page of text, in order to change this default behavior, or to customise it to your needs, then you can use the “extraArguments” parameter to fine-tune the OCR operation. The full list of these possible parameters are available on http://ocr.apixml.net/

RESOURCES

Contact information

This software is designed by Infinite Loop Development Ltd (http://www.infiniteloop.ie) and is subject to change. If you would like assistance with custom software development work, please contact us below;

  • info@infiniteloop.ie

  • +44 28 71226151

  • Twitter: @webtropy

Categories: Uncategorized

#ImageRecognition in C# using #tensorflow #inception

image recognition

Ever been faced with that situation, where you are confronted with fluffy grey animal, with four legs, whiskers, big ears and you just have no idea what it is ?

Never fear, with Artifical intelligence, you can now tell, with 12% confidence, that this is infact a tabby cat!

Ok, in fairness, what this is going to be used for is image tagging, so that a given image can be tagged based on image contents with no other context. So part of a bigger project.

Anyway,  This is based on EMGU, and the Inception TensorFlow model. Which I have packaged into a web service.

You need to install the following nuget packages

Install-Package Emgu.TF
Install-Package EMGU.TF.MODELS

Then, ensuring your application is running in 64 bit mode (x86 doesn’t cut it!)

Run the code;

Inception inceptionGraph = new Inception(null, new string[] { Server.MapPath(@”models\tensorflow_inception_graph.pb”),
Server.MapPath(@”models\imagenet_comp_graph_label_strings.txt”) });
Tensor imageTensor = ImageIO.ReadTensorFromImageFile(fileName, 224, 224, 128.0f, 1.0f / 128.0f);

float[] probability = inceptionGraph.Recognize(imageTensor);

Where filename is a local image file of our trusty moggie, and the output is an array of floats corresponding to the likelyhood of the image matchine one of the labels in inceptionGraph.labels

The 224, 224 bit is still a bit of dark magic to me, and I’d love someone to explain what those are!

Categories: Uncategorized

Improving .NET #performance with Parallel.For

tuning-performance

If you ever have a bit of code that does this;

var strSoughtUrl = “”
for each url in urls
var blnFoundIt = MakeWebRequestAndFindSomething(url);
if (blnFoundIt)
{
strSoughtUrl = url
}
next

That is to say, loops through a list of Urls, makes a web request to each one, and then breaks when it finds whatever you were looking for –

Then you can greatly improve the speed of the code using Parellel.for to something like this;

var resultCollection = new ConcurrentBag<string>();
Parallel.For(0, urls.Count, (i,loopstate) =>
{
var url = urls[(int)i];
var blnFoundIt = MakeWebRequestAndFindSomething(url);
if (blnFoundIt)
{
resultCollection.Add(url);
loopstate.Stop();
}
});
var strSoughtUrl = resultCollection.ToArray().First()

I have seen this code speeding up from 22 seconds to 5 seconds when searching through about 100 urls, since most of the time spent requesting a url is waiting for another machine to send all it’s data.

This is yet another performance increase for the Car Registration API service! 🙂

Categories: Uncategorized

#OpenSource KBA & Natcode lookup App for iOS in #Swift

690x0w

This app allows German and Austrian users search for German KBA (“Kraftfahrt-Bundesamt”) codes, and Austrian NatCode (“Nationaler Code”) by searching by make and model, or by entering the code in the search box.

There is also an API that allows businesses to obtain this data automatically. If you are interested in the API, please visit our German or Austrian website at http://www.kbaapi.de or http://www.natcode.at

The source code for the app is available (minus the API Keys), at Github: https://github.com/infiniteloopltd/KBA-Natcode/ it’s written in Swift, and it’s the first app we’ve published that’s entirely written natively.

The App itself can be downloaded from iTunes here;

https://geo.itunes.apple.com/us/app/kba-und-natcode/id1378122352?mt=8&uo=4&at=1000l9tW

 

Categories: Uncategorized