// detectMotion.cpp
// Mavis example code, by Robin Hewitt, 2005
//
// Example program for detecting motion. Uses startLookUntilSighted() method.

#include <stdio.h>
#include <windows.h>
#include "../maviscomm.h"

int main(int argc, char** argv)
{
   HINSTANCE      mavisdll         = NULL;
   STARTLOOKPROC  procStartLooking = NULL;
   ObjLoc_t       objLoc;

   // load the dll and get the address for startLookUntilSighted()
   mavisdll = LoadLibrary("mavisclient.dll");
   if(!mavisdll)
   {
      fprintf(stderr, "Can't load mavisclient.dll");
      return -1;
   }
   procStartLooking = (STARTLOOKPROC)GetProcAddress(mavisdll, STARTLOOKPROC_NAME);

   // run motion detector for 30 seconds
   printf("Looking for motion....\n");
   procStartLooking(MOTION_DETECTOR_ID, &objLoc, 30000L);
   if(objLoc.prob)
      printf("Detected motion at %.1f degrees\n",  objLoc.angle);
   else
      printf("No motion detected\n");

   // cleanup
   if(mavisdll) FreeLibrary(mavisdll);

   return 0;
}
Home | Mavis | Example Programs