My Video Player
 All Data Structures Files Functions Variables Macros Pages
video_player.c File Reference
#include <highgui.h>
#include <cv.h>
#include <stdio.h>
#include <string.h>
+ Include dependency graph for video_player.c:

Go to the source code of this file.

Data Structures

struct  Field_Area
 Structure to store the top-left and botton-right corner coordinates of various fields & buttons. More...
 

Macros

#define sldr_btn_width   15
 Default value for the Slider Button's width. More...
 
#define sldr_height   10
 Default value for the Slider Button's height. More...
 
#define ctrl_pnl_height   200
 Default value for Control Pannel's height. More...
 
#define p_width   840
 Width of the video player. More...
 
#define scrn_height   480
 Height of the video-display area. More...
 
#define p_height   ( scrn_height + sldr_height + ctrl_pnl_height )
 Height of the video player. More...
 
#define MOUSE_CALLBACK   0
 Alias for function call made by the MOUSE's callback. More...
 
#define OTHER_CALLS   1
 Alias for function call made by any function other than MOUSE's callback or Textbox Editor's function. More...
 
#define EDIT_CALLS   2
 Alias for function call made by functions the edit the textboxes function. This is reserved for future. More...
 
#define STATIC_TEXT   0
 Alias for static-text field. More...
 
#define EDIT_TEXT   1
 Alias for text-box field. More...
 
#define PLAY_BTN   0
 Alias for play button. More...
 
#define PAUSE_BTN   1
 Alias for pause button. More...
 
#define STOP_BTN   2
 Alias for stop button. More...
 
#define STEPUP_BTN   3
 Alias for step-up button. More...
 
#define STEPDOWN_BTN   4
 Alias for step-down button. More...
 
#define BTN_ACTIVE   0
 Alias for an active button. More...
 
#define BTN_INACTIVE   1
 Alias for an inactive button. More...
 

Functions

void resetField (IplImage *image, int text_type)
 Function to reset a given text field. More...
 
void initialize_pnl (char *filename)
 Function to initialise the control pannel. More...
 
int moveSlider (int pos, int call_from)
 Custome slider's callback function. More...
 
void my_mouse_callback (int event, int x, int y, int flags, void *param)
 Mouse's callback function. More...
 
void getButton (IplImage *image, int btn_type, int btn_state)
 Function to get a new button. More...
 
void getSpectrumVert (IplImage *image, CvScalar color1, CvScalar color2)
 Function to vertically color a button. More...
 
void getSpectrumHorz (IplImage *image, CvScalar color1, CvScalar color2)
 Function to horizontaly color a button. More...
 
void draw_triangle (IplImage *image, CvScalar color)
 Function to draw a triangle on a given image. More...
 
void draw_square (IplImage *image, CvScalar color)
 Function to draw a square on a given image. More...
 
void draw_pause (IplImage *image, CvScalar color)
 Function to draw a pause symbol on a given image. More...
 
void draw_stepup (IplImage *image, CvScalar color)
 Function to draw a step-up symbol on a given image. More...
 
void draw_stepdown (IplImage *image, CvScalar color)
 Function to draw a step-down symbol on a given image. More...
 
void fill_color (IplImage *image, CvScalar color)
 Function to fill a symbol with a given color. More...
 
void change_status ()
 Function to change the status message. More...
 
void type_step (char c, int frame_val)
 Function to edit a textbox. More...
 
void resetAllEdits ()
 Function to reset all fields to their previous contents. More...
 
int main (int argc, char **argv)
 

Variables

CvCapture * vid
 Pointer to CvCapture structure. More...
 
IplImage * player
 Pointer to the main image. More...
 
IplImage * pnl
 Pointer to the control-pannel sub-image. More...
 
IplImage * slider
 Pointer to the slider-strip sub-image. More...
 
IplImage * sldr_btn
 Pointer to the slider-button sub-image. More...
 
IplImage * sldr_val
 Pointer to the slider-value static-text sub-image. More...
 
IplImage * oslider
 Pointer to temporary slider-value static-text sub-image. More...
 
IplImage * frame_area
 Pointer to the frame-area sub-image. More...
 
IplImage * frame
 Pointer to the fetched frame sub-image. More...
 
IplImage * old_frame
 Pointer to the previously fetched frame. More...
 
IplImage * cur_frame_no
 Pointer to current frame number static-text. More...
 
IplImage * fps_edit
 Pointer to FPS (Frames Per Second) static-text. More...
 
IplImage * four_cc_edit
 Pointer to FOUR_CC static-text. More...
 
IplImage * status_edit
 Pointer to "Status" static-text. More...
 
IplImage * numFrames
 Pointer to Total Frames static-text. More...
 
IplImage * step_edit
 Pointer to the Step textbox. More...
 
IplImage * play_pause_btn
 Pointer to play/pause button area. More...
 
IplImage * stop_btn
 Pointer to stop button area. More...
 
IplImage * stepup_btn
 Pointer to step_up button area. More...
 
IplImage * stepdown_btn
 Pointer to step_down button area. More...
 
int sldr_start
 Indicates the starting position (frame number) of the slider. More...
 
int sldr_maxval
 The maximum number of frames in the video. More...
 
int step_val = 1
 Step size. More...
 
char line [20]
 Memory to hold any string temporarily. More...
 
char edit_text [20]
 Memory to hold a textbox string temporarily. More...
 
char status_line [15]
 Memory to hold the "status" string. More...
 
char four_cc_str [4]
 Memory to hold the Four Character Code (FOUR_CC). More...
 
double fps
 Frames per second. More...
 
long fourcc_l
 Four Character Code. More...
 
char * fourcc
 Four_CC temporary string. More...
 
int blink_count = 0
 Blinker count. More...
 
int blink_max = 5
 
char blink_char = '|'
 Threshold to toogle the blink_char. More...
 
Field_Area play_pause_btn_area
 The blinking character, toogled with an underscore (_). More...
 
Field_Area stop_btn_area
 Stop Button coordinates. More...
 
Field_Area stepup_btn_area
 Step Up Button coordinates. More...
 
Field_Area stepdown_btn_area
 Step Down Button coordinates. More...
 
Field_Area fps_edit_area
 FPS static-text coordinates. More...
 
Field_Area four_cc_edit_area
 FOUR_CC static-text coordinates. More...
 
Field_Area status_edit_area
 Status string coordinates. More...
 
Field_Area step_edit_area
 Step textbox coordinates. More...
 
bool sldr_moving = false
 Ture when slider is moving. More...
 
bool playing = false
 True when the video is being played. More...
 
bool processing = false
 True when some processing is carried out. More...
 
bool typing_step = false
 True when any textbox value is being edited. More...
 
bool blinking = false
 True when blinking character is set. More...
 
CvScalar red = cvScalar( 0, 0, 255 )
 Red color. More...
 
CvScalar green = cvScalar( 0, 255, 0 )
 Green color. More...
 
CvScalar blue = cvScalar( 255, 0, 0 )
 Blue color. More...
 
CvScalar black = cvScalar( 0, 0, 0 )
 Black color. More...
 
CvScalar white = cvScalar( 255, 255, 255 )
 White color. More...
 
CvScalar light_yellow = cvScalar( 242, 255, 255 )
 Light Yellow color. More...
 
CvScalar yellow = cvScalar( 0, 255, 255 )
 Yellow color. More...
 
CvScalar gray = cvScalar( 242, 242, 242 )
 Gray color. More...
 
CvScalar orange = cvScalar( 0, 242, 255 )
 Orange color. More...
 
CvScalar voilet = cvScalar( 255, 0, 127 )
 Voilet color. More...
 
CvScalar brown = cvScalar( 0, 0, 127 )
 Brown color. More...
 
CvFont font
 Normal font. More...
 
CvFont font_italic
 Italic font. More...
 
CvFont font_bold
 Bold font. More...
 
CvFont font_bold_italic
 Bold Italic font. More...
 
int font_face_italic = CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC
 Font face. More...
 
int font_face = CV_FONT_HERSHEY_SIMPLEX
 Font face. More...
 
double hscale = 0.5
 Font's Horizontal Scale parameter. More...
 
double vscale = 0.5
 Font's Vertical Scale parameter. More...
 
double shear = 0
 Font's Shear parameter. More...
 
int thickness = 1
 Font's Thickness parameter. More...
 
int line_type = 8
 Font's Line-type parameter. More...
 

Detailed Description

File containing the source code of this simple video player.

Definition in file video_player.c.

Macro Definition Documentation

#define BTN_ACTIVE   0

Alias for an active button.

If this value is passed, then the button under consideration is active. Therefore, all the operations on the pressing the button will be possible.

Definition at line 140 of file video_player.c.

#define BTN_INACTIVE   1

Alias for an inactive button.

If this value is passed, then the button under consideration is inactive. Therefore, no operations will be possible on pressing this button i.e. the button's callback function will not be called. Currently, no buttons are inactive during any point of execution. This is reserved for future enhancements in the video player.

Definition at line 146 of file video_player.c.

#define ctrl_pnl_height   200

Default value for Control Pannel's height.

The control pannel is nothing but a sub-image. This value specifies the height of this sub-image. The width is same as that of the player ( the main image displayed on the screen ) width.

Definition at line 49 of file video_player.c.

#define EDIT_CALLS   2

Alias for function call made by functions the edit the textboxes function. This is reserved for future.

If this value is passed, then the function call is made by the functions editing the textboxes (for future use). Curretly, this value is meaningless.

Definition at line 89 of file video_player.c.

#define EDIT_TEXT   1

Alias for text-box field.

If this value is passed, then the text field under consideration is a text-box. Accordingly operations are to be carried out on this text field.

Definition at line 102 of file video_player.c.

#define MOUSE_CALLBACK   0

Alias for function call made by the MOUSE's callback.

If this value is passed, then the function call is made by the MOUSE'S callback function. Sometimes the information about the caller function is required. This alias is easy to remember & is therefore associated to the MOUSE's callback function.

Definition at line 77 of file video_player.c.

#define OTHER_CALLS   1

Alias for function call made by any function other than MOUSE's callback or Textbox Editor's function.

If this value is passed, then the function call is made by any function other than the MOUSE'S callback function or functions editing the textboxes (for future use). Curretly, this value specifies that the call is made from any function other than the MOUSE's callback function.

Definition at line 83 of file video_player.c.

#define p_height   ( scrn_height + sldr_height + ctrl_pnl_height )

