libpco  0.3.0
libpco Documentation

Introduction

libpco is a small wrapper around the PCO message protocol to communicate with CameraLink-based cameras produced by PCO. However, actual frame transfer is still managed by the frame grabber.

Installation

Check out a current branch from the repository or untar a release tarball into some directory. Create a new empty directory and issue

 cmake <path-to-libpco>

in a terminal. In order to change the installation prefix or library suffix on 64-bit systems, you can call cmake with -DCMAKE_INSTALL_PREFIX=/some/other/path and -DLIB_SUFFIX=64. Build and install the library with

 make && make install

pkg-config meta information is also installed and can be queried with

 pkg-config --cflags --libs pco

Quick Start

Make sure to connect the camera and the frame grabber with the CameraLink cables in correct order and start the camera. Create a new camera handle by calling

 pco_handle pco = pco_init(); 

You can then use this handle to query information about the camera, for example getting the name:

 char *name = NULL;
 pco_get_name(pco, &name);
 printf("Camera name %s\n", name);
 free(name);

To release the camera, call

 pco_destroy(pco); 

Frame Grabbing

libpco is just a small wrapper and it is encouraged to use a higher level abstraction to make use of the different pco camera types. However, if you are using the SiliconSoftware SDK and want to grab frames on your own, you can write something like this:

 // The actual "applet" is specific to the camera type.
 static const char *applet = "libDualAreaGray16.so";
 int port = PORT_A;
 Fg_Struct *fg = Fg_Init(applet, 0);

 // The actual CameraLink connection is specific to the camera type and frame
 // grabber.
 int val = FG_CL_SINGLETAP_16_BIT;
 Fg_setParameter(fg, FG_CAMERA_LINK_CAMTYP, &val, port);

 // The frame format is specific to the camera type. Especially on the
 // pco.edge you have to use FG_GRAY and do the decoding on your own using the
 // pco_get_reorder_func()
 val = FG_GRAY16;
 Fg_setParameter(fg, FG_FORMAT, &val, port);

 val = FREE_RUN;
 Fg_setParameter(fg, FG_TRIGGERMODE, &val, port);

 fg, Fg_setParameter(fg, FG_WIDTH, &width, port);
 fg, Fg_setParameter(fg, FG_HEIGHT, &height, port);

 const int n_buffers = 5;

 dma_mem *mem = Fg_AllocMemEx(fg, n_buffers*width*height*sizeof(uint16_t), n_buffers);
 if (mem == NULL) 
     fprintf(stderr, "Couldn't allocate buffer memory!\n");

 pco_arm_camera(pco);
 pco_start_recording(pco);

 const int n_images = 1;
 fg, Fg_AcquireEx(fg, port, n_images, ACQ_STANDARD, mem);

 frameindex_t last_frame = 1;

 // For streaming cameras, this is unnecessary
 pco_read_images(pco, active_segment, 1, 1);
 pco_request_image(pco);

 // Request frame
 last_frame = Fg_getLastPicNumberBlockingEx(fg, n_images, port, n_images, mem);

 // Request data
 uint16_t *frame = (uint16_t *) Fg_getImagePtrEx(fg, last_frame, port, mem);
 Fg_stopAcquireEx(fg, port, mem, STOP_ASYNC);
 pco_stop_recording(pco);

API reference

All function definitions can be found in libpco.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines