Commit c69d2f59 authored by Yuelong Yu's avatar Yuelong Yu
Browse files

added vendor sdk and readme

parent a355c379
# Introdution
This project combines the PCO CLHS and PCO Me4 SDK to be one. The idea is to use system call dlopen,dlsym,dlclose
to load the corresponding sdk during runtime.
# Dependencies
The library is compiled with the following dependencies.
* Pco Me4 SDK 1.01.14
* Pco CLHS SDK 1.02.03
* SISO 5.6.0
\ No newline at end of file
set(PCO_SDK_NAME "pcosdk")
set(SDK_LIBRARY_VERSION "0.1")
set(SDK_LIB_MAIN_VERSION 0)
set(SDK_LIB_MINOR_VERSION 1)
set(SDK_LIBRARY_VERSION "${SDK_LIB_MAIN_VERSION}.${SDK_LIB_MINOR_VERSION}")
include_directories("${PROJECT_SOURCE_DIR}"
${PCOSDK_INC_DIRS}
......
#find pco
find_path(PCO_INC_DIRS NAMES Cpco_com_cl_me4.h Cpco_grab_cl_me4.h Cpco_com.h
PATHS
/usr/include
/usr/local/include
/home/yuelong/lib.local/include/pco/me4
)
#path of pco path
find_library(PCO_LIB_DIRS NAMES pcocam_me4 pcofile pcolog reorderfunc
PATHS
/usr/lib/
/usr/local/lib
/home/yuelong/lib.local/lib/pco/me4
)
if(PCO_INC_DIRS AND PCO_LIB_DIRS)
SET(PCO_LIB_FOUND TRUE)
endif(PCO_INC_DIRS AND PCO_LIB_DIRS)
if(NOT PCO_LIB_FOUND)
message(FATAL_ERROR "cannot find corresponding PCO libraries.")
else(NOT PCO_LIB_FOUND)
message(STATUS "pco include path:${PCO_INC_DIRS}")
message(STATUS "pco lib path:${PCO_LIB_DIRS}")
endif(NOT PCO_LIB_FOUND)
#find pcoclhs
find_path(PCOCLHS_INC_DIRS NAMES Cpco_grab_clhs.h Cpco_com.h
PATHS
/usr/include
/usr/local/include
/home/yuelong/lib.local/include/pco/clhs
)
#path of pcoclhs path
find_library(PCOCLHS_LIB_DIRS NAMES pcocam_clhs pcoclhs pcofile pcolog
PATHS
/usr/lib/
/usr/local/lib
/home/yuelong/lib.local/lib/pco/clhs
)
if(PCOCLHS_INC_DIRS AND PCOCLHS_LIB_DIRS)
SET(PCOCLHS_LIB_FOUND TRUE)
endif(PCOCLHS_INC_DIRS AND PCOCLHS_LIB_DIRS)
if(NOT PCOCLHS_LIB_FOUND)
message(FATAL_ERROR "cannot find corresponding libraries.")
else(NOT PCOCLHS_LIB_FOUND)
message(STATUS "pcoclhs include path:${PCOCLHS_INC_DIRS}")
message(STATUS "pcoclhs lib path:${PCOCLHS_LIB_DIRS}")
endif(NOT PCOCLHS_LIB_FOUND)
set(PCO_CLHS_NAME "pcoclhs")
set(CLHS_LIBRARY_VERSION "0.1")
#find_package(PCOCLHS)
set(CLHS_LIB_MAIN_VERSION 0)
set(CLHS_LIB_MINOR_VERSION 1)
set(CLHS_LIBRARY_VERSION "${CLHS_LIB_MAIN_VERSION}.${CLHS_LIB_MINOR_VERSION}")
include_directories("${PROJECT_SOURCE_DIR}"
${PCOCLHS_INC_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
"../vendor.sdk/include/clhs"
"../api")
#link_directories(${PCOCLHS_LIB_DIRS})
link_directories("/home/yuelong/lib.local/lib/pco/clhs")
link_directories("../vendor.sdk/lib/clhs")
message(status ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB CLHS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
......@@ -20,19 +19,10 @@ set(CLHS_SHARED_FLAGS -Wl,-Bstatic -lpcocam_clhs -lpcoclhs
-Wl,-Bdynamic
-lpthread)
message(${CLHS_SRC})
#set(LINK_FLAGS ${LINK_FLAGS} "-Wl,-whole-archive")
add_library(${PCO_CLHS_NAME} SHARED ${CLHS_SRC})
target_link_libraries(${PCO_CLHS_NAME} ${CLHS_SHARED_FLAGS})
set_target_properties(${PCO_CLHS_NAME} PROPERTIES VERSION "${CLHS_LIBRARY_VERSION}")
# set(DEV_HEADERS
# PcoCLHSInterfaces.h)
# #install header files
# install(FILES ${DEV_HEADERS} DESTINATION "${CMAKE_INSTALL_INC_PATH}")
#install target
install(TARGETS ${PCO_CLHS_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIB_PATH})
set(PCO_ME4_NAME "pcome4")
set(ME4_LIBRARY_VERSION "0.1")
find_package(PCO)
set(ME4_LIB_MAIN_VERSION 0)
set(ME4_LIB_MINOR_VERSION 1)
set(ME4_LIBRARY_VERSION "${ME4_LIB_MAIN_VERSION}.${ME4_LIB_MINOR_VERSION}")
include_directories("${PROJECT_SOURCE_DIR}"
${PCO_INC_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
"../vendor.sdk/include/me4"
"../api")
#link_directories(${PCO_LIB_DIRS})
link_directories("/home/yuelong/lib.local/lib/pco/me4")
link_directories("../vendor.sdk/lib/me4")
message(status ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB ME4_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
......@@ -17,7 +17,7 @@ file(GLOB ME4_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
set(ME4_SHARED_FLAGS -Wl,-Bstatic -lpcocam_me4 -lpcofile -lpcolog -lreorderfunc -Wl,-Bdynamic -lpthread)
message(${ME4_SRC})
#message(${ME4_SRC})
#set(LINK_FLAGS " -Wl,--whole-archive")
add_library(${PCO_ME4_NAME} SHARED ${ME4_SRC})
......
//-----------------------------------------------------------------//
// Name | Ccambuf.h | Type: ( ) source //
//-------------------------------------------| (*) header //
// Project | pco.camera | ( ) others //
//-----------------------------------------------------------------//
// Platform | Linux //
//-----------------------------------------------------------------//
// Environment | //
// | //
//-----------------------------------------------------------------//
// Purpose | pco.camera - buffer class functions //
//-----------------------------------------------------------------//
// Author | MBL, PCO AG //
//-----------------------------------------------------------------//
// Revision | rev. 1.03 //
//-----------------------------------------------------------------//
// Notes | class functions exported from Ccambuf library //
// | //
// | //
//-----------------------------------------------------------------//
// (c) 2010 - 2012 PCO AG //
// Donaupark 11 D-93309 Kelheim / Germany //
// Phone: +49 (0)9441 / 2005-0 Fax: +49 (0)9441 / 2005-20 //
// Email: info@pco.de //
//-----------------------------------------------------------------//
#ifndef Ccambuf_h
#define Ccambuf_h
#define OUT_BW 0x00
#define OUT_BGR 0x01
#define OUT_BGR0 0x02
#define OUT_PSEUDO 0x03
#define IN_BW 0x00 //input buffer is from BW-Camera
#define IN_COLOR 0x10 //input buffer is from COLOR-Camera
#define MASK_RGB 0x20
#define IN_RGB 0x20 //input buffer is from RGB-Camera
#define IN_RGB0 0x21 //input buffer is from RGB0-Camera
#define IN_BGR 0x22 //input buffer is from BGR-Camera
#define IN_BGR0 0x23 //input buffer is from BGR0-Camera
#define STATUS_INCONVERT 0x01
class Cambuf;
class CCambuf
{
//variables
public:
int status;
public:
CCambuf();
~CCambuf();
int Allocate(int width, int height,int bitpix,int align,int color_in);
int Allocate(int width, int height,int bitpix,int align);
int Allocate(int width, int height,int bitpix);
int Allocate(int size);
int Allocate();
int FreeBuffer();
int Get_Size();
int Get_actwidth();
int Get_actheight();
int Get_actbitpix();
int Get_actalign();
void* Get_actadr();
int SetCalculationRectangle(int firstline,int lastline,int firstrow,int lastrow);
void GetMinMax(int *min,int *max);
void GetMinMaxPos(int *min,int *min_pos_x,int *min_pos_y,int *max,int *max_pos_x,int *max_pos_y);
int CreateHistogramTable();
int CreateHistogramTable(int *min,int *max,double *mean,double *sigma);
int CreateHistogramTable(DWORD *histtab,int size,int *min,int *max,double *mean,double *sigma);
int CreateHistogramTables();
void Clearbuffer();
void Set_output_buffer(int mode);
void Set_output_buffer(int mode,void *bufadr);
void Set_output_lut(void *lut);
int GetColorinmode();
int convert();
int convert(void *out);
int convert(void *out,void *lut);
int convert_bw(void *out,void *lut);
int convert_col(void *out,void *lut);
void copy8to24(unsigned char *b8,unsigned char *out);
void copy8to32(unsigned char *b8,unsigned char *out);
int subtract(CCambuf *pic);
int subtract(CCambuf *pic,int offset);
int reduce(CCambuf *pic,int factor);
protected:
Cambuf *cambuf;
};
#endif
//-----------------------------------------------------------------//
// Name | Cpco_com.h | Type: ( ) source //
//-------------------------------------------| (*) header //
// Project | pco.camera | ( ) others //
//-----------------------------------------------------------------//
// Platform | LINUX //
//-----------------------------------------------------------------//
// Environment | gcc //
// | //
//-----------------------------------------------------------------//
// Purpose | pco.camera - Communication //
//-----------------------------------------------------------------//
// Author | MBL, PCO AG //
//-----------------------------------------------------------------//
// Revision | rev. 1.04 //
//-----------------------------------------------------------------//
// Notes | Common functions //
// | //
// | //
//-----------------------------------------------------------------//
// (c) 2010 - 2015 PCO AG //
// Donaupark 11 D-93309 Kelheim / Germany //
// Phone: +49 (0)9441 / 2005-0 Fax: +49 (0)9441 / 2005-20 //
// Email: info@pco.de //
//-----------------------------------------------------------------//
//-----------------------------------------------------------------//
// Revision History: //
// see Cpco_com.cpp //
//-----------------------------------------------------------------//
#ifndef CPCO_COM_H
#define CPCO_COM_H
// GNU specific __attribute__((unused)) define
#ifdef __GNUC__
#define ATTRIBUTE_UNUSED __attribute__((unused))
#else
#define ATTRIBUTE_UNUSED
#endif
#include "pco_includes.h"
#include "VersionNo.h"
#if !defined (MAX_PATH)
#define MAX_PATH 1024
#endif
/*! \page page1 Introduction
This manual provides an detailed description of all functions of the PCO Camera Linux API.
The API is a class interface and provides the functionality to write own Applications in a Linux environment.
Any C++ compiler can be used for development.
The intention was to provide a simple interface, which can be used with every PCO camera of
the pco.camera series independent from the used interface.
\section sec General
The API consist of two classes a communication class which is used to control the camera settings
and a grabber class which is used to transfer single or multiple images from the camera to the PC.
Because communication with the camera and image transfer depends on the used hardware interface,
interface specific classes exist.
For controlling the camera settings a common base class exists. The interface specific classes
are subclasses derived from the base class.
For image transfers only interface specific classes exist, but main functions use equal function declarations.
\latexonly \newpage \endlatexonly
*/
//nochmalige unterteilung funktioniert so
// This page contains the subsections \ref subsection1 and \ref subsection2.
// For more info see page \ref page2.
// \subsection subsection1 The first subsection
// Text.
// \subsection subsection2 The second subsection
// More text.
///
/// \brief Base interface class
///
/// Derived from this class are all interface specific classes. It includes some common functions and defines the mandatory functions that each subclass has to implement.
///
///\nosubgrouping
class CPco_com {
public:
WORD num_lut;
SC2_LUT_DESC cam_lut[10];
protected:
//common
CPco_Log *clog;
PCO_HANDLE hdriver;
DWORD initmode;
DWORD boardnr;
DWORD camerarev;
bool internal_open;
DWORD connected;
PCO_SC2_TIMEOUTS tab_timeout;
SC2_Camera_Description_Response description;
//functions
public:
CPco_com();
virtual ~CPco_com(){}
///
/// \brief Opens a connection to a pco.camera
/// \anchor Open_Cam
/// \param num Number of the camera starting with zero.
/// \return Error code or 0 on success
///
virtual DWORD Open_Cam(DWORD num)=0;
///
/// \brief Opens a connection to a pco.camera
/// \anchor Open_Cam_Ext
/// \param num Number of the camera starting with zero.
/// \param strOpen Unused.
/// \return Error code or 0 on success
///
virtual DWORD Open_Cam_Ext(DWORD num,SC2_OpenStruct *strOpen)=0;
///
/// \brief Closes a connection with a pco.camera
/// \anchor Close_Cam
/// Not all classes derived from this must implement a close function.
/// \return Error code or 0 on success
///
virtual DWORD Close_Cam(){return PCO_NOERROR;}
///
/// \brief The main function to communicate with the camera via PCO telegrams
/// \anchor Control_Command
/// See sc2_telegram.h for a list of telegrams and sc2_command.h for a list of possible commands
///
/// Checksum calculation is done in this function, no need to pre-calculate it.
/// \param buf_in Pointer to the buffer where the telegram is stored
/// \param size_in Pointer to a DWORD that holds the input size of the buffer
/// \param buf_out Pointer to the buffer where the response gets stored
/// \param size_out Pointer to a DWORD that holds the size of the buffer. This is updated with the returned size.
/// \return Error code or 0 on success
///
virtual DWORD Control_Command(void *buf_in,DWORD size_in,void *buf_out,DWORD size_out)=0;
///
/// \brief Sets the logging behaviour for the communication class.
/// \n
/// If this function is not called no logging is performed.
/// Logging might be useful to follow the program flow of the application.
/// \param Log Pointer to a CPco_Log logging class object
/// \return
///
void SetLog(CPco_Log *Log);
/// \cond
protected:
///
/// \brief Writes a log entry
/// \anchor writelog
/// \param level Type of the entry, e.g. Error, Status, Message, ...
/// \param hdriver The source of the error
/// \param message The actual log message as printf formatted string
/// \return Error code or 0 on success
///
void writelog(DWORD level,PCO_HANDLE hdriver,const char *message,...);
///
/// \brief Scans the connected camera and gets basic informations
/// \anchor scan_camera
/// \return Error code or 0 on success
///
virtual DWORD scan_camera()=0;
///
/// \brief Builds the checksum for Control_Command() telegrams
/// \anchor build_checksum
/// \param buf Pointer to buffer that contains the telegram
/// \param size Pointer to size of the buffer
/// \return Error code or 0 on success
///
DWORD build_checksum(unsigned char *buf,int *size);
///
/// \brief Verifies the checksum for a telegram
/// \anchor test_checksum
/// \param buf Pointer to buffer that contains the telegram
/// \param size Pointer to size of the buffer
/// \return Error code or 0 on success
///
DWORD test_checksum(unsigned char *buf,int *size);
///
/// \brief Gets the camera descriptor and caches it
/// \anchor get_description
/// \return Error code or 0 on success
///
DWORD get_description();
///
/// \brief Gets camera main processor and main FPGA firmware versions and writes them to the logfile
/// \anchor get_firmwarerev
/// \return Error code or 0 on success
///
DWORD get_firmwarerev();
///
/// \brief Gets installed LUTs and writes them to the logfile
/// \anchor get_lut_info
/// \return Error code or 0 on success
///
DWORD get_lut_info();
/// \endcond
public:
#include "Cpco_com_func.h"
#include "Cpco_com_func_2.h"
/// @name Class Control Functions
///
/// These functions are used to control some internal variables of the class.
///
///
/// \brief Gets the current timeouts for images and telegrams
/// \anchor gettimeouts
/// \param strTimeouts Pointer to a PCO_SC2_TIMEOUTS structure
/// \return
///
void gettimeouts(PCO_SC2_TIMEOUTS *strTimeouts);
///
/// \brief Sets the timeouts
/// \anchor Set_Timeouts
/// \param timetable Pointer to an DWORD array. First parameter is the command timeout, second the image timeout, third the transfer timeout.
/// \param length Length of the array in bytes, a maximum of 12 bytes are used.
/// \return
///
void Set_Timeouts(void *timetable,DWORD length);
///
/// \brief GetConnectionStatus
/// \anchor GetConnectionStatus
/// \return Connectionstatus
/// \retval 1 connected
/// \retval 0 not connected
int GetConnectionStatus();
///
/// \brief Sets the connection status
/// \anchor SetConnectionStatus
/// \param status
/// \return
///
void SetConnectionStatus(DWORD status);
///
/// \brief Common sleep function for Linux/Windows
/// \anchor Sleep_ms
/// \param time_ms Time to sleep in ms
/// \return
///
void Sleep_ms(DWORD time_ms);
};
#endif
//-----------------------------------------------------------------//
// Name | Cpco_com_clhs.h | Type: ( ) source //
//-------------------------------------------| (*) header //
// Project | pco.camera | ( ) others //
//-----------------------------------------------------------------//
// Platform | Linux //
//-----------------------------------------------------------------//
// Environment | //
// | //
//-----------------------------------------------------------------//
// Purpose | pco.camera - clhs communication //
//-----------------------------------------------------------------//
// Author | MBL, PCO AG //
//-----------------------------------------------------------------//
// Revision | rev. 0.01 rel. 0.00 //
//-----------------------------------------------------------------//
// Notes | Common functions //
// | //
// | //
//-----------------------------------------------------------------//
// (c) 2016 - 2016 PCO AG //
// Donaupark 11 D-93309 Kelheim / Germany //
// Phone: +49 (0)9441 / 2005-0 Fax: +49 (0)9441 / 2005-20 //
// Email: info@pco.de //
//-----------------------------------------------------------------//
//-----------------------------------------------------------------//
// Revision History: //
// see Cpco_com_clhs.cpp //
//-----------------------------------------------------------------//
#ifndef CPCO_COM_CLHS_H
#define CPCO_COM_CLHS_H
#include "pco_includes.h"
#include "Cpco_com.h"
#include "VersionNo.h"
#include "pco_clhs_cam.h"
#define MAXNUM_DEVICES 8
///
/// \brief The CPco_com_clhs class, extends CPco_com
///
/// This is the communication class to exchange messages (telegrams) with a pco.camera.
///
class CPco_com_clhs : public CPco_com
{
public:
protected:
///
/// \brief Semaphore to lock the Control_Command()
///
sem_t sMutex;
CPco_clhs_cam* Cclhs_cam;
//functions
public:
CPco_com_clhs();
~CPco_com_clhs();
///