Height of the video player.

This value defines the height of the video player i.e. the main image. This height is the addition of the heights of display area, the slider height and the height of the control pannel.

See Also
p_width

Definition at line 69 of file video_player.c.

#define p_width   840

Width of the video player.

This value defines the width of the main image ( player ) displayed on the screen. Various areas like the area of the video being displayed, the different textboxes, etc are actually sub-images of this main image.

See Also
p_height

Definition at line 56 of file video_player.c.

#define PAUSE_BTN   1

Alias for pause button.

If this value is passed, then the button under consideration is pause-button. Accordingly operations are to be carried out on the button area.

Definition at line 115 of file video_player.c.

#define PLAY_BTN   0

Alias for play button.

If this value is passed, then the button under consideration is play-button. Accordingly operations are to be carried out on the button area.

Definition at line 109 of file video_player.c.

#define scrn_height   480

Height of the video-display area.

This value defines the height of the video-display area. This is the area where the actual video frame is displayed. For convinence, every video frame is scaled to $ p\_width \times scrn\_height $ before being displayed.

Definition at line 62 of file video_player.c.

#define sldr_btn_width   15

Default value for the Slider Button's width.

The slider button's width is set using this value.

Definition at line 37 of file video_player.c.

#define sldr_height   10

Default value for the Slider Button's height.

The slider button's height is set using this value.

Definition at line 43 of file video_player.c.

#define STATIC_TEXT   0

Alias for static-text field.

If this value is passed, then the text field under consideration is static-text. Accordingly operations are to be carried out on this text field.

Definition at line 96 of file video_player.c.

#define STEPDOWN_BTN   4

Alias for step-down button.

If this value is passed, then the button under consideration is step-down button. Accordingly operations are to be carried out on the button area.

Definition at line 133 of file video_player.c.

#define STEPUP_BTN   3

Alias for step-up button.

If this value is passed, then the button under consideration is step-up button. Accordingly operations are to be carried out on the button area.

Definition at line 127 of file video_player.c.

#define STOP_BTN   2

Alias for stop button.

If this value is passed, then the button under consideration is stop-button. Accordingly operations are to be carried out on the button area.

Definition at line 121 of file video_player.c.

Function Documentation

void change_status ( )

Function to change the status message.

Definition at line 1405 of file video_player.c.

1405  {
1407  cvPutText( status_edit, status_line, cvPoint( 3, status_edit->height - 8 ), &font, black );
1408 }
CvScalar black
Black color.
Definition: video_player.c:426
void resetField(IplImage *image, int text_type)
Function to reset a given text field.
Definition: video_player.c:952
#define STATIC_TEXT
Alias for static-text field.
Definition: video_player.c:96
IplImage * status_edit
Pointer to "Status" static-text.
Definition: video_player.c:305
char status_line[15]
Memory to hold the "status" string.
Definition: video_player.c:374
CvFont font
Normal font.
Definition: video_player.c:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_pause ( IplImage *  image,
CvScalar  color 
)

Function to draw a pause symbol on a given image.

Function to draw a two parallel rectangles for the pause button. We pass the sub-image where we want to create the pause button and also pass the color which we desire of the button. We first define 2 points for the first rectangle whose coordinates are stored in pt1 and pt2 and a line between these points would be a vertical line. Now we simply draw 5 lines parallel to this line for the first rectangle and also 5 parallel lines for the second rectangle

Parameters
image: The image where we want to place the pause-rectangles
color: The desired color
See Also
cvPoint(), cvLine().

Definition at line 1305 of file video_player.c.

1305  {
1306  int y_start = 3;
1307  int y_end = image->height - y_start;
1308  int dist = 3;
1309  CvPoint pt1, pt2, tmp1, tmp2;
1310  pt1.x = image->width/2;
1311  pt1.y = y_start;
1312  pt2.x = pt1.x;
1313  pt2.y = y_end;
1314  for( int col=0; col<5; col++ ){
1315  tmp1.x = pt1.x + dist + col;
1316  tmp1.y = pt1.y;
1317  tmp2.x = pt2.x + dist + col;
1318  tmp2.y = pt2.y;
1319  cvLine( image, tmp1, tmp2, color );
1320  tmp1.x = pt1.x - dist - col;
1321  tmp1.y = pt1.y;
1322  tmp2.x = pt2.x - dist - col;
1323  tmp2.y = pt2.y;
1324  cvLine( image, tmp1, tmp2, color );
1325  }
1326 }

+ Here is the caller graph for this function:

void draw_square ( IplImage *  image,
CvScalar  color 
)

Function to draw a square on a given image.

Function to draw a square for the stop button. We pass the sub-image where we want to create the stop button and also pass the color which we desire of the button. We first define 4 points for the square whose coordinates are stored in pt1, pt2, pt3 and pt4. Now we simply draw segments to connect these points and finally fill up the square with the desired color.

Parameters
image: The image where we want to place the stop-square
color: The desired color
See Also
cvPoint(), cvRectangle, fill_color.

Definition at line 1285 of file video_player.c.

1285  {
1286  CvPoint pt1, pt2;
1287  pt1.x = 3*image->width/8;
1288  pt1.y = 3;
1289  pt2.x = 5*image->width/8;
1290  pt2.y = image->height - pt1.y;
1291  cvRectangle( image, pt1, pt2, color );
1292  fill_color( image, color );
1293 }
void fill_color(IplImage *image, CvScalar color)
Function to fill a symbol with a given color.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_stepdown ( IplImage *  image,
CvScalar  color 
)

Function to draw a step-down symbol on a given image.

Definition at line 1382 of file video_player.c.

1382  {
1383  CvPoint pt1, pt2, pt3, pt4;
1384  pt1.x = 4*image->width/8;
1385  pt2.x = 6*image->width/8;
1386  pt3.x = pt1.x;
1387  pt4.x = pt2.x;
1388  int y_start = 3;
1389  int y_end = image->height/2 ;
1390  for( int row=y_start; row<=y_end; row++ ){
1391  pt1.x = pt1.x - row + y_start;
1392  pt2.x = pt2.x - row + y_start;
1393  pt1.y = row;
1394  pt2.y = row;
1395  pt3.x = pt1.x;
1396  pt4.x = pt2.x;
1397  pt3.y = image->height - row;
1398  pt4.y = pt3.y;
1399  cvLine( image, pt1, pt2, color );
1400  cvLine( image, pt3, pt4, color );
1401  }
1402 }

+ Here is the caller graph for this function:

void draw_stepup ( IplImage *  image,
CvScalar  color 
)

Function to draw a step-up symbol on a given image.

Definition at line 1359 of file video_player.c.

1359  {
1360  CvPoint pt1, pt2, pt3, pt4;
1361  pt1.x = 2*image->width/8;
1362  pt2.x = 4*image->width/8;
1363  pt3.x = pt1.x;
1364  pt4.x = pt2.x;
1365  int y_start = 3;
1366  int y_end = image->height/2 ;
1367  for( int row=y_start; row<=y_end; row++ ){
1368  pt1.x = pt1.x + row - y_start;
1369  pt2.x = pt2.x + row - y_start;
1370  pt1.y = row;
1371  pt2.y = row;
1372  pt3.x = pt1.x;
1373  pt4.x = pt2.x;
1374  pt3.y = image->height - row;
1375  pt4.y = pt3.y;
1376  cvLine( image, pt1, pt2, color );
1377  cvLine( image, pt3, pt4, color );
1378  }
1379 }

+ Here is the caller graph for this function:

void draw_triangle ( IplImage *  image,
CvScalar  color 
)

Function to draw a triangle on a given image.

Function to draw a triangle for the play button. We pass the sub-image where we want to create the play button and also pass the color which we desire of the button. We first define 3 points for the triangle whose coordinates are stored in pt1, pt2 and pt3. Now we simply draw segments to connect these points and finally fill up the triangle with the desired color.

Parameters
image: The image where we want to place the play-triangle
color: The desired color
See Also
cvPoint(), cvLine(), fill_color.

Definition at line 1261 of file video_player.c.

1261  {
1262  CvPoint pt1, pt2, pt3;
1263  pt1.x = image->width/3;
1264  pt1.y = 3;
1265  pt2.x = pt1.x;
1266  pt2.y = image->height - pt1.y;
1267  pt3.x = 2*pt1.x;
1268  pt3.y = image->height/2;
1269  cvLine( image, pt1, pt2, color );
1270  cvLine( image, pt3, pt2, color );
1271  cvLine( image, pt1, pt3, color );
1272  fill_color( image, color );
1273 }
void fill_color(IplImage *image, CvScalar color)
Function to fill a symbol with a given color.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fill_color ( IplImage *  image,
CvScalar  color 
)

Function to fill a symbol with a given color.

Definition at line 1331 of file video_player.c.

1331  {
1332  bool start_fill = false;
1333  for( int row=0; row<image->height; row++ ){
1334  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
1335  for( int col=0; col<image->width; col++ ){
1336  if(
1337  ( ptr[ col*image->nChannels + 0 ] == color.val[0] ) &&
1338  ( ptr[ col*image->nChannels + 1 ] == color.val[1] ) &&
1339  ( ptr[ col*image->nChannels + 2 ] == color.val[2] )
1340  ){
1341  if( !start_fill ){
1342  start_fill = true;
1343  }
1344  else{
1345  start_fill = false;
1346  break;
1347  }
1348  }
1349  if( start_fill ){
1350  ptr[ col*image->nChannels + 0 ] = color.val[0];
1351  ptr[ col*image->nChannels + 1 ] = color.val[1];
1352  ptr[ col*image->nChannels + 2 ] = color.val[2];
1353  }
1354  }
1355  }
1356 }

+ Here is the caller graph for this function:

void getButton ( IplImage *  image,
int  btn_type,
int  btn_state 
)

Function to get a new button.

Function to get the desired control button, say play, pause, stop, stepup, stepdown. The buttons are nothing but sub-images.

Parameters
image: This is the sub-image for the desired button.
btn_type: Can be any of the following viz. PLAY_BTN, PAUSE_BTN, STOP_BTN, STEPUP_BTN, STEPDOWN_BTN.
btn_state: Can be either BTN_ACTIVE or BTN_INACTIVE. For the time being, only BTN_ACTIVE is used and it is meaningless to pass BTN_INACTIVE.
See Also
IplImage

Definition at line 991 of file video_player.c.

