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></_></_><_>

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;
                 
                }
             
            }
        }

Thursday, April 3, 2014

Attention Game 1

Attention Game 1

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.