nv2_label_reader.h

Go to the documentation of this file.
00001 /*!@file NeovisionII/nv2_label_reader.h */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/NeovisionII/nv2_label_reader.h $
00035 // $Id: nv2_label_reader.h 8125 2007-03-16 04:33:29Z rjpeters $
00036 //
00037 
00038 #ifndef NEOVISIONII_NV2_LABEL_READER_H_DEFINED
00039 #define NEOVISIONII_NV2_LABEL_READER_H_DEFINED
00040 
00041 #include <stddef.h>
00042 #include <stdint.h>
00043 
00044 struct nv2_label_reader;
00045 struct nv2_image_patch;
00046 struct nv2_patch_label;
00047 
00048 #ifdef __cplusplus
00049 #  define NV2_EXTERN_C extern "C"
00050 #else
00051 #  define NV2_EXTERN_C
00052 #endif
00053 
00054 /// Create a label reader (which will also be a patch server)
00055 /** @param label_reader_port tcp port on which the label reader should
00056     run on this host machine (by default, you should use
00057     NV2_LABEL_READER_PORT)
00058 
00059     @param remote_patch_reader_addr ip address to which we should
00060     connect to find the patch reader
00061 
00062     @param remote_patch_reader_port tcp port on which the patch reader
00063     is running on dest_addr
00064  */
00065 NV2_EXTERN_C
00066 struct nv2_label_reader* nv2_label_reader_create(
00067         const int label_reader_port,
00068         const char* remote_patch_reader_addr,
00069         const int remote_patch_reader_port);
00070 
00071 /// Destroy a label reader and release all resources associated with it
00072 NV2_EXTERN_C
00073 void nv2_label_reader_destroy(struct nv2_label_reader* p);
00074 
00075 /// Get the most recently received patch label, if any
00076 /** @param l if new label is found, it will be copied here
00077 
00078     @return non-zero if a label is found, or zero if no label has been
00079     received since the last time this function was called
00080  */
00081 NV2_EXTERN_C
00082 int nv2_label_reader_get_current_label(struct nv2_label_reader* p,
00083                                        struct nv2_patch_label* l);
00084 
00085 /// Result type of nv2_label_reader_send_patch()
00086 enum nv2_patch_send_result
00087 {
00088         NV2_PATCH_SEND_OK = 23456, ///< patch was sent succesfully
00089         NV2_PATCH_SEND_FAIL,       ///< patch was not sent (maybe server is down?)
00090 };
00091 
00092 /// Send an image patch from the patch server asynchronously
00093 /** @param r handle to the patch server from which to send the patch
00094 
00095     @param p image patch to be sent; note the patch server assumes
00096     ownership of this image patch and will free memory associated with
00097     it, so (1) the memory in p->data should have be allocated with
00098     malloc() so that it can be released with free(), and (2) the patch
00099     pointed to by p will be an empty patch on return from this
00100     function (reflecting the fact that ownership of the original patch
00101     is now transferred to the patch server)
00102  */
00103 NV2_EXTERN_C
00104 void
00105 nv2_label_reader_send_patch(struct nv2_label_reader* r,
00106                             struct nv2_image_patch* p);
00107 
00108 /// Send an image patch from the patch server synchronously
00109 /** This is the work function that is called from a background thread
00110     to implement the asynchronous nv2_label_reader_send_patch().
00111 
00112     @param show_warnings whether or not to print warnings if the patch
00113     send fails
00114 */
00115 NV2_EXTERN_C
00116 enum nv2_patch_send_result
00117 nv2_label_reader_send_patch_sync(struct nv2_label_reader* r,
00118                                  struct nv2_image_patch* p,
00119                                  const int show_warnings);
00120 
00121 #undef NV2_EXTERN_C
00122 
00123 // ######################################################################
00124 /* So things look consistent in everyone's emacs... */
00125 /* Local Variables: */
00126 /* indent-tabs-mode: nil */
00127 /* c-file-style: "linux" */
00128 /* End: */
00129 
00130 #endif // NEOVISIONII_NV2_LABEL_READER_H_DEFINED
Generated on Sun May 8 08:41:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3