991  {
992  getSpectrumVert( image, voilet, black );
993  if( btn_type==PLAY_BTN ){
994  draw_triangle( image, green );
995  }
996  if( btn_type==STOP_BTN ){
997  draw_square( image, green );
998  }
999  if( btn_type==PAUSE_BTN ){
1000  draw_pause( image, green );
1001  }
1002  if( btn_type==STEPUP_BTN ){
1003  draw_stepup( image, green );
1004  }
1005  if( btn_type==STEPDOWN_BTN ){
1006  draw_stepdown( image, green );
1007  }
1008 }
#define STEPDOWN_BTN
Alias for step-down button.
Definition: video_player.c:133
#define PAUSE_BTN
Alias for pause button.
Definition: video_player.c:115
CvScalar black
Black color.
Definition: video_player.c:426
CvScalar green
Green color.
Definition: video_player.c:424
#define PLAY_BTN
Alias for play button.
Definition: video_player.c:109
#define STOP_BTN
Alias for stop button.
Definition: video_player.c:121
void draw_square(IplImage *image, CvScalar color)
Function to draw a square on a given image.
CvScalar voilet
Voilet color.
Definition: video_player.c:432
void draw_pause(IplImage *image, CvScalar color)
Function to draw a pause symbol on a given image.
void getSpectrumVert(IplImage *image, CvScalar color1, CvScalar color2)
Function to vertically color a button.
#define STEPUP_BTN
Alias for step-up button.
Definition: video_player.c:127
void draw_stepdown(IplImage *image, CvScalar color)
Function to draw a step-down symbol on a given image.
void draw_triangle(IplImage *image, CvScalar color)
Function to draw a triangle on a given image.
void draw_stepup(IplImage *image, CvScalar color)
Function to draw a step-up symbol on a given image.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void getSpectrumHorz ( IplImage *  image,
CvScalar  color1,
CvScalar  color2 
)

Function to horizontaly color a button.

This function is nothing by an implementation of linear interploation horizontally i.e. The color1 is the color of the leftmost row of the sub-image (image) and color2 is the color of the rightmost row of the sub-image. The intermediate colors are calculated using the following formula.

$ X = \frac{B-A}{L} \times l + A $

where,
X : color of the pixel to be determined.
B : Color of the rightmost row.
A : Color of the leftmost row.
l : Distance of the current pixel from the left (i.e. column number).
L : Total number of columns.

Parameters
image: The input sub-image for the button to be colored.
color1: Color of the leftmost row.
color2: Color of the rightmost row.
See Also
IplImage

Definition at line 1084 of file video_player.c.

1084  {
1085  //Color the leftmost and rightmost pixels of each row with with color1 and color2 respectively
1086  for( int row=0; row<image->height; row++ ){
1087  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
1088  for( int chl=0; chl<image->nChannels; chl++ ){
1089  ptr[chl] = color1.val[chl];
1090  ptr[ ( image->width-1 )*image->nChannels + chl ] = color2.val[ chl ];
1091  }
1092  }
1093  //Interploation applied here
1094  //b_a_L => (B-A)/L... (X-A)/l = (B-A)/L :: => X = (((B-A)/L)*l + A)
1095  for( int row=0; row<image->height; row++ ){
1096  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
1097  for( int col=0; col<image->width; col++ ){
1098  for( int chl=0; chl<image->nChannels; chl++ ){
1099  ptr[ col*image->nChannels + chl ] = ( ptr[ ( image->width - 1 )*image->nChannels + chl ] - ptr[ chl ] )*( col/( float )image->width ) + ptr[ chl ];
1100  }
1101  }
1102  }
1103 }
void getSpectrumVert ( IplImage *  image,
CvScalar  color1,
CvScalar  color2 
)

Function to vertically color a button.

This function is nothing by an implementation of linear interploation vertically i.e. The color1 is the color of the topmost row of the sub-image (image) and color2 is the color of the bottom most row of the sub-image. The intermediate colors are calculated using the following formula.

$ X = \frac{B-A}{L} \times l + A $

where,
X : color of the pixel to be determined.
B : Color of the bottommost row.
A : Color of the topmost row.
l : Distance of the current pixel from the top (i.e. row number).
L : Total number of rows.

Parameters
image: The input sub-image for the button to be colored.
color1: Color of the topmost row.
color2: Color of the bottommost row.
See Also
IplImage

Definition at line 1029 of file video_player.c.

1029  {
1030  for( int row=0; row<image->height; row++ ){
1031  //If topmost row is selected
1032  if( row==0 ){
1033  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
1034  for( int col=0; col<image->width; col++ ){
1035  for( int chl=0; chl<image->nChannels; chl++ ){
1036  ptr[ col*image->nChannels + chl] = color1.val[chl];
1037  }
1038  }
1039  }
1040  //If bottommost row is selected
1041  if( row==image->height-1 ){
1042  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
1043  for( int col=0; col<image->width; col++ ){
1044  for( int chl=0; chl<image->nChannels; chl++ ){
1045  ptr[ col*image->nChannels + chl] = color2.val[chl];
1046  }
1047  }
1048  }
1049  }
1050 
1051  //Interpolation is applied
1052  //b_a_L => (B-A)/L... (X-A)/l = (B-A)/L :: => X = (((B-A)/L)*l + A)
1053  for( int row=1; row<image->height-1; row++ ){
1054  uchar *ptr = ( uchar* )( image->imageData );
1055  for( int col=0; col<image->width; col++ ){
1056  for( int chl=0; chl<image->nChannels; chl++ ){
1057  ptr[ row*image->widthStep + col*image->nChannels + chl ] = (
1058  ptr[ ( image->height-1 )*image->widthStep + col*image->nChannels + chl ] - ptr[ col*image->nChannels + chl ] )*(
1059  row/( float )image->height ) + ptr[ col*image->nChannels + chl ];
1060  }
1061  }
1062  }
1063 }

+ Here is the caller graph for this function:

void initialize_pnl ( char *  filename)

Function to initialise the control pannel.

This function is for initializing the control pannel, adding textfields, text and buttons to it. One may learn how to create a sub-image from an existing IplImage. Each sub-image can act as an independent image. The advantage of using sub-image over ROI is that multiple parts of an image can be worked upon simultaneously. You will come to know the importance of sub-image in the following where you will see how text-boxes and buttons are created with the use of sub-images. Lets's start.

In the initial lines you will come across the cvPutText() function. This is used to place text at various parts of the control pannel sub-image. Next you come across are the row and col. These are the starting coordinates where you want to place the textfields or buttons. To create such fields and buttons (which are nothing but sub-images of the control pannel, which is again a sub-image of the video-player), declare the IplImage header using cvCreateImageHeader() using the required dimensions. This will only create the image header and no data is assigned to it. To use this as a sub-image we need to need to make the following assignments.

  1. sub_image->origin = parent_image->origin.
  2. sub_image->widthStep = parent_image->widthStep.
  3. sub_image->imageData = parent_image->imageData + row*sub_image->widthStep + col*sub_image->nChannels.

Now the sub-image can be used as if it were an independent image. Further, for a few operations we need to keep a track of the coordinates of this newly created image. We store them in Field_Area structure of the respective button or text-field using the naming convention as sub_image_area. If the sub-image is a text-field then resetField() function is called. If the sub-image is a button then getButton() function is called.

Parameters
filename: The absolute path of the video file to be played.
See Also
cvPutText(), cvPoint(), cvCreateImageHeader(), resetField(), getButton().

Definition at line 1122 of file video_player.c.

