The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

common.h File Reference

#include <iostream.h>
#include <sys/time.h>
#include <pthread.h>
#include "errno.h"
#include <iostream>

Include dependency graph for common.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

class  nRGBTRIPLE
struct  sMUTEX
struct  tagBITMAPFILEHEADER
struct  tagBITMAPINFOHEADER

Defines

#define BYTE   unsigned char
#define FALSE   0
#define IMAGE_FLIPPED   false
#define MUTEX_LOCK_RETURN_TYPE   int
#define PIXEL_TYPE   BYTE
#define PIXEL_TYPE   BYTE
#define RGBTRIPLE   nRGBTRIPLE
#define THREAD_COND   pthread_cond_t
#define THREAD_RETURN_TYPE   void *
#define THREAD_TYPE   pthread_t
#define TIMETYPE   struct timeval
#define TRUE   1
#define WAIT_ABANDONED   EDEADLK
#define WAIT_FAILED   EINVAL
#define WAIT_OBJECT_0   0
#define WAIT_TIMEOUT   EBUSY

Typedefs

typedef tagBITMAPFILEHEADER BITMAPFILEHEADER
typedef tagBITMAPINFOHEADER BITMAPINFOHEADER
typedef int BOOL
typedef unsigned long DWORD
typedef long LONG
typedef long LONGLONG
typedef sMUTEX MUTEX_TYPE
typedef unsigned short WORD

Functions

void CreateMutex (MUTEX_TYPE &pMutex)
void CreateMutexEvent (THREAD_COND &pCond)
MUTEX_LOCK_RETURN_TYPE LockMutex (MUTEX_TYPE pMutex)
void MutexCondSignal (THREAD_COND pCond)
void MutexCondWait (THREAD_COND &pCond, MUTEX_TYPE &pMutex)
int ReleaseMutex (MUTEX_TYPE pMutex)
MUTEX_LOCK_RETURN_TYPE TryLockMutex (MUTEX_TYPE pMutex, DWORD msec=16)


Define Documentation

#define BYTE   unsigned char
 

Definition at line 25 of file common.h.

Referenced by MPFaceDetectorFilter::Copy(), MPEyeFinderFilter::Copy(), MPColorTrackerFilter::Copy(), MPBlinkDetectorFilter::Copy(), MPImageIO::LoadBitmapPixels(), MPFaceDetectorFilter::Transform(), MPEyeFinderFilter::Transform(), MPColorTrackerFilter::Transform(), MPBlinkDetectorFilter::Transform(), and MPImageIO::WriteBitmap().

#define FALSE   0
 

Definition at line 39 of file common.h.

#define IMAGE_FLIPPED   false
 

Definition at line 128 of file common.h.

Referenced by MPISearchThread::Process(), and MPISearchThread::UpdateColorModel().

#define MUTEX_LOCK_RETURN_TYPE   int
 

Definition at line 118 of file common.h.

Referenced by MPISearchThread::GetColorModel(), MPISearchThread::GetMPIFaceBoxes(), MPISearchThread::GetNumFaces(), LockMutex(), MPISearchThread::PutData(), and TryLockMutex().

#define PIXEL_TYPE   BYTE
 

Definition at line 43 of file common.h.

#define PIXEL_TYPE   BYTE
 

Definition at line 43 of file common.h.

#define RGBTRIPLE   nRGBTRIPLE
 

Definition at line 110 of file common.h.

Referenced by MPFaceDetectorFilter::Copy(), MPEyeFinderFilter::Copy(), MPColorTrackerFilter::Copy(), MPBlinkDetectorFilter::Copy(), MPColorTracker::DoSearch(), MPColorTools::DrawRGBBox(), GreyScaleFlipVideo(), FilterInterface::GreyScaleFlipVideo(), MPColorTools::hilitePixel(), MPHistogramHue::InitColorModel(), MPHistogram< float, NUMBINS >::InitColorModel(), MPISearchThread::MPIBoxPixel(), MPISearchThread::PutData(), MPColorTracker::PutImage(), MPColorTools::RGBtoHSV(), FilterInterface::runInterface(), MPColorTools::setRGBColor(), FilterInterface::ShowBlinkResults(), MPColorTracker::ShowProbs(), and MPISearchThread::UpdateColorModel().

