Home Tags Posts tagged with "tutorial"

tutorial

Hi Guys, this time I am back with some Android Game Development. I got this idea after, the popular game Flappy Bird. Hope all may have tried that game…!
Ok, so I wanted to develop a game and I did some researches and found out that there are a lot of Game engines out there. Some of them are COCOS2D, AndEngine, libGDX and many others. In this article I’ll guild you using AndEngine which is a bit easier one. In future I’ll write on libGDX.

Assumption : I assume that you guys know how to install eclipse development environment, configure java path and install Android plugin to eclipse. This post does not cover all those basic steps.

Advise : As this is a kind of a crash course, its advisable to create files the same name as I use(But it is not mandatory).

Expected Outcome : You will be able to create some lines using the AndEngine

Step 1
Download the Source(library) for the AndEngine using this link and extract

https://github.com/nicolasgramlich/AndEngine

Step 2
Create a new project and when creating select ‘Android Project from Existing Code’ and in it select the folder that we extracted in the Step1.
existing code

This is a library project. Actually this library is the ANDENGINE.
libraryproject

You can check it by right clicking on the project we created now and going to the Android tab. You can see the ‘Is Library’ check box ticked.

Step 3
Now create a new Android project and un tick the create activity. Because we are going to create AndEngine activity using the library project we created above.
createactivity

Step 4
Now you have a project with empty src folder. Right click on that folder and create a new package when naming the package use the package name available in that project ManifestFile
packagename

In my case package name is ‘”com.batz.andengsample”‘

Step 4
Now in side the empty package Download or copy the code and create LineEample.java activity using this LineExample Source Code.

You will get some errors, but don’t worry we will fix it in the next step.

Step 5
So now in your project, right click and go to Android tab and there in the below section(library section), click on the add button and select the AndEngine project and press ok. And then press Apply.
add library

Now all the errors may have gone. Some times you will have errors on the package name, if you have used your own name. So for that, click on the package name that shows as error, click ctrl key +1 key , which will bring suggestion to create a package name according to yours, and click on it to create it. And hopefully all the bugs will be fixed.

Step 6
Before going for the app launch, we have to do one more important thing, we have to specify the activity we created now in the manifest file as a launcher

So go to the manifest file and add these lines between the application tags

<activity
android:name=”.LineExample”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
manifest

LineExample is the name I gave for the activity we created, so in your one don’t forget to change that

Step 7
Now you are ready to run the app. So while you are in the the activity try running the app. it should bring a screen where you will see lots of random lines.

Step 8(For people getting error saying cannot find andengine.apk)
For some people the AndEngine folder is not getting added as library on the time of building the app. So at that point what you can do is copy the andengine.jar file from the AndEngine project libs folder and copy it into your projects’s libs folder. And right click on the newly added andengine.jar file and click on ‘Add to Build Path’ option. This is how the project structure looks after I added the jar to my project from the AndEngine project in the Step8

projectstructure

AndEngine Resources : http://www.andengine.org/

For people who got more time , for people who needs more detailed instruction on the same project guild please watch this tutorial video
Development Reference : http://www.youtube.com/watch?v=Q0kjiIH6u-M

Thank You
-Batz-

Reference:  – http://pathofacoder.com/2014/03/04/lets-try-android-game-development-with-andengine/

35427

Hello everyone! Welcome to my very first article on diGit. In this article, we will look at how to perform Optical Character Recognition (OCR) in C#.

For this we will use Puma.net library which makes our task much easier. You can download it from CodePlex, which hosts Open Source Projects.

After downloading, run the downloaded file and install it in your machine. I will illustrate this to you by using a small WPF application. After installing Puma .Net go to the “Assemblies” folder in the installation location. Usually they are in C:\Program Files (x86)\Puma.NET\Assemblies (in a 64-bit machine).

You should see three DLL(Dynamic-Link Library or .dll) files as follows.

Figure (a)

Figure (a)

Next go to the properties of the”COM Server” folder which resides at C:\Program Files (x86)\Puma.NET