1122  {
1123  int row, col;
1124  cvPutText( pnl, "Step : ", cvPoint( 3, 60 ), &font, black );
1125  cvPutText( pnl, "File : ", cvPoint( 3, 140 ), &font, black );
1126  cvPutText( pnl, filename, cvPoint( 65, 140 ), &font, black );
1127  cvPutText( pnl, "Control Pannel", cvPoint( 3, 15 ), &font_bold_italic, black );
1128  cvPutText( pnl, "FPS : ", cvPoint( 700, 100 ), &font, black );
1129  cvPutText( pnl, "Current Frame : ", cvPoint( 3, 100 ), &font, black );
1130  cvPutText( pnl, "Total Frames : ", cvPoint( 300, 100 ), &font, black );
1131  cvPutText( pnl, "FOURCC : ", cvPoint( 668, 60 ), &font, black );
1132  cvPutText( pnl, "Status : ", cvPoint( 325, 30 ), &font, black );
1133  //Current Frame field
1134  row = 88;
1135  col = 150;
1136  cur_frame_no = cvCreateImageHeader( cvSize( 120, 18), IPL_DEPTH_8U, 3 );
1137  cur_frame_no->origin = pnl->origin;
1138  cur_frame_no->widthStep = pnl->widthStep;
1139  cur_frame_no->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1141  //number of frames field
1142  row = 88;
1143  col = 430;
1144  numFrames = cvCreateImageHeader( cvSize( 120, 18), IPL_DEPTH_8U, 3 );
1145  numFrames->origin = pnl->origin;
1146  numFrames->widthStep = pnl->widthStep;
1147  numFrames->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1149  //Step field
1150  row = 48;
1151  col = 65;
1152  step_edit = cvCreateImageHeader( cvSize( 50, 18), IPL_DEPTH_8U, 3 );
1153  step_edit->origin = pnl->origin;
1154  step_edit->widthStep = pnl->widthStep;
1155  step_edit->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1157  step_edit_area.x1 = col;
1158  step_edit_area.x2 = col + step_edit->width;
1160  step_edit_area.y2 = p_height - ctrl_pnl_height + step_edit->height + row;
1161  sprintf( line, "%d", step_val );
1162  cvPutText( step_edit, line, cvPoint( 3, step_edit->height - 4 ), &font, black );
1163  //FPS field
1164  row = 88;
1165  col = 755;
1166  fps_edit = cvCreateImageHeader( cvSize( 50, 18), IPL_DEPTH_8U, 3 );
1167  fps_edit->origin = pnl->origin;
1168  fps_edit->widthStep = pnl->widthStep;
1169  fps_edit->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1171  fps_edit_area.x1 = col;
1172  fps_edit_area.x2 = col + fps_edit->width;
1174  fps_edit_area.y2 = p_height - ctrl_pnl_height + fps_edit->height + row;
1175  //FOURCC field
1176  row = 48;
1177  col = 755;
1178  four_cc_edit = cvCreateImageHeader( cvSize( 50, 22), IPL_DEPTH_8U, 3 );
1179  four_cc_edit->origin = pnl->origin;
1180  four_cc_edit->widthStep = pnl->widthStep;
1181  four_cc_edit->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1183  four_cc_edit_area.x1 = col;
1184  four_cc_edit_area.x2 = col + four_cc_edit->width;
1187  //Play/Pause button
1188  row = 48;
1189  col = 350;
1190  play_pause_btn = cvCreateImageHeader( cvSize( 60, 18), IPL_DEPTH_8U, 3 );
1191  play_pause_btn->origin = pnl->origin;
1192  play_pause_btn->widthStep = pnl->widthStep;
1193  play_pause_btn->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1195  play_pause_btn_area.x1 = col;
1196  play_pause_btn_area.x2 = col + play_pause_btn->width;
1199  //Stop button
1200  row = 48;
1201  col = 415;
1202  stop_btn = cvCreateImageHeader( cvSize( 60, 18), IPL_DEPTH_8U, 3 );
1203  stop_btn->origin = pnl->origin;
1204  stop_btn->widthStep = pnl->widthStep;
1205  stop_btn->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1207  stop_btn_area.x1 = col;
1208  stop_btn_area.x2 = col + stop_btn->width;
1210  stop_btn_area.y2 = p_height - ctrl_pnl_height + stop_btn->height + row;
1211  //Stepup button
1212  row = 48;
1213  col = 480;
1214  stepup_btn = cvCreateImageHeader( cvSize( 60, 18), IPL_DEPTH_8U, 3 );
1215  stepup_btn->origin = pnl->origin;
1216  stepup_btn->widthStep = pnl->widthStep;
1217  stepup_btn->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1219  stepup_btn_area.x1 = col;
1220  stepup_btn_area.x2 = col + stepup_btn->width;
1223  //Stepdown button
1224  row = 48;
1225  col = 285;
1226  stepdown_btn = cvCreateImageHeader( cvSize( 60, 18), IPL_DEPTH_8U, 3 );
1227  stepdown_btn->origin = pnl->origin;
1228  stepdown_btn->widthStep = pnl->widthStep;
1229  stepdown_btn->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1231  stepdown_btn_area.x1 = col;
1232  stepdown_btn_area.x2 = col + stepdown_btn->width;
1235  //Status Field
1236  row = 18;
1237  col = 395;
1238  status_edit = cvCreateImageHeader( cvSize( 130, 22), IPL_DEPTH_8U, 3 );
1239  status_edit->origin = pnl->origin;
1240  status_edit->widthStep = pnl->widthStep;
1241  status_edit->imageData = pnl->imageData + row*pnl->widthStep + col*pnl->nChannels;
1243  status_edit_area.x1 = col;
1244  status_edit_area.x2 = col + status_edit->width;
1247  sprintf( status_line, "Stopped" );
1248  change_status();
1249 }
Field_Area stepup_btn_area
Step Up Button coordinates.
Definition: video_player.c:407
#define p_height
Height of the video player.
Definition: video_player.c:69
#define STEPDOWN_BTN
Alias for step-down button.
Definition: video_player.c:133
IplImage * step_edit
Pointer to the Step textbox.
Definition: video_player.c:321
CvScalar black
Black color.
Definition: video_player.c:426
void resetField(IplImage *image, int text_type)
Function to reset a given text field.
Definition: video_player.c:952
#define STATIC_TEXT
Alias for static-text field.
Definition: video_player.c:96
IplImage * cur_frame_no
Pointer to current frame number static-text.
Definition: video_player.c:281
IplImage * numFrames
Pointer to Total Frames static-text.
Definition: video_player.c:313
IplImage * fps_edit
Pointer to FPS (Frames Per Second) static-text.
Definition: video_player.c:289
IplImage * stepdown_btn
Pointer to step_down button area.
Definition: video_player.c:354
IplImage * four_cc_edit
Pointer to FOUR_CC static-text.
Definition: video_player.c:297
#define ctrl_pnl_height
Default value for Control Pannel's height.
Definition: video_player.c:49
#define PLAY_BTN
Alias for play button.
Definition: video_player.c:109
#define STOP_BTN
Alias for stop button.
Definition: video_player.c:121
IplImage * stop_btn
Pointer to stop button area.
Definition: video_player.c:338
int x2
x coordinate of the bottom-right corrner.
Definition: video_player.c:155
CvFont font_bold_italic
Bold Italic font.
Definition: video_player.c:439
Field_Area stop_btn_area
Stop Button coordinates.
Definition: video_player.c:406
#define STEPUP_BTN
Alias for step-up button.
Definition: video_player.c:127
IplImage * status_edit
Pointer to "Status" static-text.
Definition: video_player.c:305
Field_Area fps_edit_area
FPS static-text coordinates.
Definition: video_player.c:409
int y2
y coordinate of the bottom-right corrner.
Definition: video_player.c:156
char line[20]
Memory to hold any string temporarily.
Definition: video_player.c:366
int y1
y coordinate of the top-left corrner.
Definition: video_player.c:154
#define EDIT_TEXT
Alias for text-box field.
Definition: video_player.c:102
Field_Area four_cc_edit_area
FOUR_CC static-text coordinates.
Definition: video_player.c:410
Field_Area play_pause_btn_area
The blinking character, toogled with an underscore (_).
Definition: video_player.c:405
void getButton(IplImage *image, int btn_type, int btn_state)
Function to get a new button.
Definition: video_player.c:991
IplImage * play_pause_btn
Pointer to play/pause button area.
Definition: video_player.c:330
Field_Area stepdown_btn_area
Step Down Button coordinates.
Definition: video_player.c:408
char status_line[15]
Memory to hold the "status" string.
Definition: video_player.c:374
void change_status()
Function to change the status message.
#define BTN_ACTIVE
Alias for an active button.
Definition: video_player.c:140
CvFont font
Normal font.
Definition: video_player.c:436
Field_Area step_edit_area
Step textbox coordinates.
Definition: video_player.c:412
int step_val
Step size.
Definition: video_player.c:364
IplImage * pnl
Pointer to the control-pannel sub-image.
Definition: video_player.c:188
IplImage * stepup_btn
Pointer to step_up button area.
Definition: video_player.c:346
Field_Area status_edit_area
Status string coordinates.
Definition: video_player.c:411
int x1
x coordinate of the top-left corrner.
Definition: video_player.c:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

The main function creates the main image and various sub-images that constitute the video player. Once this outline is ready, frames from the video are fetched and displayed on the sub-image denoting the "screen area". Simultaneously, contents of other sub-image (frame number, slider position) are also updated.

Before starting to initialize the various sub-images, the fonts to be used need to be initialized. The fonts are initialized using the cvInitFont() function.

This is followed by the creation of an empty image (which serves as the main image of the player). The player image is created using the various dimensions shown earlier.

Then the control-pannel sub-image is assigned as a part of the main player image.

All the buttons, textboxes, static-texts, etc are initialized.

Above the control-pannel, a sub-image is assigned to be a slider. OpenCV has an inbuilt function cvCreateTrackbar() to create a slider. But the disadvantage with this function is, the slider is placed at either at the top or the buttom of an image in a window. Therefore, to have the slider at a custom location in the window, I created my own slider. Practically, this slider is a sub-image to which I have assigned a mouse_callback function. Setting the ROI to this sub-image was possible, but then simultaneously accessing all the sub-images would not had been possible. Therefore, the slider sub-image is created by first creating the sub-image of the required dimensions and then setting the origin, widthstep to be the same as that of the main image and the imageData to the appropriate value of imageData of the main image. Everytime the slider position is updated, the original slider needs to be restored first and then the new position is to be marked. Therefore, the original slider sub-image is cloned to oslider sub-image. sldr_val sub-image is nothing but a rectangular image at a position derived from the slider's value. Thus, every time the slider's value is updated, the original slider sub-image ( oslider ) is restored, followed by placing the sldr_val sub-image at it appropriate position on the slider.

The main player images needs to be displayed using a Named Window. Using the cvNamedWindow() function we create a display window.

Everytime a mouse action ( move, click, etc ) occurs on the main display window, the events need to be captured and appropriate actions are to be called. For achieveing this task the cvSetMouseCallback() function is used.

Now that we are ready with the video-player's outline, the video file should be loaded. This is achieved using the cvCaptureFromFile() function. The next task is to access various properties of this video and then display them at appropriate locations on the Control Pannel. To access the video properites cvGetCaptureProperty() function is used.

If proper codecs are installed and the video consists of atleast one frame, then cvQueryFrame() should return the initial frame in the video. If no frame is returned then there must be some problem either with the codecs or the video itself. In such a case, the program is halted with an appropriate error message. If everything goes fine, then the currently grabbed frame is stored into old_frame.

Now we come to the task where a frame is grabbed and displayed on the screen. If the player is in play mode ( i.e. player is set to true ) then frames are grabbed sequentially at an interval derived from the FPS value. The grabbed frame is then resized to the screen_area and displayed to the viewes.

Finally, cleaning up is done by destroying all the open windows and releasing all the images and sub-images.

Parameters
argv[1]: Video file path
Return values
0Exit without any problem.
1Early exit with due to some error.

Definition at line 505 of file video_player.c.