#define THREAD_COND   pthread_cond_t
 

Definition at line 125 of file common.h.

#define THREAD_RETURN_TYPE   void *
 

Definition at line 123 of file common.h.

#define THREAD_TYPE   pthread_t
 

Definition at line 124 of file common.h.

#define TIMETYPE   struct timeval
 

Definition at line 127 of file common.h.

Referenced by MPISearchThread::getCurTime(), MPISearchThread::getElapsedTime(), MPISearchThread::getTimeStamp(), MPColorTracker::GetTimeStamp(), and MPISearchThread::Process().

#define TRUE   1
 

Definition at line 35 of file common.h.

#define WAIT_ABANDONED   EDEADLK
 

Definition at line 121 of file common.h.

Referenced by MPISearchThread::GetMPIFaceBoxes(), and CommThread::PutData().

#define WAIT_FAILED   EINVAL
 

Definition at line 122 of file common.h.

Referenced by MPISearchThread::GetMPIFaceBoxes(), and CommThread::PutData().

#define WAIT_OBJECT_0   0
 

Definition at line 119 of file common.h.

Referenced by MPISearchThread::GetColorModel(), MPISearchThread::GetMPIFaceBoxes(), MPISearchThread::GetNumFaces(), MPISearchThread::PutData(), and CommThread::PutData().

#define WAIT_TIMEOUT   EBUSY
 

Definition at line 120 of file common.h.

Referenced by MPISearchThread::GetMPIFaceBoxes(), and CommThread::PutData().


Typedef Documentation

typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER
 

Referenced by MPImageIO::LoadBitmapHeader(), MPImageIO::LoadBitmapPixels(), and MPImageIO::WriteBitmap().

typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER
 

Referenced by MPImageIO::LoadBitmapHeader(), MPImageIO::LoadBitmapPixels(), and MPImageIO::WriteBitmap().

typedef int BOOL
 

Definition at line 32 of file common.h.

Referenced by MPBlinkDetectorFilter::CanPerformMPBlinkDetectorFilter(), MPColorTrackerFilter::CanPerformMPColorTrackerFilter(), MPEyeFinderFilter::CanPerformMPEyeFinderFilter(), MPFaceDetectorFilter::CanPerformMPFaceDetectorFilter(), MPSocketIO::connectServer(), CVideoDemoApp::InitInstance(), InitInstance(), MPSocketIO::isConnect(), CMainFrame::OnCmdMsg(), and CMainFrame::PreCreateWindow().

typedef unsigned long DWORD
 

Definition at line 112 of file common.h.

Referenced by CommThread::PutData().

typedef long LONG
 

Definition at line 114 of file common.h.

typedef long LONGLONG
 

Definition at line 115 of file common.h.

Referenced by MPFaceDetectorFilter::Copy(), MPEyeFinderFilter::Copy(), MPColorTrackerFilter::Copy(), and MPBlinkDetectorFilter::Copy().

typedef struct sMUTEX MUTEX_TYPE
 

Referenced by CreateMutex(), LockMutex(), MutexCondWait(), ReleaseMutex(), and TryLockMutex().

typedef unsigned short WORD
 

Definition at line 113 of file common.h.


Function Documentation

void CreateMutex MUTEX_TYPE pMutex  )  [inline]
 

Definition at line 194 of file common.h.

References sMUTEX::activation, FALSE, sMUTEX::mutex, and MUTEX_TYPE.

Referenced by CommThread::CommThread(), and MPISearchThread::MPISearchThread().

00194                                              {
00195         pMutex.activation = 0;
00196 #ifdef WIN32
00197         pMutex.mutex = CreateMutex (NULL, FALSE, NULL);
00198 #else
00199         pthread_mutex_init(&pMutex.mutex,NULL);
00200 #endif
00201 }

void CreateMutexEvent THREAD_COND &  pCond  )  [inline]
 

