00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <cams/factory.h>
00024 #include <fvutils/ipc/shm_image.h>
00025
00026 #include <cstring>
00027 #include <signal.h>
00028 #include <cstdio>
00029
00030 using namespace fawkes;
00031 using namespace firevision;
00032
00033 Camera *cam;
00034 SharedMemoryImageBuffer *shm;
00035 bool quit = false;
00036
00037 void
00038 handle_signal(int signum)
00039 {
00040 quit = true;
00041 }
00042
00043 int
00044 main(int argc, char **argv)
00045 {
00046 signal(SIGINT, handle_signal);
00047
00048 printf("Instantiating camera\n");
00049 cam = CameraFactory::instance("leutron:leutron");
00050 printf("Opening camera\n");
00051 cam->open();
00052 printf("Starting camera\n");
00053 cam->start();
00054
00055 printf("Creating shm segment rcxretriever\n");
00056 shm = new SharedMemoryImageBuffer("rcxretriever", cam->colorspace(),
00057 cam->pixel_width(), cam->pixel_height());
00058
00059 printf("Running capture loop\n");
00060 while (! quit) {
00061 cam->capture();
00062 memcpy(shm->buffer(), cam->buffer(), cam->buffer_size());
00063 cam->dispose_buffer();
00064 }
00065
00066 printf("Cleaning up\n");
00067 cam->stop();
00068 cam->close();
00069
00070 delete shm;
00071 delete cam;
00072
00073 }
00074