505  {
506 
507  //Initialize the font
510  cvInitFont( &font, font_face, hscale, vscale, shear, thickness, line_type );
512  cvInitFont( &font_bold, font_face, hscale, vscale, shear, thickness+1, line_type );
514 
515  //Create the player image
518  player = cvCreateImage( cvSize( p_width, p_height ), IPL_DEPTH_8U, 3 );
519 
520  //Create Control Pannel
523  pnl = cvCreateImageHeader( cvSize( p_width, ctrl_pnl_height ), IPL_DEPTH_8U, 3 );
524  pnl->origin = player->origin;
525  pnl->widthStep = player->widthStep;
526  pnl->imageData = player->imageData + ( p_height - ctrl_pnl_height )*player->widthStep;
527  for( int row=0; row<pnl->height; row++ ){
528  uchar* ptr = ( uchar* )( pnl->imageData + row*pnl->widthStep );
529  for( int col=0; col<pnl->width; col++ ){
530  ptr[ col*pnl->nChannels + 0 ] = 226;
531  ptr[ col*pnl->nChannels + 1 ] = 235;
532  ptr[ col*pnl->nChannels + 2 ] = 240;
533  }
534  }
535  //Add text & buttons
538  initialize_pnl( argv[1] );
539 
540  //create custom slider (non-opencv)
543  slider = cvCreateImageHeader( cvSize( p_width, 10 ), IPL_DEPTH_8U, 3 );
544  slider->origin = player->origin;
545  slider->widthStep = player->widthStep;
546  slider->imageData = player->imageData + ( p_height - sldr_height - ctrl_pnl_height )*player->widthStep;
547  for( int row=0; row<slider->height; row++ ){
548  uchar* ptr = ( uchar* )( slider->imageData + row*slider->widthStep );
549  for( int col=0; col<slider->width; col++ ){
550  ptr[ col*slider->nChannels + 0 ] = 94;
551  ptr[ col*slider->nChannels + 1 ] = 118;
552  ptr[ col*slider->nChannels + 2 ] = 254;
553  }
554  }
555  oslider = cvCloneImage( slider );
556  sldr_btn = cvCreateImage( cvSize( 15, sldr_height ), IPL_DEPTH_8U, 3 );
557  for( int row=0; row<sldr_btn->height; row++ ){
558  uchar* ptr = ( uchar* )( sldr_btn->imageData + row*sldr_btn->widthStep );
559  for( int col=0; col<sldr_btn->width; col++ ){
560  ptr[ col*slider->nChannels + 0 ] = 100;
561  ptr[ col*slider->nChannels + 1 ] = 150;
562  ptr[ col*slider->nChannels + 2 ] = 100;
563  }
564  }
565  sldr_val = cvCreateImageHeader( cvSize( sldr_btn_width, sldr_height ), IPL_DEPTH_8U, 3 );
566  sldr_val->origin = slider->origin;
567  sldr_val->widthStep = slider->widthStep;
568  sldr_val->imageData = slider->imageData;
569  cvCopy( sldr_btn, sldr_val );
570 
571  //display window
575  cvNamedWindow( "Video Player", CV_WINDOW_AUTOSIZE );
576 
577  //install mouse callback
581  cvSetMouseCallback(
582  "Video Player",
584  ( void* )NULL
585  );
586 
587 
588  //load the video
592  vid = cvCaptureFromFile( argv[1] );
593  //check the video
594  if( !vid ){
595  printf( "Error loading the video file. Either missing file or codec not installed\n" );
596  return( 1 );
597  }
598  frame_area = cvCreateImageHeader( cvSize( p_width, scrn_height ), IPL_DEPTH_8U, 3 );
599  frame_area->origin = player->origin;
600  frame_area->widthStep = player->widthStep;
601  frame_area->imageData = player->imageData;
602  fps = cvGetCaptureProperty( vid, CV_CAP_PROP_FPS );
603  sldr_start = cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES );
604  fourcc_l = cvGetCaptureProperty( vid, CV_CAP_PROP_FOURCC );
605  fourcc = ( char* )( &fourcc_l );
606  sprintf( four_cc_str, "%c%c%c%c", fourcc[0], fourcc[1], fourcc[2], fourcc[3] );
607  //printf( "FPS : %f\n", fps );
608  sldr_maxval = cvGetCaptureProperty( vid, CV_CAP_PROP_FRAME_COUNT ); //check this property
609  if( sldr_maxval<1 ){
610  printf( "Number of frames < 1. Cannot continue...\n" );
611  return( 1 );
612  }
613  cvSetCaptureProperty(
614  vid,
615  CV_CAP_PROP_POS_FRAMES,
616  sldr_start
617  );
618  sprintf( line, "%d", sldr_maxval );
619  cvPutText( numFrames, line, cvPoint( 3, numFrames->height - 4 ), &font, black );
620  sprintf( line, "%d", ( int )cvRound( fps ) );
621  cvPutText( fps_edit, line, cvPoint( 3, fps_edit->height - 4 ), &font, black );
622  sprintf( line, "%d", sldr_start );
623  cvPutText( cur_frame_no, line, cvPoint( 3, cur_frame_no->height - 4 ), &font, black );
624  sprintf( line, "%s", four_cc_str );
625  cvPutText( four_cc_edit, line, cvPoint( 3, four_cc_edit->height - 8 ), &font, black );
627 
631  frame = cvQueryFrame( vid );
632  old_frame = cvCloneImage( frame );
633  if( !frame ){
634  printf( "Cannot load video. Missing Codec : %s\n", four_cc_str );
635  return( 1 );
636  }
637  cvShowImage( "Video Player", player );
638 
642  char c;
643  int cur_frame;
644  while( 1 ){
645  if( ( c = cvWaitKey( 1000/fps ) )==27 ){
646  break;
647  }
648  if( !processing ){
649  if( playing ){
650  for( int i = 0; i < ( step_val - 1 ); i++ ){
651  cvQueryFrame( vid );
652  }
653  frame = cvQueryFrame( vid );
654  if( !frame ){
655  playing = false;
656  }
657  else{
658  cvCopy( frame, old_frame );
659  }
660  }
661  //to avoid any negative value of cur_frame
662  while( 1 ){
663  if( ( cur_frame = ( int )cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES ) )>=0 ){
664  break;
665  }
666  //for some unknown reason cvQueryFrame was needed to be called twice to get to the desired frame.
667  frame = cvQueryFrame( vid );
668  cvCopy( frame, old_frame );
669  }
670  //defines the task to be carried out when editing a text-field
671  if( typing_step ){
672  type_step( c, cur_frame );
673  }
674  //this takes care if for some reason the cur_frame overshoots the sldr_maxval.
675  if( cur_frame == ( sldr_maxval-1 ) ){
677  sprintf( status_line, "End reached" );
678  change_status();
679  }
680  cvResize( old_frame, frame_area );
681  //printf( "Current frame : %d\n", cur_frame );
682  moveSlider( cur_frame, OTHER_CALLS );
683  }
684  cvShowImage( "Video Player", player );
685  }
686 
690  //destory window
691  cvDestroyWindow( "Video Player" );
692 
693  //Release image
694  cvReleaseImageHeader( &stepdown_btn );
695  cvReleaseImageHeader( &stepup_btn );
696  cvReleaseImageHeader( &stop_btn );
697  cvReleaseImageHeader( &play_pause_btn );
698  cvReleaseImageHeader( &step_edit );
699  cvReleaseImageHeader( &four_cc_edit );
700  cvReleaseImageHeader( &fps_edit );
701  cvReleaseImageHeader( &numFrames );
702  cvReleaseImageHeader( &cur_frame_no );
703  cvReleaseImageHeader( &pnl );
704  cvReleaseImageHeader( &sldr_val );
705  cvReleaseImageHeader( &slider );
706  cvReleaseImageHeader( &frame_area );
707  cvReleaseImage( &old_frame );
708  cvReleaseImage( &sldr_btn );
709  cvReleaseImage( &oslider );
710  cvReleaseImage( &player );
711 
712  //Release the video
713  cvReleaseCapture( &vid );
714 
715  return( 0 );
721 }
#define sldr_btn_width
Default value for the Slider Button's width.
Definition: video_player.c:37
int thickness
Font's Thickness parameter.
Definition: video_player.c:445
#define p_height
Height of the video player.
Definition: video_player.c:69
void type_step(char c, int frame_val)
Function to edit a textbox.
IplImage * step_edit
Pointer to the Step textbox.
Definition: video_player.c:321
CvScalar black
Black color.
Definition: video_player.c:426
IplImage * slider
Pointer to the slider-strip sub-image.
Definition: video_player.c:202
int line_type
Font's Line-type parameter.
Definition: video_player.c:446
IplImage * cur_frame_no
Pointer to current frame number static-text.
Definition: video_player.c:281
IplImage * numFrames
Pointer to Total Frames static-text.
Definition: video_player.c:313
IplImage * fps_edit
Pointer to FPS (Frames Per Second) static-text.
Definition: video_player.c:289
CvFont font_bold
Bold font.
Definition: video_player.c:438
IplImage * stepdown_btn
Pointer to step_down button area.
Definition: video_player.c:354
bool processing
True when some processing is carried out.
Definition: video_player.c:417
char four_cc_str[4]
Memory to hold the Four Character Code (FOUR_CC).
Definition: video_player.c:375
IplImage * four_cc_edit
Pointer to FOUR_CC static-text.
Definition: video_player.c:297
void initialize_pnl(char *filename)
Function to initialise the control pannel.
int sldr_maxval
The maximum number of frames in the video.
Definition: video_player.c:358
IplImage * frame_area
Pointer to the frame-area sub-image.
Definition: video_player.c:258
#define ctrl_pnl_height
Default value for Control Pannel's height.
Definition: video_player.c:49
#define PLAY_BTN
Alias for play button.
Definition: video_player.c:109
bool playing
True when the video is being played.
Definition: video_player.c:416
int moveSlider(int pos, int call_from)
Custome slider's callback function.
Definition: video_player.c:729
CvCapture * vid
Pointer to CvCapture structure.
Definition: video_player.c:166
IplImage * stop_btn
Pointer to stop button area.
Definition: video_player.c:338
char * fourcc
Four_CC temporary string.
Definition: video_player.c:392
#define p_width
Width of the video player.
Definition: video_player.c:56
double fps
Frames per second.
Definition: video_player.c:381
CvFont font_bold_italic
Bold Italic font.
Definition: video_player.c:439
CvFont font_italic
Italic font.
Definition: video_player.c:437
double vscale
Font's Vertical Scale parameter.
Definition: video_player.c:443
IplImage * oslider
Pointer to temporary slider-value static-text sub-image.
Definition: video_player.c:244
#define OTHER_CALLS
Alias for function call made by any function other than MOUSE's callback or Textbox Editor's function...
Definition: video_player.c:83
long fourcc_l
Four Character Code.
Definition: video_player.c:387
IplImage * sldr_val
Pointer to the slider-value static-text sub-image.
Definition: video_player.c:230
IplImage * sldr_btn
Pointer to the slider-button sub-image.
Definition: video_player.c:216
IplImage * player
Pointer to the main image.
Definition: video_player.c:174
char line[20]
Memory to hold any string temporarily.
Definition: video_player.c:366
int font_face
Font face.
Definition: video_player.c:441
void my_mouse_callback(int event, int x, int y, int flags, void *param)
Mouse's callback function.
Definition: video_player.c:784
void getButton(IplImage *image, int btn_type, int btn_state)
Function to get a new button.
Definition: video_player.c:991
int font_face_italic
Font face.
Definition: video_player.c:440
IplImage * play_pause_btn
Pointer to play/pause button area.
Definition: video_player.c:330
double hscale
Font's Horizontal Scale parameter.
Definition: video_player.c:442
char status_line[15]
Memory to hold the "status" string.
Definition: video_player.c:374
#define sldr_height
Default value for the Slider Button's height.
Definition: video_player.c:43
void change_status()
Function to change the status message.
IplImage * old_frame
Pointer to the previously fetched frame.
Definition: video_player.c:274
bool typing_step
True when any textbox value is being edited.
Definition: video_player.c:418
int sldr_start
Indicates the starting position (frame number) of the slider.
Definition: video_player.c:357
#define BTN_ACTIVE
Alias for an active button.
Definition: video_player.c:140
IplImage * frame
Pointer to the fetched frame sub-image.
Definition: video_player.c:266
CvFont font
Normal font.
Definition: video_player.c:436
int step_val
Step size.
Definition: video_player.c:364
#define scrn_height
Height of the video-display area.
Definition: video_player.c:62
double shear
Font's Shear parameter.
Definition: video_player.c:444
IplImage * pnl
Pointer to the control-pannel sub-image.
Definition: video_player.c:188
IplImage * stepup_btn
Pointer to step_up button area.
Definition: video_player.c:346