Definition at line 212 of file common.h.

References FALSE, and TRUE.

Referenced by MPISearchThread::MPISearchThread().

00212                                                  {
00213 #ifdef WIN32
00214         pCond = CreateEvent(NULL, TRUE, FALSE, NULL); 
00215 #else
00216         pthread_cond_init(&pCond,NULL);
00217 #endif
00218 }

MUTEX_LOCK_RETURN_TYPE LockMutex MUTEX_TYPE  pMutex  )  [inline]
 

Definition at line 168 of file common.h.

References sMUTEX::activation, sMUTEX::mutex, MUTEX_LOCK_RETURN_TYPE, and MUTEX_TYPE.

Referenced by MPISearchThread::Process(), CommThread::Process(), MPISearchThread::Start(), MPISearchThread::UpdateColorModel(), and CommThread::~CommThread().

00168                                                           {
00169         if(pMutex.activation == 1) {
00170                 std::cout << "error - trying to lock previously locked mutex\n";
00171                 return 0;
00172         }
00173         pMutex.activation = 1;
00174 #ifdef WIN32
00175         return WaitForSingleObject( pMutex.mutex, INFINITE );
00176 #else
00177         return pthread_mutex_lock(&pMutex.mutex);
00178 #endif
00179 }

void MutexCondSignal THREAD_COND  pCond  )  [inline]
 

Definition at line 220 of file common.h.

Referenced by MPISearchThread::PutData().

00220                                                {
00221 #ifdef WIN32
00222         PulseEvent(pCond);
00223 #else
00224         pthread_cond_signal(&pCond);
00225 #endif
00226 }

void MutexCondWait THREAD_COND &  pCond,
MUTEX_TYPE pMutex
[inline]
 

Definition at line 228 of file common.h.

References sMUTEX::mutex, and MUTEX_TYPE.

Referenced by MPISearchThread::Process().

00228                                                                   {
00229 #ifdef WIN32
00230         WaitForSingleObject( pCond, INFINITE );
00231 #else
00232         pthread_cond_wait(&pCond,&pMutex.mutex);
00233 #endif
00234 }

int ReleaseMutex MUTEX_TYPE  pMutex  )  [inline]
 

Definition at line 203 of file common.h.

References sMUTEX::activation, sMUTEX::mutex, and MUTEX_TYPE.

Referenced by MPISearchThread::GetColorModel(), MPISearchThread::GetMPIFaceBoxes(), MPISearchThread::GetNumFaces(), MPISearchThread::Process(), CommThread::Process(), MPISearchThread::PutData(), CommThread::PutData(), MPISearchThread::Start(), and MPISearchThread::UpdateColorModel().

00203                                            {
00204         pMutex.activation = 0;
00205 #ifdef WIN32 
00206         return ReleaseMutex(pMutex.mutex);
00207 #else
00208         return (pthread_mutex_unlock(&pMutex.mutex)==0);
00209 #endif
00210 }

MUTEX_LOCK_RETURN_TYPE TryLockMutex MUTEX_TYPE  pMutex,
DWORD  msec = 16
[inline]
 

Definition at line 183 of file common.h.

References sMUTEX::activation, sMUTEX::mutex, MUTEX_LOCK_RETURN_TYPE, and MUTEX_TYPE.

Referenced by MPISearchThread::GetColorModel(), MPISearchThread::GetMPIFaceBoxes(), MPISearchThread::GetNumFaces(), MPISearchThread::PutData(), and CommThread::PutData().

00183                                                                               {
00184         MUTEX_LOCK_RETURN_TYPE rtn;
00185 #ifdef WIN32
00186         rtn = WaitForSingleObject(pMutex.mutex, msec );
00187 #else
00188         rtn = pthread_mutex_trylock(&pMutex.mutex);
00189 #endif
00190         if (rtn == WAIT_OBJECT_0) pMutex.activation = 1;
00191         return rtn;
00192 }


Generated on Mon Nov 8 17:07:56 2004 for MPT by  doxygen 1.3.9.1