Open Gl Project 6th Sem Hawk Eye by Nasar

download Open Gl Project 6th Sem Hawk Eye by Nasar

of 19

Transcript of Open Gl Project 6th Sem Hawk Eye by Nasar

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    1/19

    HAWK EYE 2010-2011

    CONTENTS

    ABSTRACT i

    ACKNOWLEDGEMENT iii

    LIST OF FIGURES iv

    1. INTRODUCTION 1-3

    1.1 Applications of computer graphics 2

    2. BASIC DRAWING TOOL 4-5

    2.1. OpenGL APIs 4

    2.2. glut.h 4

    2.3. Header files 5

    3. SYSTEM REQUTREMENTS 6-8

    3.1. System Requirements 6

    3.1.1. Hardware requirements 6

    3.1.2. Software requirements 6

    3.1.3. Functional requirements 6

    4. ALGORTTHM 9-125. FLOW OF THE PROGRAM 13

    6. IMPLEMENTATION 14-16

    7. TESTING 17-18

    6.1. System testing 17

    6.2. Types of testing 17

    6.2.1 Unit testing 17

    6.2.2 Integration testing 176.3. Aim and Shoot 17

    8. SNAPSHOTS 19-21

    9. CONCLUTION 22

    10. BIBILIOGRAPHY 23

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    2/19

    HAWK EYE 2010-2011

    INTRODUCTION1.1 OVERVIEW

    The Computer Graphics is one of the most effective and commonly used methods to

    communicate the processed information to the user. It displays the information in the form of graphics

    objects such as pictures, charts, graphs and diagram instead of simple text.

    In computer graphics, pictures or graphics objects are presented as a collection of discrete

    picture elements called pixels . The pixel is the smallest addressable screen element

    Computer graphics today is largely interactive: The user controls the contents structure, and

    appearance of objects and their displayed images by using input devices, such as a keyboard, mouse, or

    touch-sensitive panel on the screen

    Computer graphics concerns with the pictorial synthesis of real or imaginary objects from their computer based models, where as the related field of image processing treats the converse process ,the

    analysis of scenes ,or the reconstruction of models of 2D or 3D objects from their pictures.

    The image processing can be classified as

    Image enhancement.

    Pattern detection and recognition

    Scene analysis and computer vision.

    The image enhancement deals with the improvement in the image quality by eliminating noiseor by increasing image contrast. Pattern detection and recognition deals with the detection and

    clarification of standard patterns

    and finding deviations from these patterns .The optical character recognition (OCR) technology is an

    practical example for pattern detection & recognition. Scene analysis deals with the recognition and

    reconstruction of 3D model of scene from several 2D images.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    3/19

    HAWK EYE 2010-2011

    1.2 ADVANTAGES OF INTERACTIVE GRAPHICS

    It provide a tool for producing pictures not only of concrete, real-world objects but also of

    abstract ,synthesis of objects.

    It as an ability to show moving pictures, and thus it is possible to produce animations.

    With the use of interactive graphics we can control the movement of an object. The interactive

    graphics provides tool called motion dynamics. With this tool user can move and tumble

    objects with respect to stationary observer, or he can make object stationary and the viewer

    moving around them.

    Interactive graphics provides facility called update dynamics.

    With the recent development of digital signal processing (DSP) and audio synthesis chip the

    interactive graphics can now provide audio feed back along with the graphical feed backs to

    make the simulated environment even more realistic

    1.3 AREAS OF APPLICATION OF COMPUTER GRAPHICS

    User interfaces

    Plotting of graphs and charts

    Office automation and Desktop publishing

    Computer aided Drafting and designs

    Process control

    Cartography

    OPENGL PROGRAMMING LANGUAGE:

    As a software interface for graphics hardware, OpenGL's main purpose is to render two- and

    three-dimensional objects into a frame buffer. These objects are described as sequences of

    vertices (which define geometric objects) or pixels (which define images). OpenGL performs

    several processing steps on this data to convert it to pixels to form the final desired image in theframe buffer .

    CHAPTER 2

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    4/19

    HAWK EYE 2010-2011

    BASIC DRAWING TOOLS

    OpenGL APIs

    The various functions are grouped into seven broad categories:

    i. Primitive Functions define the low level objects or atomic entities that our system can

    display. These could be lines, points, polygons, etc.

    ii. Attribute Functions allow us to define the way a primitive appears on the display. Some of

    the operations include choosing the color, picking a pattern to fill, etc.

    iii. The Viewing Functions allow us to specify various views, such as orthogonal views,

    perspective view, etc.

    iv. A set of Transformation Functions are available, that allow the user to carry out

    transformations on objects such as translation, rotating, scaling.

    v. The Input Functions allow interactive applications to deal with a variety of input devices,

    such as keyboard, mouse etc.

    vi. The Control Functions enable us to communicate with the windows system, initialize the

    program and deal with errors.

    vii. The Query Functions can be used to extract other information, such as camera parameters,or values in frame buffer.

    2.1. glut.h

    Most of our applications will be designed to access OpenGL directly through functions in three

    libraries. Functions in the main GL library have names that begin with the letters g/ and are stored in

    a library usually referred as GL.

    The second is the OpenGL Utility Library (GLU). This library uses only GL functions but contains

    code for creating common objects and simplifying viewing.To interface with the window system and

    to get input from external devices into our programs, we need at least one library. For the X window

    system, this library is called GLX, for windows, it is wall etc. GLUT will use GLX and X libraries.

    #include

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    5/19

    HAWK EYE 2010-2011

    OR

    #include

    GLUT is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL

    programs. It implements a simple windowing application programming interface (API) for OpenGL.

    GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides

    a portable API so you can write a single OpenGL program that works across all PC and workstation

    OS platforms.

    GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-

    suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured

    toolkit so large applications requiring sophisticated user interfaces are better off using native window

    system toolkits. GLUT is simple, easy, and small.

    The GLUT library has C, C++ (same as C), FORTRAN, ffid Ada programming bindings. The GLUT

    source code distribution is portable to nearly all OpenGL implementations and platforms. The current

    version is 3.7. Additional releases of the library are not anticipated. GLUT is not open source.

    2.2. HEADER (.h) FILES

    OpenGL is part of Windows XP and the Visual Studio.

    Its header files are

    #include

    #include

    The GLU (GL Utilities) in glu.h refers to a set of utility functions that make some OpenGL operations

    easier to program. It is standard on all OpenGL implementations and is generally thought of as part of standard OpenGL. Both gl.h and glu.h are included in GLUT, so if glut.h is included in the source file,gl.h and glu.h don't need to be explicitly included

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    6/19

    HAWK EYE 2010-2011

    CHAPTER 3

    SYSTEM REQUIREMENTS

    3.1. SYSTEM REQUIREMENTS

    System requirements are intended to communicate in precise way, the functions that the system must

    provide. To reduce ambiguity, they may be written in a structured form of natural language

    supplemented by tables and system models.

    3.1.1. HARDWARE REQUIREMENTS

    The physical components required are:

    Processor - Pentium Pro Memory - 128M8 RAM

    40GB Hard Disk Drive

    Mouse or other pointing device

    Keyboard

    3.1.2. SOFTWARE REQUIREMENTS

    The software used in building this program are as specified:- Operating system - Windows XP

    Microsoft Visual C++ editor.

    Compiler - C++ Compiler.

    Graphics Library - glut.h

    OpenGL 2.0

    3.1.3. FUNCTIONAL REQUIREMENTS

    glMatrixMode(Glenum mode)

    Specifies which matrix will be affected by subsequent transformation.

    GL_MODELVIEW, GL_PROJECTION.

    glPushMatrix( ), glPopMatrix( )

    Pushes to and pops from matrix stack corresponding to the current matrix mode.

    glTranslate[fd]( TYPE x, TYPE y, TYPE z)Multiplies the current matrix by a matrix that moves an object by the given x, y, z values.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    7/19

    HAWK EYE 2010-2011

    glScale[fd] (TYPE x, TYPE y, TYPE z)

    Multiplies the current matrix by a matrix that scales an object by the given x, y, z values, along

    x, y, z axes respectively.

    glFlush ( )

    Forces any buffered OpenGl commands to execute.

    glViewport (TYPE x, TYPE y, TYPE w, TYPE h)

    Sets the lower left corner of the viewport - of width w and height h, to(x, y).

    gluOrtho2D (TYPE left, TYPE right, TYPE bottom, TYPE top)

    This sets the world window, which is bounded by left, right, bottom and top.

    void glutInit( )

    It initializes GLUT.

    void glutlnitDisplayMode( ) - It requests a display with the properties in mode.

    void glutCreateWindow( ) - It creates a window on the display.

    void glutMainloop( ) - It causes the program to enter an event processing loop.

    void glutPostRedisplay( ) - It requests that the display callback be to be executed after the cur-

    rent callback returns.

    void glutDisplayFunc( ) - It registers the display function that is executed when the window

    needs to be redrawn.

    void glutKeyboardFunc( ) - It registers the keyboard callback function.

    void glutCreateMenu( ) - It creates a new menu.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    8/19

    HAWK EYE 2010-2011

    void glEnable( ) - It enables an openGl feature.

    void glDisable( ) - It disables an openGl feature.

    void glutBitmapCharacter( ) - it renders the character in the named bitmap font.

    void glRasterPos( ) - it is used to position pixel and bitrnap write operation

    void glFlush( ) - forces any buffered openGl commands to execute.

    void glViewport( ) - it specifies viewing volume for window co-ordinates

    void glPushMatrix( ) - It pushes to the stack corresponding to the current matrix.

    void glPopMatrix( ) - It pops from the stack corresponding to the current matrix.

    void glClearColor( ) - It sets the present RGB clearing the color buffer.

    void glBegin( ) - It initiates new primitive and vertices.

    void glEnd( ) - It terminates a list of vertices'

    void glClear( ) - It clears the buffers.

    CHAPTER 4

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    9/19

    HAWK EYE 2010-2011

    ALGORITHM

    STEP 1: Start

    STEP 2: Initialize all arrays and variables

    STEP 3: Declare the positions of the ball

    STEP 4: Initialize the flags.

    STEP 5: Declare the messages to be displayed on the window.

    void display( ):

    STEP 6: Specifies the vertices to draw the boundaries, ground, pitch, stumps on either side, bails and

    and lbw strips.

    void spindispaly( ):

    STEP 7: Move the ball on the x-co ordinate & y-co ordinate before pitching.

    void spindisplayy( ):

    STEP 8: Movement of the ball on the x-co ordinate & y-co ordinate after pitching for straight

    deliveries.

    STEP 9: If the ball matches the co ordinates of the lbw strip make bail disappear.

    STEP 10: If the ball donot matches the co ordinates of the lbw strip, it travels straight.

    void spindisplayyy( ):

    STEP 11: Movement of the ball on the x-co ordinate & y-co ordinate after pitching for inswing or

    offspin deliveries.

    STEP 12: If the ball matches the co ordinates of the lbw strip make bail disappear.

    STEP 13: If the ball donot matches the co ordinates of the lbw strip, it travels straight.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    10/19

    HAWK EYE 2010-2011

    void spindisplayyy( ):

    STEP 14: Movement of the ball on the x-co ordinate & y-co ordinate after pitching for outswing and

    legspin.

    STEP 15: If the ball matches the co ordinates of the lbw strip make bail disappear.

    STEP 16: If the ball donot matches the co ordinates of the lbw strip, it travels straight.

    void mouse( ):

    STEP 17: If pressed RIGHT MOUSE BUTTON to move the ball

    STEP 18: If pressed LEFT MOUSE BUTTON to stop the ball

    void keyboard( ):

    STEP 17: If pressed key is s/S, ball goes Straight.

    STEP 18: If pressed key is i/I, ball Inswing or Offspin

    STEP 19: If pressed key is o/O, ball Outswing or Legspin

    void main( ):

    STEP 20: Initializes the count and argument variables using glutInit(argc,argv) functions.

    STEP 21: Set the color buffer to RGB mode, initializes the depth buffer and double buffer.

    STEP 22: Set the window size and position for the display window.

    STEP 23: Register display, keyboard, mouse, reshape, idle callback functions and call the menu

    functions.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    11/19

    HAWK EYE 2010-2011

    STEP 24: Enter event processing loop.

    STEP 25: Stop.

    CHAPTER 5

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    12/19

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    13/19

    HAWK EYE 2010-2011

    7.1. SYSTEM TESTING

    Testing is the process of executing a program to find the errors. A good test has the high probability of

    finding a yet undiscovered error.A test is vital to the success of the system. System test makes a logicalassumption that if all parts of the system are correct, then goal will be successfully achieved.

    7.2 . TYPES OF TESTING

    The types of testing are as follows:

    7.2.1. UNIT TESTING

    In computer programming, unit testing is a method by which individual units of source codeare tested to determine if they are fit for use. A unit is the smallest testable part of an

    application .

    7.2.2. INTEGRATION TESTING

    Integration testing (sometimes called Integration and Testing, abbreviated "I&T") is the phase

    in testing in which individual modules are combined and tested as a group. It occurs after unit

    testing and before system testing. Integration testing takes as its input modules that have been

    unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to

    those aggregates, and delivers as its output the integrated system ready for system testing.

    7.3. HAWK EYE

    The designed HAWK-EYE is to show how the LBW(leg before the wicket)can be simulatedusing the Computer graphics. The HAWK-EYE is interfaced with the MOUSE. We are usingthe different BUTTONS for working of the HAWK-EYE. The HAWK-EYE can JUDGE the

    ball pitched inside the yellow zone or not. This HAWK-EYE is a simple and very basicdemonstration of the application of computer graphics. Therefore, as a whole, this is a simpleand useful demonstration for developing the interest in the graphics field of computers.

    CHAPTER 6

    IMPLEMENTATION

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    14/19

    HAWK EYE 2010-2011

    The project is implemented using various user defined functions which are described below:

    Sprint() -This function will print the characters of font size 24

    Sprint12 ()-This function will print the characters of font size 12

    Printhelvetica18 ()-This function will print the characters of font size 18

    display ()-This function will display the different shapes of polygon which will form the

    boundaries, LBW reference line, crease, wickets of striker side and non-sticker side, bails of

    sticker side and non-striker side, pitch.

    spindisplay ()-Start pitching the ball.

    spindisplayy ()-Displays the movement of the straight ball.

    spindisplayyy ()-Displays the movement of the In swing ball.

    spindisplayyyy ()-Displays the movement of the Out swing ball.

    credit ()- Contains the information about the Instructor and the Programmers.

    dispmen ()-Displays the main menu.

    keyboard ()-Controls the swing of the ball.

    keyboardmenu ()-Specifies the keys for the main menu.

    keycredit ()-Specifies the backspace option to go back to menu from Credits.

    keysplmain ()-Specifies the arrow keys function, to point to the options.

    Mouse ()-This function has mouse button facilities.

    Init ()-This function displays the Orthogonal view

    CHAPTER 8

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    15/19

    HAWK EYE 2010-2011

    SNAPSHOTS

    Fig8.1 Main Menu

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    16/19

    HAWK EYE 2010-2011

    Fig8.2 Ball before pitching

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    17/19

    HAWK EYE 2010-2011

    Fig 8.3 Ball after Pitching

    CHAPTER 9

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    18/19

    HAWK EYE 2010-2011

    CONCLUSION

    This project was implemented using OpenGL. This project provides us the information about

    various features of a hawk eye. This project also helps us to analyze how we can use the

    different standard functions for creating the animated objects and can be used for making a

    gaming package. This package is very useful for the users since it provides the basic

    information about various OpenGL functions used for hawk eye.

    This product has been demonstrated to fulfill the requirements. The functionality of all the

    modules and the module level integration is found to be satisfactory.

    DEPARTMENT OF CSE VEMANA INSTITUTE OF TECHNOLOGY

  • 8/2/2019 Open Gl Project 6th Sem Hawk Eye by Nasar

    19/19

    HAWK EYE 2010-2011

    BIBILIOGRAPHY

    REFERENCE BOOKS

    Interactive computer graphics: A top-down approach using OpenGL (2008)

    Edward angel, Pearson Education India.

    Computer graphics: using OpenGL( 2006)

    Francis S Hill, Stephen M Kelly, Pearson Prentice Hall

    OpenGL programming guide: The official guide to learning OpenGL,

    versions 3.0 and 3.1 (2010)

    Dave Shreiner, Addison Wesley

    WEBSITE REFERENCES

    http://www.opengl.org/sdk/docs/man/

    http://www.opengl.org/documentation/specs/glut/spec3/spec3.html

    http://glprogramming.com/

    http://www.rodedev.com/tutorials/gamephysics/

    http://freeglut.sourceforge.net/docs/api.php

    http://www.videotutorialsrock.com/opengl_tutorial/

    http://www.gamedev.net/

    http://www.opengl.org/resources/faq/technical/glut.htm

    http://www.go4expert.com/forums/