+ Here is the call graph for this function:

int moveSlider ( int  pos,
int  call_from 
)

Custome slider's callback function.

Whenever a right-click on our custom-built slider occurs and the mouse is moved over the slider or there is a change in the displayed frame, this function is called.

If the function is called from a mouse event then call_from is set to MOUSE_CALLBACK and corresponding pos indicates the x-coordinate (Cartesian System) of the latest mouse event. The current frame value ( frame_val ) is derived from pos using appropriate scaling.

If this function is called from any other function then call_from is set to OTHER_CALLS and corresponding pos indicates the current frame value which is directly assigned to frame_val.

Again scaling is done so that the slider button can be set to an appropriate location between 0 and (p_width - sldr_btn_width)

Proper care is taken so that frame_val remains an integeral multiple of step_val between 0 and sldr_maxval.

Current frame number is then updated in the control pannel and lastly the slider button is set at its appropriate location on the custom-built slider.

Parameters
posEither the x-coordinate of the latest mouse event on the slider or the current frame number.
call_fromSet to MOUSE_CALLBACK when this function is called from a mouse callback event, else set to OTHER_CALLS.
Returns
frame_val: The current frame number.
See Also
resetField(), cvPutText(), cvCopy()

Definition at line 729 of file video_player.c.

729  {
730  int frame_val;
731  //Scaling to obtain the current frame number
735  float scale = ( sldr_maxval )/( float )( p_width );
736  //printf( "Pos : %d\tScale : %f\n", pos, scale );
737  if( call_from == MOUSE_CALLBACK ){
738  frame_val = cvCeil( scale*pos );
739  }
743  if( call_from == OTHER_CALLS ){
744  frame_val = pos;
745  }
746  //Scaling to set the slider button at an appropriate location between 0 and (p_width - sldr_btn_width)
750  scale = ( p_width - sldr_btn_width )/( float )( sldr_maxval );
751  //printf( "Frame slider : %d\n", frame_val );
752  int new_pos = cvCeil( scale*frame_val );
753  //frame_val should be an integral multiple of step_val
757  if( frame_val%step_val != 0 ){
758  frame_val = step_val*( ( int )frame_val/( int )step_val );
759  }
764  sprintf( line, "%d", frame_val );
765  cvPutText( cur_frame_no, line, cvPoint( 3, cur_frame_no->height - 4 ), &font, black );
766  cvCopy( oslider, slider );
767  sldr_val->imageData = slider->imageData + new_pos*slider->nChannels;
768  cvCopy( sldr_btn, sldr_val );
769  return( frame_val );
776 }
#define sldr_btn_width
Default value for the Slider Button's width.
Definition: video_player.c:37
CvScalar black
Black color.
Definition: video_player.c:426
void resetField(IplImage *image, int text_type)
Function to reset a given text field.
Definition: video_player.c:952
IplImage * slider
Pointer to the slider-strip sub-image.
Definition: video_player.c:202
#define STATIC_TEXT
Alias for static-text field.
Definition: video_player.c:96
IplImage * cur_frame_no
Pointer to current frame number static-text.
Definition: video_player.c:281
int sldr_maxval
The maximum number of frames in the video.
Definition: video_player.c:358
#define p_width
Width of the video player.
Definition: video_player.c:56
IplImage * oslider
Pointer to temporary slider-value static-text sub-image.
Definition: video_player.c:244
#define OTHER_CALLS
Alias for function call made by any function other than MOUSE's callback or Textbox Editor's function...
Definition: video_player.c:83
IplImage * sldr_val
Pointer to the slider-value static-text sub-image.
Definition: video_player.c:230
IplImage * sldr_btn
Pointer to the slider-button sub-image.
Definition: video_player.c:216
char line[20]
Memory to hold any string temporarily.
Definition: video_player.c:366
#define MOUSE_CALLBACK
Alias for function call made by the MOUSE's callback.
Definition: video_player.c:77
CvFont font
Normal font.
Definition: video_player.c:436
int step_val
Step size.
Definition: video_player.c:364

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void my_mouse_callback ( int  event,
int  x,
int  y,
int  flags,
void *  param 
)

Mouse's callback function.

The function is callback for mouse events. Actions to be taken for various mouse events are defined in this function. This function is the 2nd argument to the cvSetMouseCallback() function.

We associate this mouse callback function for events on the custom-built slider as well as on the different fields in the control pannel. Following is the explaination of the various mouse events used in this scenario and their respective actions.

Case1, event = CV_EVENT_MOUSEMOVE i.e. mouse is moved. If the slider button is dragged to a different location, only then this mouse event is to be used to update the frame being displayed. So both conditions viz. the slider is moving ( sldr_moving ) an the mouse coordinates belong to the custom-built slider are checked and accordingly the new frame number is calculated which is also updated in various fields of the player.

Case2, event = CV_EVENT_LBUTTONDOWN i.e. mouse's left button is pressed down. This event indicates some button being pressed ( play, pause, etc or slider button ). The mouse coordinates help to identify the button being pressed. Approproate actions on pressing respective buttons are taken.

Case3, event = CV_EVENT_LBUTTONUP i.e. mouse's left button is released after earlier press. Only the slider-button depends on this event it can be dragged along the slider-strip. Therefore, on this event the slider movement is stopped.

See Also
cvSetMouseCallback() function for
Parameters
event
x
y
flags
param

Definition at line 784 of file video_player.c.

