rcxretriever.cpp
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
00032 Camera *cam;
00033 SharedMemoryImageBuffer *shm;
00034 bool quit = false;
00035
00036 void
00037 handle_signal(int signum)
00038 {
00039 quit = true;
00040 }
00041
00042 int
00043 main(int argc, char **argv)
00044 {
00045 signal(SIGINT, handle_signal);
00046
00047 printf("Instantiating camera\n");
00048 cam = CameraFactory::instance("leutron:leutron");
00049 printf("Opening camera\n");
00050 cam->open();
00051 printf("Starting camera\n");
00052 cam->start();
00053
00054 printf("Creating shm segment rcxretriever\n");
00055 shm = new SharedMemoryImageBuffer("rcxretriever", cam->colorspace(),
00056 cam->pixel_width(), cam->pixel_height());
00057
00058 printf("Running capture loop\n");
00059 while (! quit) {
00060 cam->capture();
00061 memcpy(shm->buffer(), cam->buffer(), cam->buffer_size());
00062 cam->dispose_buffer();
00063 }
00064
00065 printf("Cleaning up\n");
00066 cam->stop();
00067 cam->close();
00068
00069 delete shm;
00070 delete cam;
00071
00072 }
00073