Go to the security tab and click edit.

Figure (b)

Figure (b)

And make sure you have given full control for the current user.

Next open Visual Studio (I am using 2012 version) and go to File=> new=> project

Figure (c)

Figure (c)

Under “Windows” category choose “WPF Application” and under “Name” give a name for your application and click  OK.

 Right click on your project and select “Add Reference” and go to “Browse” section.

Figure (d)

Figure (d)

Click on “Browse” and locate the” Puma.Net.dll” file which resides in C:\Program Files (x86)\Puma.NET\Assemblies  (in 64-bit machine) and click OK.

Right click on your project  and select “Rebuild”.  After rebuild completes right click on the project again and select “open folder in file explorer”. Go to Bin => Debug and you must  have  “Puma.Net.dll” , and “puma.interop.dll” files inside that folder. From the location in figure (a) you must copy “dibapi.dll” file into this location. Now your Debug folder must have the following content:

Figure (e)

Figure (e)

Now go to “MainWindow.xaml ” in our WPF Application and create an interface like the following by simply using the items in the toolbox.

Figure (f)

Figure (f)

The first  File Selector is used to select the source image file. We can get the output of the OCR as a string or we can directly write it into a file. The second file selector is used to select the destination file for the second scenario.

So now let’s look at the code written in event handlers.

 First let’s consider the click event of the “Select Source” button.

Figure (g)
Figure (g)

Here I have created an object from the “OpenFileDialog” class which helps us to locate the source image that we use to read. The “ShowDialog()” method in this class will open a file chooser window and it returns a boolean value which indicates whether a file has been selected or not. And I have taken the path of the selected file using the “FileName” property and set it into the first TextBox in Figure (f).

Now let’s consider the actions caused by the click event of the “Read to screen” button

Figure (h)
Figure (h)

Here we are creating an object from the “PumaPage” class and we have to pass the path of the source image file which we got in the previous step into the constructor of this object. And then we can set the output format we want (line 54), and set the language which is used in the source image(line 55). Using the “RecongnizeToString()” method we can take the output of the reading into a string. I have applied that string into a “TextBlock”  in our MainPage.xaml. Finally I have called the “Dispose()” method so this PumaPage object will be disposed allowing another PumaPage object to get hold of the source image file.

Here is the code under “SelectDestination” button

Figure (i)
Figure (i)

This has a similar functionality as the “Select Source” button in Figure (g) and it will let us select the destination file where we would like to save the output if we plan to save it in a file. And that path is assigned to the Second TextBox in the MainWindow.xaml page. 

Click event in the “Read to File” button

Figure (j)
Figure (j)

The functionality of this event is similar to “read to screen” in Figure (h). Instead of the “RecongnizeToString()” method we must use the “RecognizeToFile()” method (line 85) and pass the path of the destination file which we got in the previous step, as a parameter.

Before running the application make sure to add a reference to the “System.Drawing” assembly by going to the Reference Manager in the same way we did in Figure (d). Under “Assemblies” section select “FrameWork” and select “System.Drawing ” as shown in below and click OK.

Figure (k)

Figure (k)

This is the image which I will use for recognition:

Figure (l)

Figure (l)

Now let’s run our application by clicking on “Start” button.

This is the result which I got by clicking the “Read to Screen” button after selecting the above source file through “Select Source” button.

Figure (m)

Figure (m)

And we can also use the “Read to File” button after selecting a destination file using the “Select Destination” button.

Figure (n)

Figure (n)

Here is the destination file after the operation:

Figure (o)

Figure (o)

There are some other properties under “PumaPage” class which can be set for much sensitive and thorough recognition, just play around with them a little bit and you will understand their usage and power in no time.

I hope you understood my explanation and learned something new. If you need any further clarifications, please feel free to contact me. And since this is my very first article I very much appreciate your feedback in order to make my future work much beneficial to you all!

Let’s meet again soon with another article.

Take care :)   Happy Coding!!