Commit f4df9954 authored by David Johnson's avatar David Johnson

mezzanine with ipc not webcam changes

parent 3af9b150
This diff is collapsed.
###########################################################################
# Desc: Top-level makefile for Mezzanine
# Author: Andrew Howard
# Date: 21 Mar 2002
# CVS: $Id: Makefile,v 1.1 2004-12-12 23:36:33 johnsond Exp $
###########################################################################
include Makefile.opt
###########################################################################
# Build section
###########################################################################
all:
cd rtk2 && make all
cd libfg && make all
cd libmezz && make all
cd mezzanine && make all
cd mezzcal && make all
cd examples && make all
dep:
cd rtk2 && make dep
cd libfg && make dep
cd libmezz && make dep
cd mezzanine && make dep
cd mezzcal && make dep
cd examples && make dep
clean:
rm -f *~ *.o
cd rtk2 && make clean
cd libfg && make clean
cd libmezz && make clean
cd mezzanine && make clean
cd mezzcal && make clean
cd examples && make clean
install:
echo "Installing Mezzanine to " $(INSTALL_DIR)
cd mezzanine && make install
cd libmezz && make install
cd mezzcal && make install
cd examples && make install
cd docs && make install
\ No newline at end of file
###########################################################################
# Desc: Options used by all Makefiles
# Author: Andrew Howard
# Date: 21 Mar 2002
# CVS: $Id: Makefile.opt,v 1.1 2004-12-12 23:36:33 johnsond Exp $
###########################################################################
###########################################################################
# Version number
###########################################################################
VERSION = 0.00
###########################################################################
# Install paths
###########################################################################
INSTALL_BASE = /opt/mezzanine
INSTALL_DIR = $(INSTALL_BASE)-$(VERSION)
INSTALL_BIN = $(INSTALL_DIR)/bin
INSTALL_ETC = $(INSTALL_DIR)/etc
INSTALL_INC = $(INSTALL_DIR)/include
INSTALL_LIB = $(INSTALL_DIR)/lib
INSTALL_EG = $(INSTALL_DIR)/examples
INSTALL_DOC = $(INSTALL_DIR)/doc
###########################################################################
# Tools
###########################################################################
INSTALL = install
MKDIR = mkdir
Desc: README for Mezzanine package
Author: Andrew Howard ahoward@usc.edu
CVS: $Id: README,v 1.1 2004-12-12 23:36:33 johnsond Exp $
Abstract
--------
Mezzanine is an overhead 2D visual tracking package intended primarily
for use as a mobile robot metrology system. It uses a camera to track
objects marked with color-coded fiducials, and infers the pose
(position and orientation) of these objects in world coordinates.
Mezzanine will work with almost any color camera (even the really
cheap ones), and can correct for the barrel distortion produced by
wide-angle-lenses.
Mezzanine is also language and architecture neutral: object poses are
written into a shared memory-mapped file which other programs can read
and make use of as they see fit. Mezzanine itself is written in pure
C and was developed under Linux on x86 hardware.
Documentation
-------------
Full documentation can be found in the user manual: docs/mezzanine.pdf.
This file contains instructions for building mezzanine.
Package contents
----------------
mezzanine : the visual object tracker.
mezzcal : a calibration tool for the tracker.
libmezz : an IPC library for talking to mezzanine.
libfg : a simple Video4Linux library written by Gavin Baker (thanks Gav!).
rtk2 : a gui toolkit used by mezzcal.
examples : sample programs.
docs : package documentation.
System Requirements
-------------------
Mezzanine is known to work on Linux x86 systems running 2.4.X kernels.
Third party libraries
---------------------
Mezzanine requires the Gimp Toolkit (GTK+ 1.2) available from:
http://www.gtk.org
Mezzanine also requires the Gnu Scientific Library (GSL 0.9 and above)
available from:
http://sources.redhat.com/gsl/
Both libraries come as RPMS in RedHat distros, although GSL is
not usually installed by default.
Building Mezzanine
------------------
Currently, Mezzanine is not using autoconf, so you will just have
to build it the old fashioned way. Assuming the required third-party
libraries are installed, you should be able to just:
$ make; make install
from the top-level directory (i.e. the one you found this README in).
By default, Mezzanine will install in your home directory rather than
/usr/local/bin, so you wont need root permissions to install it. You
will, however, need to append ~/mezzanine-<VERSION>/bin to your
executable path.
Build Options
-------------
Various build options, including the default installation path,
can be changed by editing Makefile.opt.
Bugs
----
Mezzanine is research software, and is bound to contain some bugs. If
you've broken something (or better yet, fixed something), please
submit a bug report to
http://sourceforge.net/playerstage
Make sure you include the Mezzanine and OS version, together with a
detailed description of the problem. While there is no warranty on
this software, we'll try to fix things for you.
###########################################################################
# Desc: Makefile for documentation
# Author: Andrew Howard
# Date: 5 May 2002
# CVS: $Id: Makefile,v 1.1 2004-12-12 23:36:35 johnsond Exp $
###########################################################################
include ../Makefile.opt
all:
cd tex && make all && cp mezzanine.pdf ..
clean:
cd tex && make clean
install:
$(MKDIR) -p $(INSTALL_DOC)
$(INSTALL) -m 644 mezzanine.pdf $(INSTALL_DOC)
###########################################################################
# Desc: Makefile for building and installing the examples
# Author: Andrew Howard
# Date: Apr 10 2002
# CVS: $Id: Makefile,v 1.1 2004-12-12 23:36:33 johnsond Exp $
###########################################################################
include ../Makefile.opt
all:
cd simple && make all
dep:
cd simple && make dep
clean:
rm -f *~ *.o
cd simple && make clean
install:
$(MKDIR) -p $(INSTALL_EG)
$(MKDIR) -p $(INSTALL_EG)/simple
$(INSTALL) -m 644 simple/*.c simple/Makefile $(INSTALL_EG)/simple/
###########################################################################
# Desc: Makefile for simple tracking example
# Author: Andrew Howard
# Date: Apr 10 2002
# CVS: $Id: Makefile,v 1.1 2004-12-12 23:36:33 johnsond Exp $
###########################################################################
.SUFFIXES: .c .o
###########################################################################
# Options
###########################################################################
EXE = simple
OBS = simple.o
INCLUDES = -I../../libmezz
CFLAGS = -g3 -Wall $(INCLUDES)
LFLAGS = -lm -L../../libmezz -lmezz
CC = gcc
LINKER = gcc
MAKEDEP = makedepend
###########################################################################
# Build section
###########################################################################
all: $(EXE)
$(EXE) : $(OBS)
$(LINKER) $(OBS) $(LFLAGS) -o $(EXE)
%.o : %.c
${CC} ${CFLAGS} -c $< -o $@
dep:
$(MAKEDEP) $(INCLUDES) -Y -s "# Dependancies (generated by 'make dep')" *.c 2>/dev/null
$(RM) -f Makefile.bak
clean:
rm -f $(EXE) *~ *.o
# Dependancies (generated by 'make dep')
simple.o: ../../libmezz/mezz.h
/*
* Mezzanine - an overhead visual object tracker.
* Copyright (C) Andrew Howard 2002
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/***************************************************************************
* Desc: Simple object tracking example
* Author: Andrew Howard
* Date: 28 Mar 2002
* CVS: $Id: simple.c,v 1.1 2004-12-12 23:36:33 johnsond Exp $
***************************************************************************/
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "mezz.h"
// Set flag to 1 to force program to quit
static int quit = 0;
// Handle quit signals
void sig_quit(int signum)
{
quit = 1;
}
// Main
int main(int argc, char **argv)
{
int i;
mezz_mmap_t *mmap;
mezz_object_t *object;
char *tmpdir;
char ipcfilename[256];
// Register signal handlers
signal(SIGINT, sig_quit);
signal(SIGQUIT, sig_quit);
// set up ipc file.
tmpdir = getenv("TMP");
if (tmpdir == NULL)
tmpdir = "/tmp";
snprintf(ipcfilename,sizeof(ipcfilename),"%s/mezz_instance%s.ipc",
tmpdir,argv[1]);
// Initialise the IPC
if (mezz_init(0,ipcfilename) < 0)
return -1;
mmap = mezz_mmap();
while (!quit)
{
// Make sure the IPC is running before we do anything else
mezz_wait_event();
printf("time [%13.3f] frame [%d]\n", mmap->time, mmap->count);
for (i = 0; i < mmap->objectlist.count; i++)
{
object = mmap->objectlist.objects + i;
printf("object [%d] pose [%+05.2f, %+05.2f, %+03.0f]\n",
i, object->px, object->py, object->pa * 180 / M_PI);
}
}
// Finalise the IPC
mezz_term(0);
return 0;
}
This diff is collapsed.
#===========================================================================
#
# Description: Makefile for libfg
#
# Author: Gavin Baker <gavinb@antonym.org>
#
# Homepage: http://www.antonym.org/libfg
#
# License: Released under the GPL v2
#
#===========================================================================
.SUFFIXES: .c .o
#---------------------------------------------------------------------------
# Options
#---------------------------------------------------------------------------
# Targets
LIB = libfg.a
EXE = test_capture
OBJS = capture.o frame.o
# Build flags with no gui
INCLUDES = -I.
CFLAGS = -g3 -Wall $(INCLUDES)
LFLAGS = -lm
CC = gcc
MAKEDEP = makedepend
#---------------------------------------------------------------------------
# Build section
#---------------------------------------------------------------------------
%.o : %.c
${CC} ${CFLAGS} -c $< -o $@
all: $(EXE) $(LIB) camview
$(LIB): $(OBJS)
ar r $(LIB) $(OBJS)
$(EXE): $(LIB) test_capture.o
$(CC) $(LFLAGS) -o $(EXE) test_capture.o $(LIB)
camview: camview.c
$(CC) $(CFLAGS) $(LFLAGS) -o camview camview.c \
libfg.a -lSDL -lpthread
doc: #
doxygen libfg.dox
dep: #
$(MAKEDEP) $(INCLUDES) -Y -s "# Dependencies (generated by 'make dep')" *.c 2>/dev/null
$(RM) -f Makefile.bak
clean:
@rm -f $(EXE) $(LIB) $(OBJS) test_capture.o camview *~
#===========================================================================
# Dependencies (generated by 'make dep')
capture.o: capture.h frame.h
fgmodule.o: capture.h frame.h
frame.o: frame.h
test_capture.o: capture.h frame.h
libfg - Frame Grabber Library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Details
~~~~~~~
Version: 0.2a
Author: Gavin Baker <gavinb@antonym.org>
Homepage: www.antonym.org/libfg
License: Lesser GPL v2.1 (LGPL)
Description: Provides a simple high-level C interface to control
Video4Linux compatible hardware such as frame grabbers
TV tuners and USB cameras.
License Terms
~~~~~~~~~~~~~
libfg - Frame Grabber library for Linux
Copyright (C) 2002, 2003 Gavin Baker
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or visit their website at http://www.gnu.org/.
Introduction
~~~~~~~~~~~~
This library provides a simple C interface for controlling a frame grabber
or TV tuner card under Linux. It uses the Video 4 Linux API for control.
It supports the following features:
- Frame capture (for image processing)
- Video overlay (coming soon!)
- Picture control
- TV tuner control
Documentation
~~~~~~~~~~~~~
The API reference is provided in the doc directory, in HTML and PDF formats.
Hardware Support
~~~~~~~~~~~~~~~~
Libfg should work with any V4L supported hardware, but is completely
dependent upon the version of the kernel you are using. A recent 2.4 series
kernel is strongly recommended.
It has been tested to work with the following configurations:
- Debian woody 3.0, kernel 2.4.17, bttv driver, FlyVideo 98 card
- Mandrake 8.2, kernel 2.4.19, bttv driver, Picolo card
- RedHat 8
- Debian woody 3.0, kernel 2.4.21, Logitech USB Camera
Python Bindings
~~~~~~~~~~~~~~~
A very preliminary release of bindings to Python are now included.
Methods will be gradually added over time.
Currently the extension must be manually built. Fortunately, this is
only slightly harder than falling off a log. It does require that you
have a recent (eg. 2.x) version of Python installed, with distutils.
And of course, you must build libfg first!
% python setup.py build
This will build the module and put it in a strange directory, like
build/lib.linux-i686-2.1. If you go there and run the python interpreter,
you can do stuff like this:
>>> import fg
>>> g = fg.Grabber()
>>> g.set_source(0)
>>> g.set_channel(64.250) # ABC TV
>>> g.demo('test01.pgm')
Have fun!
//==========================================================================
//
// camview
//
// Copyright (c) 2003 Gavin Baker <gavinb@antonym.org>
//
// Released under the Artistic license
//
// A simple program to display the camera output on screen.
// Uses libSDL in concert with libfg.
//
//==========================================================================
#include <stdio.h>
#include <sys/time.h>
#include <SDL/SDL.h>
#include "capture.h"
//--------------------------------------------------------------------------
typedef struct
{
FRAMEGRABBER* fg;
FRAME* frame;
SDL_Surface* screen;
SDL_Surface* image;
unsigned frames;
struct timeval timestamp;
} camview_app;
//--------------------------------------------------------------------------
int init( camview_app* app )
{
unsigned int bmask = 0x000000ff;
unsigned int gmask = 0x0000ff00;
unsigned int rmask = 0x00ff0000;
unsigned int amask = 0xff000000;
// Open framegrabber device
app->fg = fg_open( NULL );
app->frame = fg_new_compatible_frame( app->fg );
app->frames = 0;
fg_dump_info( app->fg );
int bpp = 0;
switch ( app->frame->format )
{
case VIDEO_PALETTE_RGB24:
bpp = 24;
break;
case VIDEO_PALETTE_RGB32:
bpp = 32;
break;
default:
fprintf( stderr, "Unsupported frame format! %u",
app->frame->format );
return -1;
}
// Start SDL
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Failed to initialise SDL: %s\n", SDL_GetError() );
return -1;
}
atexit( SDL_Quit );
// Create a window the size of the display
SDL_WM_SetCaption( "camview", NULL );
app->screen = SDL_SetVideoMode( app->fg->caps.maxwidth,
app->fg->caps.maxheight,
bpp, SDL_SWSURFACE );
if ( app->screen == NULL )
{
fprintf( stderr, "Failed to set video mode: %s\n", SDL_GetError() );
return -1;
}
// Wrap the libfg frame in an SDL surface
app->image = SDL_CreateRGBSurfaceFrom( app->frame->data,
app->frame->width,
app->frame->height,
bpp,
app->frame->width * 4,
rmask, gmask, bmask, amask);
if ( app->image == NULL )
{
fprintf( stderr, "Failed to create RGB surface! %s\n", SDL_GetError());
return 1;
}
// Ignore alpha channel, go opaque
SDL_SetAlpha( app->image, 0, 0 );
gettimeofday( &app->timestamp, NULL );
return 0;
}
//--------------------------------------------------------------------------
int cleanup( camview_app* app )
{
fg_close( app->fg );
frame_release( app->frame );
SDL_FreeSurface( app->image );
SDL_Quit();
return 0;
}
//--------------------------------------------------------------------------
int update( camview_app* app )
{
fg_grab_frame( app->fg, app->frame );
app->frames++;
if ( SDL_BlitSurface( app->image, NULL,
app->screen, NULL ) < 0 )
{
fprintf( stderr, "Cannot blit! %s\n", SDL_GetError() );
return 1;
}
SDL_UpdateRect( app->screen, 0, 0, 0, 0 );
if ( app->frames % 10 == 0 )
{
struct timeval now;
gettimeofday( &now, NULL );
float elapsed = ( now.tv_sec - app->timestamp.tv_sec ) +
( now.tv_usec - app->timestamp.tv_usec )/1e6;
printf( "%0.2f frames/sec \n", app->frames/elapsed );
}
return 0;
}
//--------------------------------------------------------------------------
int run( camview_app* app )
{
SDL_Event event;
int running = 1;
while( running )
{
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT )
{
running = 0;
}
if ( event.type == SDL_KEYDOWN )
{
if ( event.key.keysym.sym == SDLK_ESCAPE )
{
running = 0;
}
}
}