784  {
785  IplImage* image = ( IplImage* )param;
786  switch( event ){
790  case CV_EVENT_MOUSEMOVE: {
791  if( sldr_moving ){
792  // mouse on slider
793  if( ( y > scrn_height ) && ( y <= scrn_height + sldr_height ) ){
794  int cur_frame = moveSlider( x, MOUSE_CALLBACK );
795  if( vid ){
796  cvSetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES, ( double )( cur_frame-1 ) );
797  cvQueryFrame( vid );
798  cvCopy( cvQueryFrame( vid ), old_frame );
799  }
800  }
801  }
802  }
803  break;
807  case CV_EVENT_LBUTTONDOWN: {
808  sldr_moving = true;
809  resetAllEdits();
810  // mouse on slider
811  if( ( y > scrn_height ) && ( y <= scrn_height + sldr_height ) ){
812  int cur_frame = moveSlider( x, MOUSE_CALLBACK );
813  if( vid ){
814  cvSetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES, ( double )( cur_frame-1 + step_val -1 ) );
815  cvQueryFrame( vid );
816  cvCopy( cvQueryFrame( vid ), old_frame );
817  //printf( "Before val : %f\n", cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES ) );
818  }
819  if( !playing ){
820  sprintf( status_line, "Slider moved" );
821  change_status();
822  }
823  }
824  // mouse on play/pause button
825  if(
826  ( y > play_pause_btn_area.y1 ) &&
827  ( y <= play_pause_btn_area.y2 ) &&
828  ( x > play_pause_btn_area.x1 ) &&
829  ( x <= play_pause_btn_area.x2 )
830  ){
831  //printf( "Frame val : %d\n", ( int )cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES ) );
832  if( playing ){
833  playing = false;
835  sprintf( status_line, "Paused" );
836  change_status();
837  }
838  else{
839  playing = true;
841  sprintf( status_line, "Playing" );
842  change_status();
843  }
844  }
845  // mouse on stop button
846  if(
847  ( y > stop_btn_area.y1 ) &&
848  ( y <= stop_btn_area.y2 ) &&
849  ( x > stop_btn_area.x1 ) &&
850  ( x <= stop_btn_area.x2 )
851  ){
852  playing = false;
854  if( vid ){
855  cvSetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES, ( double )( sldr_start-1 ) );
856  cvQueryFrame( vid );
857  cvCopy( cvQueryFrame( vid ), old_frame );
858  }
860  sprintf( status_line, "Stopped" );
861  change_status();
862  }
863  // mouse on stepup button
864  if(
865  ( y > stepup_btn_area.y1 ) &&
866  ( y <= stepup_btn_area.y2 ) &&
867  ( x > stepup_btn_area.x1 ) &&
868  ( x <= stepup_btn_area.x2 )
869  ){
870  int cur_frame = ( int )cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES );
871  //printf( "Frame val : %d\n", cur_frame );
872  if( cur_frame + 1 + step_val - 1 < sldr_maxval ){
873  for( int i=0; i < ( step_val - 1 ); i++ ){
874  cvQueryFrame( vid );
875  }
876  frame = cvQueryFrame( vid );
877  if( frame ){
878  cvCopy( frame, old_frame );
879  }
880  }
881  if( !playing ){
882  sprintf( status_line, "Stepped Up" );
883  change_status();
884  }
885  //printf( "Stepup pressed \n" );
886  }
887  // mouse on stepdown button
888  if(
889  ( y > stepdown_btn_area.y1 ) &&
890  ( y <= stepdown_btn_area.y2 ) &&
891  ( x > stepdown_btn_area.x1 ) &&
892  ( x <= stepdown_btn_area.x2 )
893  ){
894  processing = true;
895  int cur_frame = ( int )cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES );
896  //printf( "Frame val : %d\n", cur_frame );
897  if( cur_frame - 1 - ( step_val - 1 ) >= sldr_start ){
898  moveSlider( ( cur_frame - 1 - ( step_val - 1 ) ), OTHER_CALLS );
899  cvSetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES, ( double )( cur_frame - 1 - ( step_val - 1 ) ) );
900  cvQueryFrame( vid );
901  cvCopy( cvQueryFrame( vid ), old_frame );
902  //printf( "New Frame val : %d\n", ( int )cvGetCaptureProperty( vid, CV_CAP_PROP_POS_FRAMES ) );
903  }
904  if( !playing ){
905  sprintf( status_line, "Stepped Down" );
906  change_status();
907  }
908  processing = false;
909  //printf( "Stepdown pressed \n" );
910  }
911  // mouse on step_edit field
912  if(
913  ( y > step_edit_area.y1 ) &&
914  ( y <= step_edit_area.y2 ) &&
915  ( x > step_edit_area.x1 ) &&
916  ( x <= step_edit_area.x2 )
917  ){
918  sprintf( edit_text, "" );
919  typing_step = true;
920  }
921  }
922  break;
926  case CV_EVENT_LBUTTONUP: {
927  sldr_moving = false;
928  }
929  break;
930  }
939 }
Field_Area stepup_btn_area
Step Up Button coordinates.
Definition: video_player.c:407
#define PAUSE_BTN
Alias for pause button.
Definition: video_player.c:115
bool processing
True when some processing is carried out.
Definition: video_player.c:417
int sldr_maxval
The maximum number of frames in the video.
Definition: video_player.c:358
#define PLAY_BTN
Alias for play button.
Definition: video_player.c:109
bool playing
True when the video is being played.
Definition: video_player.c:416
int moveSlider(int pos, int call_from)
Custome slider's callback function.
Definition: video_player.c:729
CvCapture * vid
Pointer to CvCapture structure.
Definition: video_player.c:166
int x2
x coordinate of the bottom-right corrner.
Definition: video_player.c:155
Field_Area stop_btn_area
Stop Button coordinates.
Definition: video_player.c:406
#define OTHER_CALLS
Alias for function call made by any function other than MOUSE's callback or Textbox Editor's function...
Definition: video_player.c:83
bool sldr_moving
Ture when slider is moving.
Definition: video_player.c:415
int y2
y coordinate of the bottom-right corrner.
Definition: video_player.c:156
int y1
y coordinate of the top-left corrner.
Definition: video_player.c:154
#define MOUSE_CALLBACK
Alias for function call made by the MOUSE's callback.
Definition: video_player.c:77
Field_Area play_pause_btn_area
The blinking character, toogled with an underscore (_).
Definition: video_player.c:405
void getButton(IplImage *image, int btn_type, int btn_state)
Function to get a new button.
Definition: video_player.c:991
IplImage * play_pause_btn
Pointer to play/pause button area.
Definition: video_player.c:330
char edit_text[20]
Memory to hold a textbox string temporarily.
Definition: video_player.c:372
Field_Area stepdown_btn_area
Step Down Button coordinates.
Definition: video_player.c:408
char status_line[15]
Memory to hold the "status" string.
Definition: video_player.c:374
#define sldr_height
Default value for the Slider Button's height.
Definition: video_player.c:43
void change_status()
Function to change the status message.
IplImage * old_frame
Pointer to the previously fetched frame.
Definition: video_player.c:274
bool typing_step
True when any textbox value is being edited.
Definition: video_player.c:418
void resetAllEdits()
Function to reset all fields to their previous contents.
int sldr_start
Indicates the starting position (frame number) of the slider.
Definition: video_player.c:357
#define BTN_ACTIVE
Alias for an active button.
Definition: video_player.c:140
IplImage * frame
Pointer to the fetched frame sub-image.
Definition: video_player.c:266
Field_Area step_edit_area
Step textbox coordinates.
Definition: video_player.c:412
int step_val
Step size.
Definition: video_player.c:364
#define scrn_height
Height of the video-display area.
Definition: video_player.c:62
int x1
x coordinate of the top-left corrner.
Definition: video_player.c:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void resetAllEdits ( )

Function to reset all fields to their previous contents.

Definition at line 1466 of file video_player.c.

1466  {
1468  sprintf( edit_text, "%d", step_val );
1469  cvPutText( step_edit, edit_text, cvPoint( 3, step_edit->height - 4 ), &font, black );
1470  typing_step = false;
1471 }
IplImage * step_edit
Pointer to the Step textbox.
Definition: video_player.c:321
CvScalar black
Black color.
Definition: video_player.c:426
void resetField(IplImage *image, int text_type)
Function to reset a given text field.
Definition: video_player.c:952
#define EDIT_TEXT
Alias for text-box field.
Definition: video_player.c:102
char edit_text[20]
Memory to hold a textbox string temporarily.
Definition: video_player.c:372
bool typing_step
True when any textbox value is being edited.
Definition: video_player.c:418
CvFont font
Normal font.
Definition: video_player.c:436
int step_val
Step size.
Definition: video_player.c:364

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void resetField ( IplImage *  image,
int  text_type 
)

Function to reset a given text field.

