Identify the face through web camera
still there are problems to be fixed.....
IT For You
Monday, June 9, 2014
Friday, June 6, 2014
OpenCV 2.4.9
2014-6-6
OpenCV 2.4.9
Studying the OpenCV head tracking haarcascade_frontalface_alt2.xml file to track head movement (left /right)
some part of the structure of that XML file
<opencv_storage><haarcascade_frontalface_alt2 type_id="opencv-haar-classifier"><size>20 20</size><stages><_><!-- stage 0 --><trees><_><!-- tree 0 --><_><!-- root node --><feature><rects><_>2 7 16 4 -1.</_><_>2 9 16 2 2.</_></rects><tilted>0</tilted></feature><threshold>4.3272329494357109e-003</threshold><left_val>0.0383819006383419</left_val><right_node>1</right_node></_><_><!-- node 1 --><feature><rects><_>8 4 3 14 -1.</_><_>8 11 3 7 2.</_></rects><tilted>0</tilted></feature><threshold>0.0130761601030827</threshold><left_val>0.8965256810188294</left_val><right_val>0.2629314064979553</right_val></_></_><_><!-- tree 1 --><_><!-- root node --><feature><rects><_>13 6 1 6 -1.</_><_>13 9 1 3 2.</_></rects><tilted>0</tilted></feature><threshold>5.2434601821005344e-004</threshold><left_val>0.1021663025021553</left_val><right_node>1</right_node></_><_><!-- node 1 --><feature><rects><_>4 2 12 8 -1.</_><_>8 2 4 8 3.</_></rects><tilted>0</tilted></feature><threshold>4.4573000632226467e-003</threshold><left_val>0.1238401979207993</left_val><right_val>0.6910383105278015</right_val></_></_><_>
OpenCV 2.4.9
Studying the OpenCV head tracking haarcascade_frontalface_alt2.xml file to track head movement (left /right)
some part of the structure of that XML file
<opencv_storage><haarcascade_frontalface_alt2 type_id="opencv-haar-classifier"><size>20 20</size><stages><_><!-- stage 0 --><trees><_><!-- tree 0 --><_><!-- root node --><feature><rects><_>2 7 16 4 -1.</_><_>2 9 16 2 2.</_></rects><tilted>0</tilted></feature><threshold>4.3272329494357109e-003</threshold><left_val>0.0383819006383419</left_val><right_node>1</right_node></_><_><!-- node 1 --><feature><rects><_>8 4 3 14 -1.</_><_>8 11 3 7 2.</_></rects><tilted>0</tilted></feature><threshold>0.0130761601030827</threshold><left_val>0.8965256810188294</left_val><right_val>0.2629314064979553</right_val></_></_><_><!-- tree 1 --><_><!-- root node --><feature><rects><_>13 6 1 6 -1.</_><_>13 9 1 3 2.</_></rects><tilted>0</tilted></feature><threshold>5.2434601821005344e-004</threshold><left_val>0.1021663025021553</left_val><right_node>1</right_node></_><_><!-- node 1 --><feature><rects><_>4 2 12 8 -1.</_><_>8 2 4 8 3.</_></rects><tilted>0</tilted></feature><threshold>4.4573000632226467e-003</threshold><left_val>0.1238401979207993</left_val><right_val>0.6910383105278015</right_val></_></_><_>
Friday, April 25, 2014
Sprite Animation in simple way
2014-04-25
Introduce a new way to add sprite animations to XNA game class.
here are the code that need for it.
public class Fire
{
Vector2 sposition;
Rectangle spriteAnimateRect;
Texture2D spriteCoin;
int currentFrame = 0;
int frameX = 0;
int frameY = 0;
float timer;
int interval = 100;
public Fire(ContentManager content,Vector2 position)
{
spriteCoin = content.Load<Texture2D>("fire_explosion");
sposition = position;
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(spriteCoin, sposition,spriteAnimateRect, Color.White);
}
public void Update(GameTime gameTime)
{
spriteAnimateRect = new Rectangle(currentFrame + frameX, frameY, 120, 140);
Animate(gameTime);
}
public void Animate(GameTime gameTime)
{
timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds / 2;
if (timer > interval)
{
timer = 0;
currentFrame += 120;
if (currentFrame >1725)
{
currentFrame = 0;
}
}
}
Introduce a new way to add sprite animations to XNA game class.
here are the code that need for it.
public class Fire
{
Vector2 sposition;
Rectangle spriteAnimateRect;
Texture2D spriteCoin;
int currentFrame = 0;
int frameX = 0;
int frameY = 0;
float timer;
int interval = 100;
public Fire(ContentManager content,Vector2 position)
{
spriteCoin = content.Load<Texture2D>("fire_explosion");
sposition = position;
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(spriteCoin, sposition,spriteAnimateRect, Color.White);
}
public void Update(GameTime gameTime)
{
spriteAnimateRect = new Rectangle(currentFrame + frameX, frameY, 120, 140);
Animate(gameTime);
}
public void Animate(GameTime gameTime)
{
timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds / 2;
if (timer > interval)
{
timer = 0;
currentFrame += 120;
if (currentFrame >1725)
{
currentFrame = 0;
}
}
}
Thursday, April 3, 2014
Attention Game 1
Attention Game 1
use NeuroSky mindwave device to control the "bird's velocity".
use NeuroSky mindwave device to control the "bird's velocity".
- basic functionality are ok.
- sounds has to be added.
- attention level indicator has to be added.
Friday, September 20, 2013
Easy way to convert Excel Data to XML file using Java
Easy way to convert
Excel Data to XML file using Java
From the article “Easy
way read Excel sheets through Java Application”
that I post earlier describe a way to read your Excel spread
sheet through a Java application. In my case I want to convert the some data of
my excel sheet into ” XML” file and store it.
What is XML?
- XML stands for Extensible Markup Language
- XML is a markup language much like HTML
- XML was designed to carry data, not to display data
- XML tags are not predefined. You must define your own tags
- XML is designed to be self-descriptive
Simple XML File
<?xml
version="1.0"?>
<person>
<name>Tove</name>
<address>Jani</address>
<phone>Reminder</phone>
<task>Don't forget me this weekend!</task>
</note>
Here is some advantages of XML
- XML uses human, not computer, language. XML is readable and understandable, even by novices, and no more difficult to code than HTML.
- XML is completely compatible with Java™ and 100% portable. Any application that can process XML can use your information, regardless of platform.
- XML is extendable. Create your own tags, or use tags created by others, that use the natural language of your domain, that have the attributes you need, and that makes sense to you and your users.
-
If you want to learn more about xml click here “http://www.w3schools.com/xml/” .Suppose you want to store your selected Excel column data to a XML data.For an example suppose your Excel is like this.Suppose from this Excel if you want to create a XML with <RegNo> and <Name> tags like the following.Here is the program to generate this XML sheetpublic void createStuDetailsXmlNew(final Vector v1) {try {DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();DocumentBuilder docBuilder = docFactory.newDocumentBuilder();1 final Document doc = docBuilder.newDocument();final Element rootElement = doc.createElement("StudentDetails");doc.appendChild(rootElement);2 for (int i = 0; i < v1.size(); i++) {Element student = doc.createElement("student");rootElement.appendChild(student);3 Element id = doc.createElement("RegNo");String rno = (String) v1.elementAt(i);id.appendChild(doc.createTextNode(rno));student.appendChild(id);
4
Element name = doc.createElement("Name");String n = (String) v1.elementAt(++i);name.appendChild(doc.createTextNode(n));student.appendChild(name);}TransformerFactory transformerFactory = TransformerFactory.newInstance();Transformer transformer = transformerFactory.newTransformer();DOMSource source = new DOMSource(doc);success = new File(path)mkdirs();file = new File(path);StreamResult result = new StreamResult(file);transformer.transform(source, result);statust.setText("Completed.");}Catch(Exception Ex){}}Code explanation· This method need the Data to do the task. Therefore you need to provide a data with any form. In this case it is provided as a Vector. Read vector creation according to the excel sheet is explain in the previous article ” Easy way read Excel sheets through Java Application” and it describe how to read the Excel sheet and store that data in a Vector type data structure.· The main element of the XML file is “StudentDetails” and only one <studentDetails> tag is created according to the code. You can customize the <studentDetails> by changing the number 1 location in the code.
· Root <studentDetails> can have any number of <student> tags shown in 2· According to this code in for loop it create <student > tags until the vector has values.· Each <student> have <RegNo> and <Name> shown in 3 and 4· When vector is creating it store data in first record in the bottom and final record in the tom manner. Therefore when getting data back it first give the last record, so you can decide whether you want the stored data in ascending order or descending order by changing the for loop of the above code.· When the for loop is end the final XML is created. Then you have to give the save location , in here I mention it by “path” . You can use your own way to set the path.· Add a file name to the end of your pathExample:- C:\Users\ABC\Desktop\testing.xml· Then the XML is generated in that location.
Subscribe to:
Posts (Atom)