PARP Research Group University of Murcia, Spain


examples/OpenCV/siftDetector/hess/utils.h File Reference

#include "cxcore.h"
#include <stdio.h>
#include <dirent.h>

Go to the source code of this file.

Defines

#define ABS(x)   ( ( x < 0 )? -x : x )

Functions

void fatal_error (char *format,...)
char * replace_extension (const char *file, const char *extn)
char * prepend_path (const char *path, const char *file)
char * basename (const char *pathname)
void progress (int done)
void erase_from_stream (FILE *stream, int n)
int array_double (void **array, int n, int size)
double dist_sq_2D (CvPoint2D64f p1, CvPoint2D64f p2)
void draw_x (IplImage *img, CvPoint pt, int r, int w, CvScalar color)
IplImage * stack_imgs (IplImage *img1, IplImage *img2)
void display_big_img (IplImage *img, char *title)
void vid_view (IplImage **imgs, int n, char *win_name)
int win_closed (char *name)


Detailed Description

Miscellaneous utility functions.

Copyright (C) 2006-2007 Rob Hess <hess@eecs.oregonstate.edu>

Version:
1.1.1-20070913

Definition in file utils.h.


Function Documentation

int array_double ( void **  array,
int  n,
int  size 
)

Doubles the size of an array with error checking

Parameters:
array pointer to an array whose size is to be doubled
n number of elements allocated for array
size size in bytes of elements in array
Returns:
Returns the new number of elements allocated for array. If no memory is available, returns 0 and frees array.

Definition at line 189 of file utils.cpp.

char* basename ( const char *  pathname  ) 

A function that removes the path from a filename. Similar to the Unix basename command.

Parameters:
pathname a (full) path name
Returns:
Returns the basename of pathname.

void display_big_img ( IplImage *  img,
char *  title 
)

Displays an image, making sure it fits on screen. cvWaitKey() must be called after this function so the event loop is entered and the image is displayed.

Parameters:
img an image, possibly too large to display on-screen
title the title of the window in which img is displayed

double dist_sq_2D ( CvPoint2D64f  p1,
CvPoint2D64f  p2 
)

Calculates the squared distance between two points.

Parameters:
p1 a point
p2 another point

Definition at line 215 of file utils.cpp.

void draw_x ( IplImage *  img,
CvPoint  pt,
int  r,
int  w,
CvScalar  color 
)

Draws an x on an image.

Parameters:
img an image
pt the center point of the x
r the x's radius
w the x's line weight
color the color of the x

Definition at line 234 of file utils.cpp.

void erase_from_stream ( FILE *  stream,
int  n 
)

Erases a specified number of characters from a stream.

Parameters:
stream the stream from which to erase characters
n the number of characters to erase

Definition at line 166 of file utils.cpp.

void fatal_error ( char *  format,
  ... 
)

Prints an error message and aborts the program. The error message is of the form "Error: ...", where the ... is specified by the format argument

Parameters:
format an error message format string (as with printf(3)).

Definition at line 33 of file utils.cpp.

char* prepend_path ( const char *  path,
const char *  file 
)

Prepends a path to a filename.

Parameters:
path a path
file a file name
Returns:
Returns a new string containing a full path name consisting of path prepended to file.

Definition at line 88 of file utils.cpp.

void progress ( int  done  ) 

Displays progress in the console with a spinning pinwheel. Every time this function is called, the state of the pinwheel is incremented. The pinwheel has four states that loop indefinitely: '|', '/', '-', '\'.

Parameters:
done if 0, this function simply increments the state of the pinwheel; otherwise it prints "done"

Definition at line 137 of file utils.cpp.

char* replace_extension ( const char *  file,
const char *  extn 
)

Replaces a file's extension, which is assumed to be everything after the last dot ('.') character.

Parameters:
file the name of a file
extn a new extension for file; should not include a dot (i.e. "jpg", not ".jpg") unless the new file extension should contain two dots.
Returns:
Returns a new string formed as described above. If file does not have an extension, this function simply adds one.

Definition at line 61 of file utils.cpp.

IplImage* stack_imgs ( IplImage *  img1,
IplImage *  img2 
)

Combines two images by scacking one on top of the other

Parameters:
img1 top image
img2 bottom image
Returns:
Returns the image resulting from stacking img1 on top if img2

Definition at line 252 of file utils.cpp.

void vid_view ( IplImage **  imgs,
int  n,
char *  win_name 
)

Allows user to view an array of images as a video. Keyboard controls are as follows:

  • Space - start and pause playback
  • Page Up - skip forward 10 frames
  • Page Down - jump back 10 frames
  • Right Arrow - skip forward 1 frame
  • Left Arrow - jump back 1 frame
  • Backspace - jump back to beginning
  • Esc - exit playback
  • Closing the window also exits playback

Parameters:
imgs an array of images
n number of images in imgs
win_name name of window in which images are displayed

int win_closed ( char *  name  ) 

Checks if a HighGUI window is still open or not

Parameters:
name the name of the window we're checking
Returns:
Returns 1 if the window named name has been closed or 0 otherwise




QVision framework. PARP research group, copyright 2007, 2008.