This function will reset a text-field ( a textbox or a static text). The text-field is nothing but a sub-image. Therefore all the pixel values are to be reset to the original values of the respecitve text fields (white with black border for EDIT_TEXT and Control Pannel's color with black border for STATIC_TEXT).

Whenever the value in the text-field is changed, the text-field being an image, the new value is overwritten over the old value. Therefore, every time a new value is to be written, the respective field need to be reset.

Parameters
image: The sub-image (i.e. the text-field) to be reset.
text_type: Either STATIC_TEXT or EDIT_TEXT.
See Also
IplImage

Definition at line 952 of file video_player.c.

952  {
953  if( text_type == STATIC_TEXT ){
954  for( int row=0; row<image->height; row++ ){
955  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
956  for( int col=0; col<image->width; col++ ){
957  ptr[ col*image->nChannels + 0 ] = 226;
958  ptr[ col*image->nChannels + 1 ] = 235;
959  ptr[ col*image->nChannels + 2 ] = 240;
960  }
961  }
962  }
963  else{
964  for( int row=0; row<image->height; row++ ){
965  uchar *ptr = ( uchar* )( image->imageData + row*image->widthStep );
966  for( int col=0; col<image->width; col++ ){
967  if( row==0 || row==image->height-1 || col==0 || col==image->width-1 ){
968  ptr[ col*image->nChannels + 0 ] = 0;
969  ptr[ col*image->nChannels + 1 ] = 0;
970  ptr[ col*image->nChannels + 2 ] = 0;
971  }
972  else
973  {
974  ptr[ col*image->nChannels + 0 ] = 255;
975  ptr[ col*image->nChannels + 1 ] = 255;
976  ptr[ col*image->nChannels + 2 ] = 255;
977  }
978  }
979  }
980  }
981 }
#define STATIC_TEXT
Alias for static-text field.
Definition: video_player.c:96

+ Here is the caller graph for this function:

void type_step ( char  c,
int  frame_val 
)

Function to edit a textbox.

Definition at line 1411 of file video_player.c.

1411  {
1413  char temp_text[ 20 ];
1414  int cur_frame;
1415  sprintf( temp_text, "" );
1416  if( blinking ){
1417  if( blink_count<blink_max ){
1418  blink_count++;
1419  }
1420  else{
1421  blinking = false;
1422  blink_char = ' ';
1423  blink_count = 0;
1424  }
1425  //printf( "Blinking...\n" );
1426  }
1427  else{
1428  if( blink_count<blink_max ){
1429  blink_count++;
1430  }
1431  else{
1432  blinking = true;
1433  blink_char = '|';
1434  blink_count = 0;
1435  }
1436  //printf( "Not blinking...\n" );
1437  }
1438  //valid number
1439  if( c>=48 && c<=57 ){
1440  sprintf( temp_text, "%s%c", edit_text, c );
1441  if( ( frame_val + atoi( temp_text ) )>=0 && ( frame_val + atoi( temp_text ) )<=sldr_maxval && ( atoi( temp_text )!=0 ) ){
1442  sprintf( edit_text, "%s", temp_text );
1443  }
1444  }
1445  //backspace
1446  if( c==8 ){
1447  if( strcmp( edit_text, "" )!=0 ){
1448  for( int count=0; count<( strlen( edit_text )-1 ); count++ ){
1449  sprintf( temp_text, "%s%c", temp_text, edit_text[ count ] );
1450  }
1451  sprintf( edit_text, "%s", temp_text );
1452  }
1453  }
1454  sprintf( temp_text, "%s%c", edit_text, blink_char );
1455  cvPutText( step_edit, temp_text, cvPoint( 3, step_edit->height - 4 ), &font, black );
1456  if( c==10 ){
1458  cvPutText( step_edit, edit_text, cvPoint( 3, step_edit->height - 4 ), &font, black );
1459  step_val = atoi( edit_text );
1460  //printf( "Step : %d\n", step );
1461  typing_step = false;
1462  }
1463 }
IplImage * step_edit
Pointer to the Step textbox.
Definition: video_player.c:321
CvScalar black
Black color.
Definition: video_player.c:426
void resetField(IplImage *image, int text_type)
Function to reset a given text field.
Definition: video_player.c:952
int sldr_maxval
The maximum number of frames in the video.
Definition: video_player.c:358
int blink_max
Definition: video_player.c:402
char blink_char
Threshold to toogle the blink_char.
Definition: video_player.c:403
int blink_count
Blinker count.
Definition: video_player.c:400
bool blinking
True when blinking character is set.
Definition: video_player.c:419
#define EDIT_TEXT
Alias for text-box field.
Definition: video_player.c:102
char edit_text[20]
Memory to hold a textbox string temporarily.
Definition: video_player.c:372
bool typing_step
True when any textbox value is being edited.
Definition: video_player.c:418
CvFont font
Normal font.
Definition: video_player.c:436
int step_val
Step size.
Definition: video_player.c:364

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

CvScalar black = cvScalar( 0, 0, 0 )

Black color.

Definition at line 426 of file video_player.c.

char blink_char = '|'

Threshold to toogle the blink_char.

Definition at line 403 of file video_player.c.

int blink_count = 0

Blinker count.

This counter is used to toogle the blinker character blink_char. Whenever this counter crosses blink_max, the blink_char is toogled.

See Also
type_step().

Definition at line 400 of file video_player.c.

int blink_max = 5

Definition at line 402 of file video_player.c.

bool blinking = false

True when blinking character is set.

Definition at line 419 of file video_player.c.

CvScalar blue = cvScalar( 255, 0, 0 )

Blue color.

Definition at line 425 of file video_player.c.

CvScalar brown = cvScalar( 0, 0, 127 )

Brown color.

Definition at line 433 of file video_player.c.

IplImage* cur_frame_no

Pointer to current frame number static-text.

Points to the sub-image showing the current frame number.

See Also
IplImage, initialize_pnl(), moveSlider().

Definition at line 281 of file video_player.c.

char edit_text[20]

Memory to hold a textbox string temporarily.

This will hold a textbox string temporarily. Whenever a textbox is to be used, the original string in the textbox is required while editing its contents. This is the primary use of this memory.

Definition at line 372 of file video_player.c.

CvFont font

Normal font.

Definition at line 436 of file video_player.c.

CvFont font_bold

Bold font.

Definition at line 438 of file video_player.c.

CvFont font_bold_italic

Bold Italic font.

Definition at line 439 of file video_player.c.

int font_face = CV_FONT_HERSHEY_SIMPLEX

Font face.

Definition at line 441 of file video_player.c.

int font_face_italic = CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC

Font face.

Definition at line 440 of file video_player.c.

CvFont font_italic

Italic font.

Definition at line 437 of file video_player.c.

IplImage* four_cc_edit

Pointer to FOUR_CC static-text.

Points to the sub-image showing FOUR_CC static text.

See Also
IplImage, initialize_pnl().

Definition at line 297 of file video_player.c.

Field_Area four_cc_edit_area

FOUR_CC static-text coordinates.

Definition at line 410 of file video_player.c.

char four_cc_str[4]

Memory to hold the Four Character Code (FOUR_CC).

Definition at line 375 of file video_player.c.

char* fourcc

Four_CC temporary string.

An intermediate string to hold the FOUR_CC value while parsing from fourcc_l to four_cc_str.

Definition at line 392 of file video_player.c.

long fourcc_l

Four Character Code.

Hold the FOUR_CC value in double format. This value is directly read from the input video file, parsed to a string (using fourcc) and stored to four_cc_str.

Definition at line 387 of file video_player.c.

double fps

Frames per second.

Frames Per Second value is stored in this variable. This value is read from the input video file.

Definition at line 381 of file video_player.c.

IplImage* fps_edit

Pointer to FPS (Frames Per Second) static-text.

Points to the sub-image showing the FPS. This is currently a static-text field and its value is to be loaded from the video initially. Later, the functionality to edit this field can be added, therefore the pointer has "edit" in its name. It hold the value of fps.

See Also
IplImage, initialize_pnl().

Definition at line 289 of file video_player.c.

Field_Area fps_edit_area

FPS static-text coordinates.

Definition at line 409 of file video_player.c.

IplImage* frame

Pointer to the fetched frame sub-image.

This will point to frame fetched using cvQueryFrame(). Therefore, this pointer is only declared and not defined. The allocation and deallocation of memory pointed by this pointer is handled by cvQueryFrame().

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 266 of file video_player.c.

IplImage* frame_area

Pointer to the frame-area sub-image.

The frame-area sub-image is originally created as an empty image using the cvCreateImage() function. Here the currently fetched frame will be displayed. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this Frame-area sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 258 of file video_player.c.

CvScalar gray = cvScalar( 242, 242, 242 )

Gray color.

Definition at line 430 of file video_player.c.

CvScalar green = cvScalar( 0, 255, 0 )

Green color.

Definition at line 424 of file video_player.c.

double hscale = 0.5

Font's Horizontal Scale parameter.

Definition at line 442 of file video_player.c.

CvScalar light_yellow = cvScalar( 242, 255, 255 )

Light Yellow color.

Definition at line 428 of file video_player.c.

char line[20]

Memory to hold any string temporarily.

Definition at line 366 of file video_player.c.

int line_type = 8

Font's Line-type parameter.

Definition at line 446 of file video_player.c.

IplImage* numFrames

Pointer to Total Frames static-text.

Points to the sub-image showing the Total Number of Frames static-text. It holds the value of sldr_maxval.

See Also
IplImage, initialize_pnl().

Definition at line 313 of file video_player.c.

IplImage* old_frame

Pointer to the previously fetched frame.

The current fetched frame using cvQueryFrame() is cloned to old_frame before fetching the next frame. Thus, this pointer points to an IplImage structure holding the previously fetched frame.

See Also
cvLoadImage(), cvReleaseImage().

Definition at line 274 of file video_player.c.

CvScalar orange = cvScalar( 0, 242, 255 )

Orange color.

Definition at line 431 of file video_player.c.

IplImage* oslider

Pointer to temporary slider-value static-text sub-image.

The temporary slider-value static-text sub-image is originally created as an empty image using the cvCreateImage() function. This is used to temporarily store the original slider-value. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this temporary slider-value static-text sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 244 of file video_player.c.

IplImage* play_pause_btn

Pointer to play/pause button area.

Points to the sub-image having the play / pause button.

See Also
IplImage, initialize_pnl().

Definition at line 330 of file video_player.c.

Field_Area play_pause_btn_area

The blinking character, toogled with an underscore (_).

Play / Pause Button coordinates.

Definition at line 405 of file video_player.c.

IplImage* player

Pointer to the main image.

Pointer to the main image shown on the screen. The various buttons, screen-area etc are sub-images of this image. Initially this image is created as an empty image using the cvCreateImage() function. Later, every sub-image's data part is assigned the desired part of this main image. Now, any further operation on the sub-images reflects the change in this image as well.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 174 of file video_player.c.

bool playing = false

True when the video is being played.

Definition at line 416 of file video_player.c.

IplImage* pnl

Pointer to the control-pannel sub-image.

The control-pannel sub-image is originally created as an empty image using the cvCreateImage() function. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this Control-Pannel sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 188 of file video_player.c.

bool processing = false

True when some processing is carried out.

Definition at line 417 of file video_player.c.

CvScalar red = cvScalar( 0, 0, 255 )

Red color.

Definition at line 423 of file video_player.c.

double shear = 0

Font's Shear parameter.

Definition at line 444 of file video_player.c.

IplImage* sldr_btn

Pointer to the slider-button sub-image.

The slider-button sub-image is originally created as an empty image using the cvCreateImage() function. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this Slider-Button sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 216 of file video_player.c.

int sldr_maxval

The maximum number of frames in the video.

Definition at line 358 of file video_player.c.

bool sldr_moving = false

Ture when slider is moving.

Definition at line 415 of file video_player.c.

int sldr_start

Indicates the starting position (frame number) of the slider.

Definition at line 357 of file video_player.c.

IplImage* sldr_val

Pointer to the slider-value static-text sub-image.

The slider-value static-text sub-image is originally created as an empty image using the cvCreateImage() function. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this Slider-value Static-Text sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 230 of file video_player.c.

IplImage* slider

Pointer to the slider-strip sub-image.

The slider-strip sub-image is originally created as an empty image using the cvCreateImage() function. It is then assigned the following properties of the main image so that it becomes a sub-image ( or region of interest ).

Once this assignment is done, any change in this Slider-strip sub-image, will be reflected directly on the screen.

See Also
IplImage, cvLoadImage(), cvReleaseImage().

Definition at line 202 of file video_player.c.

IplImage* status_edit

Pointer to "Status" static-text.

Points to the sub-image showing the status static-text. Holds the string in status_line.

See Also
IplImage, initialize_pnl().

Definition at line 305 of file video_player.c.

Field_Area status_edit_area

Status string coordinates.

Definition at line 411 of file video_player.c.

char status_line[15]

Memory to hold the "status" string.

Definition at line 374 of file video_player.c.

IplImage* step_edit

Pointer to the Step textbox.

Points to the sub-image showing the Step textbox. This will hold the value of step_val.

See Also
IplImage, initialize_pnl().

Definition at line 321 of file video_player.c.

Field_Area step_edit_area

Step textbox coordinates.

Definition at line 412 of file video_player.c.

int step_val = 1

Step size.

The step size is the distance between the current and the next frame to be fetched. To view the video as it is, every frame has to be displayed. Therefore, by default this value is set to 1.

Definition at line 364 of file video_player.c.

IplImage* stepdown_btn

Pointer to step_down button area.

Points to the sub-image having the step_down button.

See Also
IplImage, initialize_pnl().

Definition at line 354 of file video_player.c.

Field_Area stepdown_btn_area

Step Down Button coordinates.

Definition at line 408 of file video_player.c.

IplImage* stepup_btn

Pointer to step_up button area.

Points to the sub-image having the step_up button.

See Also
IplImage, initialize_pnl().

Definition at line 346 of file video_player.c.

Field_Area stepup_btn_area

Step Up Button coordinates.

Definition at line 407 of file video_player.c.

IplImage* stop_btn

Pointer to stop button area.

Points to the sub-image having the stop button.

See Also
IplImage, initialize_pnl().

Definition at line 338 of file video_player.c.

Field_Area stop_btn_area

Stop Button coordinates.

Definition at line 406 of file video_player.c.

int thickness = 1

Font's Thickness parameter.

Definition at line 445 of file video_player.c.

bool typing_step = false

True when any textbox value is being edited.

Definition at line 418 of file video_player.c.

CvCapture* vid

Pointer to CvCapture structure.

A global pointer to the CvCapture structure is created so that the capture properties can be extracted and edited seamlessly from any of the related functions. CvCapture is basically used to capture the video into the program using the functions cvCaptureFromFile() (for capturing from file) or cvCaptureFromCAM() (for capturing directly from the attached camera). The details of CvCapture structure can be found here.

See Also
cvReleaseCapture().

Definition at line 166 of file video_player.c.

CvScalar voilet = cvScalar( 255, 0, 127 )

Voilet color.

Definition at line 432 of file video_player.c.

double vscale = 0.5

Font's Vertical Scale parameter.

Definition at line 443 of file video_player.c.

CvScalar white = cvScalar( 255, 255, 255 )

White color.

Definition at line 427 of file video_player.c.

CvScalar yellow = cvScalar( 0, 255, 255 )

Yellow color.

Definition at line 429 of file video_player.c.