- Reestructuración de ficheros y directorios general

- merge v0.01 --> Añadido fileselector
- Añadidas fuentes de Gem y Pure Data
- pix2jpg incluído en Gem. Archivos de construcción de Gem modificados.
- Añadido fichero ompiling.txt con instrucciones de compilación
This commit is contained in:
Santi Noreña 2013-02-04 18:00:17 +01:00
parent c9adfd020b
commit e85d191b46
3100 changed files with 775434 additions and 3073 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
#ifndef _INCLUDE_GEMPLUGIN__VIDEOPYLON_CAMERAPROPERTIES_H_
#define _INCLUDE_GEMPLUGIN__VIDEOPYLON_CAMERAPROPERTIES_H_
#include "pylon/PylonIncludes.h"
#include <pylon/gige/BaslerGigECamera.h>
#include <string>
#include "Gem/Properties.h"
namespace gem { namespace pylon { namespace cameraproperties {
void init(void);
gem::Properties&getKeys(void);
gem::Properties&setKeys(void);
void get(Pylon::CBaslerGigECamera*device,
std::string key,
gem::any&result);
bool set(Pylon::CBaslerGigECamera*device,
std::string key,
gem::Properties&props);
};};};
#endif /* _INCLUDE_GEMPLUGIN__VIDEOPYLON_CAMERAPROPERTIES_H_ */

View file

@ -0,0 +1,25 @@
Copyright (C) 2010 IOhannes m zmölnig
Institute of Electronic Music and Acoustics (IEM), Graz, Austria
University of Music and Performing Arts (KUG), Graz, Austria
forum::für::umläute
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, see <http://www.gnu.org/licenses>.
Additional permission under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or combining it
with PYLON (or a modified version of that library), containing parts covered by
the terms of the Basler Vision Technologies AG - Software License Agreement,
the licensors of this Program grant you additional permission to convey the
resulting work.

View file

@ -0,0 +1,46 @@
ACLOCAL_AMFLAGS = -I ../../m4 -I .
AM_CPPFLAGS = -I$(srcdir)/../../src
EXTRA_DIST = pylon.m4 LICENSE.txt README.txt
EXTRA_DIST += win-vs2003/videoPYLON.sln win-vs2003/videoPYLON.vcproj
EXTRA_DIST += win-vs2008/videoPYLON.sln win-vs2008/videoPYLON.vcproj
plugindir=$(libdir)/Gem
plugin_LTLIBRARIES=
dist_plugin_DATA =
if HAVE_PYLON
plugin_LTLIBRARIES+= gem_videoPYLON.la
dist_plugin_DATA += pylon-videoplugin.pd
endif
gem_videoPYLON_la_CXXFLAGS =
gem_videoPYLON_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_videoPYLON_la_LDFLAGS += -no-undefined
endif
gem_videoPYLON_la_LIBADD =
# RTE
gem_videoPYLON_la_CXXFLAGS += @GEM_RTE_CFLAGS@
gem_videoPYLON_la_LDFLAGS += @GEM_RTE_LIBS@
#gem_videoPYLON_la_CXXFLAGS += @GEM_ARCH_CXXFLAGS@
#gem_videoPYLON_la_LDFLAGS += @GEM_ARCH_LDFLAGS@
# #gem_videoPYLON_la @MOREFLAGS@
# Dependencies
gem_videoPYLON_la_CXXFLAGS += @GEM_PYLON_CXXFLAGS@
gem_videoPYLON_la_LIBADD += @GEM_PYLON_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_videoPYLON_la_SOURCES= videoPYLON.cpp videoPYLON.h \
CameraProperties.cpp CameraProperties.h \
StreamGrabberProperties.cpp StreamGrabberProperties.h

View file

@ -0,0 +1,171 @@
videoPYLON
===========
PYLON-backend for pix_video
PYLON is a proprietary library that can do image-acquisition from
a number of GigE-cameras, available from Basler Vision Technologies.
You have to download pylon yourself.
At time o writing pylon is free as in beer, however it is not OpenSource.
http://www.baslerweb.com/ (and search for "pylon")
installation instructions for linux
===================================
0. obvious prerequisites
you need a C++-compiler, Pd (inclusing headers) and the Gem-sources (including
the videoPYLON plugin)
you should have Gem running (preferrably self-compiled)
1. getting PYLON
get PYLON and install it onto your computer (and make sure to read their
installation instructions).
the directory you installed into shall henceforward be referred to as PYLON_ROOT
note: when running anything PYLONic, you will need to set PYLON_ROOT, GENICAM_ROOT_V1_1 as
environment-variables;
you will also have to set your library path, so the dynamic linker will find the
pylon libraries as needed.
for testing it makes also sense to add the pylon's bin-path to your PATH.
it's a good idea to do so right now:
e.g.
$ export PYLON_ROOT=${HOME}/lib/pylon
$ export GENICAM_ROOT_V1_1=${PYLON_ROOT}
$ export PATH=${PYLON_ROOT}/bin/:${PATH}
$ export LD_LIBRARY_PATH=${PYLON_ROOT}/lib
$ PylonViewerApp
if all went well, you should see a number of files from the pylon installation.
if not, adapt PYLON_ROOT to your system (and/or read PYLON's README again)
notes on LD_LIBRARY_PATH:
- if you already have set the LD_LIBRARY_PATH to something else before, make
sure _add_ to it:
$ export LD_LIBRARY_PATH=${PYLON_ROOT}/lib:${LD_LIBRARY_PATH}
- on 64bit systems, you might need to set it to
$ export LD_LIBRARY_PATH=${PYLON_ROOT}/lib64
instead
2. compiling videoPYLON
open a terminal and enter this directory
$ cd [Gem]/src/plugins/videoPYLON/
if you haven't done so yet, run autoreconf
$ autoreconf -fiv
(if you built Gem from source, you might have already done so)
now run configure
you will have to tell configure where to find your PYLON.
if you have set PYLON_ROOT, then the PYLON-framework
should be detected automatically, so just run:
$ ./configure
if you haven't set the environment variables, you can specify them via
configure-flags, e.g.:
$ ./configure --with-pylon=${HOME}/lib/pylon
you might also have to tell configure where to find the Pd-sources by specifying
the /path/to/pd with the "--with-pd=" flag.
for more information try:
$ ./configure --help
if all went well, you should see a line "checking for PYLON... yes" near the
end of configure's output.
now run the build:
$ make
you will get an error-message if something failed.
if you want, you can install the plugin into /usr/local/lib/pd/extra/Gem (or
wherever you specified with the "--libdir=" flag, by running
$ make install
you can also manually install the plugin, by copying the file
".libs/gem_videoPYLON.so" next to your Gem-binary.
3. using videoPYLON
start Pd/Gem
create an object [pix_video]
on the Pd-console, you should see (among other things) something like:
"[pix_video]: backend #0='pylon' : pylon gige"
the backend-# will be different) depending on the number of video-backends found
on your system; it's only important that you find one backend named "pylon"
probably this won't work, with Gem complaining that it cannot find
"libpylonbase.so" or similar.
in this case should tell the linker where to find the pylon-libraries, using
the LD_LIBRARY_PATH variable:
$ LD_LIBRARY_PATH=${PYLON_ROOT}/lib pd -lib Gem
should do the trick. (see above, section 2)
once the plugin loaded correctly, you can start using it.
tell [pix_video] to open a device named like
"Basler scA640-120gm#0030530F8E64#192.168.1.100:3956"
(that's a single long symbol with _spaces_ (and without quotes)!)
The name consists of vendor, modelname, MAC-address, IP-address and port, which
allows one to quite uniquely identify your camera.
Since such names are a bit awkward to use, you probably want to:
1: connect to your camera with something like "PylonViewerApp" and change
"user defined name" to something like "mycam"
2: enumerate all available devices (using the "enumerate" message to
[pix_video]
3: access the device with it's short name "mycam".
you really have to run the "enumerate" in order to make [pix_video] aware of the
user definee name!
examples:
[list Basler scA640-120gm#0030530F8E64#192.168.1.100:3956(
|
[symbol2list]
|
[device $1(
will search for a GigE-camera (scout scA640-120g) at the specified IP/MAC-address
and connect.
[enumerate, device mycam(
will search for the cam named "mycam"
possible issues (FAQ)
=====================
Q1: my image quality is bad (white stripes)
A1: make sure you have a Gigabit-Ethernet card and enable "Jumbo Frames"
you can do so by setting the MTU of your network card to 8000-9000
e.g. use (as root):
# ifconfig eth1 mtu 9500
Q2: i called the "resetDevice" command on the camera, and now it stopped working
(it grabs some images and then stops)
A2: make sure you have "Jumbo Frames" also enabled on the _camera_!
there is a parameter (in PylonViewerApp it is only visible in professional mode
and it is somewhere in the "Transport" section) called either "PayloadSize" or
"GevSCPSPacketSize" which you should set to the same value as your MTU.
see the pylon documentation for more info
Q3: it doesn't work reliably (e.g. it works a bit, and then stops)
A3: make sure you have "Jumbo Frames" on both your network card and your camera
fmgasdr
IOhannes m zmölnig
Graz, 18.11.2010

View file

@ -0,0 +1,408 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file:
// handling of getting/setting pylon/baslergigestreamgrabber properties
//
// Copyright (c) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "LICENSE.txt"
//
/////////////////////////////////////////////////////////
// get StreamGrabber attributes
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_PYLON
#include "StreamGrabberProperties.h"
#include "map"
namespace gem{namespace pylon{namespace streamgrabberproperties{
static gem::Properties writeprops, readprops;
typedef Pylon::CBaslerGigEStreamGrabber DEVICE;
#define GETSETBOOL(T) \
static bool get##T(DEVICE*device) { return device->T.GetValue(); } \
static void set##T(DEVICE*device, const bool v) { device->T.SetValue(v); }
#define GETSETINT(T) \
static int64_t get##T(DEVICE*device) { return device->T.GetValue(); } \
static void set##T(DEVICE*device, const int64_t v) { device->T.SetValue(v); }
#define GETSETFLOAT(T) \
static double get##T(DEVICE*device) { return device->T.GetValue(); } \
static void set##T(DEVICE*device, const double v) { device->T.SetValue(v); }
#define GETSETSTRING(T) \
static void set##T(DEVICE*device, const GenICam::gcstring v) { device->T.SetValue(v); } \
static GenICam::gcstring get##T(DEVICE*device) { return device->T.GetValue(); }
#define GETSETCOMMAND(T) \
static void set##T(DEVICE*device) { device->T.Execute(); }
#define GETSETENUM(T) \
std::map<std::string, enum T##Enums> enumap_##T; \
static std::string get##T (DEVICE*device) { \
const enum T##Enums v=device->T.GetValue(); \
std::map<std::string, T##Enums>::iterator it; \
for (it=enumap_##T.begin(); it != enumap_##T.end(); ++it) { \
if(v==it->second) \
return (it->first); \
} \
return std::string("unknown"); \
} \
static void setS_##T (DEVICE*device, const std::string s) { \
std::map<std::string, T##Enums>::iterator it=enumap_##T.find(s); \
if(it!=enumap_##T.end()) \
device->T.SetValue(it->second); \
else throw OUT_OF_RANGE_EXCEPTION(s.c_str()); \
} \
static void setI_##T (DEVICE*device, const int i) { \
if(i<0 || i>=enumap_##T.size()) { \
std::stringstream ss; \
ss << "Out of range: " << i << " must be within [0.."<<enumap_##T.size()<<")"; \
throw OUT_OF_RANGE_EXCEPTION(ss.str()); \
} \
else { \
const enum T##Enums v=static_cast<T##Enums>(i); \
device->T.SetValue(v); \
} \
}
typedef bool (*t_getbool)(DEVICE*device);
std::map<std::string, t_getbool>map_getbool;
typedef void (*t_setbool)(DEVICE*device, const bool);
std::map<std::string, t_setbool>map_setbool;
GETSETBOOL(EnableResend);
GETSETBOOL(ReceiveThreadPriorityOverride);
typedef int64_t (*t_getint)(DEVICE*device);
std::map<std::string, t_getint>map_getint;
typedef void (*t_setint)(DEVICE*device, const int64_t);
std::map<std::string, t_setint>map_setint;
GETSETINT(MaxNumBuffer);
GETSETINT(MaxBufferSize);
GETSETINT(PacketTimeout);
GETSETINT(ReceiveWindowSize);
GETSETINT(ResendRequestThreshold);
GETSETINT(ResendRequestBatching);
GETSETINT(ResendTimeout);
GETSETINT(ResendRequestResponseTimeout);
GETSETINT(MaximumNumberResendRequests);
GETSETINT(FrameRetention);
GETSETINT(ReceiveThreadPriority);
GETSETINT(SocketBufferSize);
GETSETINT(TypeIsWindowsIntelPerformanceDriverAvailable);
GETSETINT(TypeIsWindowsFilterDriverAvailable);
GETSETINT(TypeIsSocketDriverAvailable);
GETSETINT(Statistic_Total_Buffer_Count);
GETSETINT(Statistic_Failed_Buffer_Count);
GETSETINT(Statistic_Buffer_Underrun_Count);
GETSETINT(Statistic_Total_Packet_Count);
GETSETINT(Statistic_Failed_Packet_Count);
GETSETINT(Statistic_Resend_Request_Count);
GETSETINT(Statistic_Resend_Packet_Count);
GETSETINT(DestinationPort);
typedef GenICam::gcstring (*t_getstring)(DEVICE*device);
std::map<std::string, t_getstring>map_getstring;
typedef void (*t_setstring)(DEVICE*device, GenICam::gcstring);
std::map<std::string, t_setstring>map_setstring;
GETSETSTRING(DestinationAddr);
typedef std::string (*t_getenum)(DEVICE*device);
typedef void (*t_setenum)(DEVICE*device, const std::string);
typedef void (*t_setenumi)(DEVICE*device, const int);
std::map<std::string, t_getenum>map_getenum;
std::map<std::string, t_setenum>map_setenum;
std::map<std::string, t_setenumi>map_setenumi;
using namespace Basler_GigEStreamParams;
GETSETENUM(Status);
GETSETENUM(AccessMode);
GETSETENUM(TransmissionType);
};};};
void gem::pylon::streamgrabberproperties::init() {
static bool initialized=false;
if(initialized)return;
initialized=true;
#define MAP_GETSETBOOL(T) \
map_getbool[ #T ]=get##T; \
map_setbool[ #T ]=set##T
#define MAP_GETSETINT(T) \
map_getint[ #T ]=get##T; \
map_setint[ #T ]=set##T
#define MAP_GETSETFLOAT(T) \
map_getfloat[ #T ]=get##T; \
map_setfloat[ #T ]=set##T
#define MAP_GETSETSTRING(T) \
map_getstring[ #T ]=get##T; \
map_setstring[ #T ]=set##T
#define MAP_GETSETCOMMAND(T) \
map_setcommand[ #T ]=set##T
#define MAP_GETSETENUM(T) \
map_getenum[ #T ]=get##T; \
map_setenum[ #T ]=setS_##T; \
map_setenumi[ #T ]=setI_##T
map_getbool.clear();
map_setbool.clear();
MAP_GETSETBOOL(EnableResend);
MAP_GETSETBOOL(ReceiveThreadPriorityOverride);
map_getint.clear();
map_setint.clear();
MAP_GETSETINT(MaxNumBuffer);
MAP_GETSETINT(MaxBufferSize);
MAP_GETSETINT(PacketTimeout);
MAP_GETSETINT(ReceiveWindowSize);
MAP_GETSETINT(ResendRequestThreshold);
MAP_GETSETINT(ResendRequestBatching);
MAP_GETSETINT(ResendTimeout);
MAP_GETSETINT(ResendRequestResponseTimeout);
MAP_GETSETINT(MaximumNumberResendRequests);
MAP_GETSETINT(FrameRetention);
MAP_GETSETINT(ReceiveThreadPriority);
MAP_GETSETINT(SocketBufferSize);
MAP_GETSETINT(TypeIsWindowsIntelPerformanceDriverAvailable);
MAP_GETSETINT(TypeIsWindowsFilterDriverAvailable);
MAP_GETSETINT(TypeIsSocketDriverAvailable);
MAP_GETSETINT(Statistic_Total_Buffer_Count);
MAP_GETSETINT(Statistic_Failed_Buffer_Count);
MAP_GETSETINT(Statistic_Buffer_Underrun_Count);
MAP_GETSETINT(Statistic_Total_Packet_Count);
MAP_GETSETINT(Statistic_Failed_Packet_Count);
MAP_GETSETINT(Statistic_Resend_Request_Count);
MAP_GETSETINT(Statistic_Resend_Packet_Count);
MAP_GETSETINT(DestinationPort);
map_getstring.clear();
map_setstring.clear();
MAP_GETSETSTRING(DestinationAddr);
map_getenum.clear();
map_setenum.clear();
map_setenumi.clear();
MAP_GETSETENUM(Status);
MAP_GETSETENUM(AccessMode);
MAP_GETSETENUM(TransmissionType);
enumap_Status.clear();
enumap_AccessMode.clear();
enumap_TransmissionType.clear();
enumap_Status["NotInitialized"]=Status_NotInitialized;
enumap_Status["Closed"]=Status_Closed;
enumap_Status["Open"]=Status_Open;
enumap_Status["Locked"]=Status_Locked;
enumap_AccessMode["NotInitialized"]=AccessMode_NotInitialized;
enumap_AccessMode["Monitor"]=AccessMode_Monitor;
enumap_AccessMode["Control"]=AccessMode_Control;
enumap_AccessMode["Exclusive"]=AccessMode_Exclusive;
enumap_TransmissionType["UseCameraConfig"]=TransmissionType_UseCameraConfig;
enumap_TransmissionType["Unicast"]=TransmissionType_Unicast;
enumap_TransmissionType["Multicast"]=TransmissionType_Multicast;
enumap_TransmissionType["LimitedBroadcast"]=TransmissionType_LimitedBroadcast;
enumap_TransmissionType["SubnetDirectedBroadcast"]=TransmissionType_SubnetDirectedBroadcast;
}
gem::Properties&gem::pylon::streamgrabberproperties::getKeys(void) {
gem::Properties&result=readprops; result.clear();
gem::pylon::streamgrabberproperties::init();
do {
gem::any typevalue=1;
std::map<std::string, t_getbool>::iterator it;
for(it=map_getbool.begin(); it!=map_getbool.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
do {
gem::any typevalue=0;
std::map<std::string, t_getint>::iterator it;
for(it=map_getint.begin(); it!=map_getint.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
do {
gem::any typevalue=std::string("symbol");
std::map<std::string, t_getstring>::iterator it;
for(it=map_getstring.begin(); it!=map_getstring.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
/* enumeration */
do {
gem::any typevalue=std::string("symbol");
std::map<std::string, t_setenum>::iterator it;
for(it=map_setenum.begin(); it!=map_setenum.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
return result;
}
gem::Properties&gem::pylon::streamgrabberproperties::setKeys(void) {
gem::Properties&result=writeprops; result.clear();
gem::pylon::streamgrabberproperties::init();
do {
gem::any typevalue=1;
std::map<std::string, t_setbool>::iterator it;
for(it=map_setbool.begin(); it!=map_setbool.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
do {
gem::any typevalue=0;
std::map<std::string, t_setint>::iterator it;
for(it=map_setint.begin(); it!=map_setint.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
do {
gem::any typevalue=std::string("symbol");
std::map<std::string, t_setstring>::iterator it;
for(it=map_setstring.begin(); it!=map_setstring.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
/* enumeration */
do {
gem::any typevalue=std::string("symbol");
std::map<std::string, t_setenum>::iterator it;
for(it=map_setenum.begin(); it!=map_setenum.end(); ++it) {
result.set(it->first, typevalue);
}
} while(0);
return result;
}
void gem::pylon::streamgrabberproperties::get(DEVICE*device,
std::string key,
gem::any&result)
{
gem::pylon::streamgrabberproperties::init();
std::map<std::string, t_getbool>::iterator it_b=map_getbool.find(key);
if(it_b != map_getbool.end()) {
result=static_cast<double>(it_b->second(device));
return;
}
std::map<std::string, t_getint>::iterator it_i=map_getint.find(key);
if(it_i != map_getint.end()) {
result=static_cast<double>(it_i->second(device));
return;
}
std::map<std::string, t_getstring>::iterator it_s=map_getstring.find(key);
if(it_s != map_getstring.end()) {
result=std::string((it_s->second(device)).c_str());
return;
}
std::map<std::string, t_getenum>::iterator it=map_getenum.find(key);
if(it!=map_getenum.end()) {
result=it->second(device);
}
}
// set StreamGrabber attributes
bool gem::pylon::streamgrabberproperties::set(DEVICE*device,
std::string key,
gem::Properties&props)
{
double d;
std::string s;
gem::pylon::streamgrabberproperties::init();
std::map<std::string, t_setbool>::iterator it_b=map_setbool.find(key);
if(it_b != map_setbool.end()) {
if(props.get(key, d)) {
it_b->second(device, static_cast<bool>(d));
return true;
} else {
return false;
}
}
std::map<std::string, t_setint>::iterator it_i=map_setint.find(key);
if(it_i != map_setint.end()) {
if(props.get(key, d)) {
it_i->second(device, static_cast<int64_t>(d));
return true;
} else {
return false;
}
}
std::map<std::string, t_setstring>::iterator it_s=map_setstring.find(key);
if(it_s != map_setstring.end()) {
if(props.get(key, s)) {
GenICam::gcstring gs(s.c_str());
it_s->second(device, gs);
return true;
} else {
return false;
}
}
std::map<std::string, t_setenum>::iterator it_e=map_setenum.find(key);
if(it_e != map_setenum.end()) {
if(props.get(key, s)) {
it_e->second(device, s);
} else if(props.get(key, d)) {
std::map<std::string, t_setenumi>::iterator it_ei=map_setenumi.find(key);
if(it_ei != map_setenumi.end()) {
it_ei->second(device, d);
}
}
return true;
}
return false;
}
#endif /* HAVE_PYLON */

View file

@ -0,0 +1,26 @@
#ifndef _INCLUDE_GEMPLUGIN__VIDEOPYLON_STREAMGRABBERPROPERTIES_H_
#define _INCLUDE_GEMPLUGIN__VIDEOPYLON_STREAMGRABBERPROPERTIES_H_
#include "pylon/PylonIncludes.h"
# include <pylon/gige/BaslerGigECamera.h>
#include <string>
#include "Gem/Properties.h"
namespace gem { namespace pylon { namespace streamgrabberproperties {
void init(void);
gem::Properties&getKeys(void);
gem::Properties&setKeys(void);
void get(Pylon::CBaslerGigEStreamGrabber*device,
std::string key,
gem::any&result);
bool set(Pylon::CBaslerGigEStreamGrabber*device,
std::string key,
gem::Properties&props);
};};};
#endif /* _INCLUDE_GEMPLUGIN__VIDEOPYLON_STREAMGRABBERPROPERTIES_H_ */

View file

@ -0,0 +1,24 @@
AC_PREREQ(2.60)
AC_INIT([videoPYLON],[0.1],[zmoelnig@iem.at], [], [http://gem.iem.at])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([../../m4])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([videoPYLON.cpp])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile])
AC_PROG_CXX
AC_PROG_LIBTOOL
#AM_SANITY_CHECK
GEM_CHECK_RTE
AC_LANG(C++)
GEM_CHECK_PYLON
AC_OUTPUT

View file

@ -0,0 +1,2 @@
#N canvas 8 49 505 112 10;
#X text 89 47 Nothing special about this backend...;

View file

@ -0,0 +1,88 @@
#g++ -O6 -march=pentium -mtune=pentiumpro -I/home/zmoelnig/pylon//include -I/home/zmoelnig/pylon//include/cpp ./ean13.cpp -I/home/zmoelnig/pylon//include -I/home/zmoelnig/pylon//include/cpp \
# -L/usr/X11R6/lib -lXext -lX11 -lpthread -lm -ldl -L/home/zmoelnig/pylon//lib/x86-linux2.4-gcc40/ -lpyloncpp -lpylon -o ../bin/x86-linux2.4-gcc40/ean13
## CFLAGS: -I${PYLON_ROOT}/include -I${GENICAM_ROOT_V1_1}/include -I${GENICAM_ROOT_V1_1}/include/genicam
## LDFLAGS: -L${PYLON_ROOT}/lib -L${GENICAM_ROOT_V1_1}/lib -L${PYLON_ROOT}/lib64 -L${GENICAM_ROOT_V1_1}/lib64 -lpylonbase
AC_DEFUN([GEM_CHECK_PYLON],
[
AC_ARG_VAR([PYLON_ROOT], [root-directory where you installed PYLON (override this with '--with-pylon=${PYLON_ROOT}'])dnl
AC_ARG_VAR([PYLONARCH], [architecture for you PYLON-installation (e.g. 'x86-linux2.4-gcc40'])dnl
AC_ARG_WITH([pylon],
AC_HELP_STRING([--with-pylon], [enable PYLON video capturing (overrides $PYLON_ROOT)]))
have_pylon="no"
if test "x$with_pylon" != "xno"; then
if test -d "${with_pylon}" ; then
PYLON_ROOT=${with_pylon}
fi
if test "x${GENICAM_ROOT_V1_1}" = "x"; then
GENICAM_ROOT_V1_1="${PYLON_ROOT}"
fi
tmp_pylon_includes=""
if test -d "${PYLON_ROOT}/include" ; then
AC_LIB_APPENDTOVAR([tmp_pylon_includes], "-I${PYLON_ROOT}/include")
fi
if test -d "${GENICAM_ROOT_V1_1}/include" ; then
AC_LIB_APPENDTOVAR([tmp_pylon_includes], "-I${GENICAM_ROOT_V1_1}/include")
fi
if test -d "${GENICAM_ROOT_V1_1}/include/genicam" ; then
AC_LIB_APPENDTOVAR([tmp_pylon_includes], "-I${GENICAM_ROOT_V1_1}/include/genicam")
fi
if test -d "${PYLON_ROOT}/lib" ; then
tmp_pylon_ldflags="-L${PYLON_ROOT}/lib"
fi
if test -d "${PYLON_ROOT}/lib64" ; then
tmp_pylon_ldflags="-L${PYLON_ROOT}/lib64"
fi
if test -d "${GENICAM_ROOT_V1_1}/lib" ; then
tmp_pylon_ldflags="-L${GENICAM_ROOT_V1_1}/lib"
fi
if test -d "${GENICAM_ROOT_V1_1}/lib64" ; then
tmp_pylon_ldflags="-L${GENICAM_ROOT_V1_1}/lib64"
fi
tmp_pylon_ldflags="-lpylonbase -lpylonutility ${tmp_pylon_ldflags}"
tmp_pylon_cppflags_org="$CPPFLAGS"
tmp_pylon_libs_org="$LIBS"
CPPFLAGS="$CPPFLAGS $tmp_pylon_includes"
LIBS="-lm"
AC_CHECK_HEADER([pylon/PylonIncludes.h],
[
have_pylon="yes"
],[
have_pylon="no"
])
if test "x$have_pylon" = "xyes"; then
AC_CHECK_LIB(pylonbase, main, , [have_pylon="no"], ["${tmp_pylon_ldflags}"])
AC_CHECK_LIB(pylonutility, main, , [have_pylon="no"], ["${tmp_pylon_ldflags}"])
fi
CPPFLAGS="$tmp_pylon_cppflags_org"
LIBS="$tmp_pylon_libs_org"
if test "x$have_pylon" = "xyes"; then
AC_DEFINE([HAVE_PYLON], [1], [video capturing using Basler's PYLON])
GEM_PYLON_CXXFLAGS="${tmp_pylon_includes}"
GEM_PYLON_LIBS="${tmp_pylon_ldflags}"
fi
AC_MSG_CHECKING([for PYLON])
AC_MSG_RESULT([$have_pylon])
fi
AM_CONDITIONAL(HAVE_PYLON, test x$have_pylon = xyes)
AC_SUBST(GEM_PYLON_CXXFLAGS)
AC_SUBST(GEM_PYLON_LIBS)
])

View file

@ -0,0 +1,803 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "LICENSE.txt"
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined HAVE_LIBPYLON
# define HAVE_PYLON
#endif
#ifdef HAVE_PYLON
#include "videoPYLON.h"
#include "plugins/PluginFactory.h"
#include <sstream>
using namespace gem::plugins;
#define NUM_BUFFERS 8
#include "Gem/RTE.h"
#include "Gem/Exception.h"
#if 0
# define debug ::post
#else
# define debug
#endif
using namespace Basler_GigECameraParams;
using namespace Basler_GigEStreamParams;
#include "CameraProperties.h"
#include "StreamGrabberProperties.h"
// Constructor allocates the image buffer
class videoPYLON::CGrabBuffer {
static int buffercount;
public:
CGrabBuffer(const size_t ImageSize)
: m_pBuffer(NULL) {
buffercount++;
m_pBuffer = new uint8_t[ ImageSize ];
if (NULL == m_pBuffer)
{
GenICam::GenericException e("Not enough memory to allocate image buffer", __FILE__, __LINE__);
throw e;
}
}
// Freeing the memory
~CGrabBuffer() {
if (NULL != m_pBuffer)
delete[] m_pBuffer;
buffercount--;
}
uint8_t* GetBufferPointer(void) { return m_pBuffer; }
Pylon::StreamBufferHandle GetBufferHandle(void) { return m_hBuffer; }
void SetBufferHandle(Pylon::StreamBufferHandle hBuffer) { m_hBuffer = hBuffer; };
protected:
uint8_t *m_pBuffer;
Pylon::StreamBufferHandle m_hBuffer;
};
int videoPYLON::CGrabBuffer::buffercount=0;
struct videoPYLON::Converter {
#ifdef HAVE_LIBPYLONUTILITY
Pylon::CPixelFormatConverter*converter;
#endif
imageStruct image;
struct Pylon::SImageFormat inFormat;
struct Pylon::SOutputImageFormat outFormat;
Converter(void)
#ifdef HAVE_LIBPYLONUTILITY
: converter(NULL)
#endif
{
}
~Converter(void) {
destroyConverter();
}
void destroyConverter(void) {
#ifdef HAVE_LIBPYLONUTILITY
if(converter) {
delete converter;
converter=NULL;
}
#endif
}
void makeConverter(const struct Pylon::SImageFormat&format) {
destroyConverter();
using namespace Pylon;
bool rgba_out=false;
bool need_converter=true;
#ifdef HAVE_LIBPYLONUTILITY
switch(format.PixelFormat) {
case PixelType_Mono8:
case PixelType_Mono8signed:
/* no converter needed */
need_converter=false;
rgba_out=false;
break;
case PixelType_RGBA8packed:
/* no converter needed */
need_converter=false;
rgba_out=true;
break;
case PixelType_Mono10:
case PixelType_Mono12:
case PixelType_Mono16:
converter= new Pylon::CPixelFormatConverterGamma ();
// converter= new Pylon::CPixelFormatConverterTruncate ();
rgba_out=false;
break;
case PixelType_Mono10packed:
case PixelType_Mono12packed:
converter= new Pylon::CPixelFormatConverterGammaPacked ();
// converter= new Pylon::CPixelFormatConverterTruncatePacked ();
rgba_out=false;
break;
case PixelType_BayerGR8:
case PixelType_BayerRG8:
case PixelType_BayerGB8:
case PixelType_BayerBG8:
case PixelType_BayerGR10:
case PixelType_BayerRG10:
case PixelType_BayerGB10:
case PixelType_BayerBG10:
case PixelType_BayerGR12:
case PixelType_BayerRG12:
case PixelType_BayerGB12:
case PixelType_BayerBG12:
case PixelType_BayerGB12Packed:
case PixelType_BayerGR12Packed:
case PixelType_BayerRG12Packed:
case PixelType_BayerBG12Packed:
case PixelType_BayerGR16:
case PixelType_BayerRG16:
case PixelType_BayerGB16:
case PixelType_BayerBG16:
converter= new Pylon::CPixelFormatConverterBayer ();
rgba_out=true;
break;
case PixelType_RGB8planar:
case PixelType_RGB10planar:
case PixelType_RGB12planar:
case PixelType_RGB16planar:
case PixelType_RGB8packed:
case PixelType_BGR8packed:
case PixelType_BGRA8packed:
case PixelType_RGB10packed:
case PixelType_BGR10packed:
case PixelType_RGB12packed:
case PixelType_BGR12packed:
case PixelType_BGR10V1packed:
case PixelType_BGR10V2packed:
converter= new Pylon::CPixelFormatConverterRGB ();
rgba_out=true;
break;
case PixelType_YUV422_YUYV_Packed:
converter= new Pylon::CPixelFormatConverterYUV422YUYV();
rgba_out=true;
break;
case PixelType_YUV422packed:
converter= new Pylon::CPixelFormatConverterYUV422();
rgba_out=true;
break;
case PixelType_YUV411packed:
case PixelType_YUV444packed:
case PixelType_RGB12V1packed:
// ?
break;
}
if(NULL==converter && need_converter) {
error("PYLON: could not find a converter for given colorspace");
}
if(converter)
converter->Init(format);
#endif
if(rgba_out) {
image.setCsizeByFormat(GL_RGBA);
} else {
image.setCsizeByFormat(GL_LUMINANCE);
}
}
static struct Pylon::SImageFormat getInFormat(const Pylon::GrabResult&Result) {
using namespace Pylon;
struct SImageFormat imageFormat;
const enum PixelType pixelType=Result.GetPixelType();
imageFormat.Width =Result.GetSizeX();
imageFormat.Height=Result.GetSizeY();
imageFormat.PixelFormat=pixelType;
imageFormat.LinePitch=IsPacked(pixelType)?
0:
(7+Result.GetSizeX()*BitPerPixel(pixelType)) >>3;
return imageFormat;
}
static struct Pylon::SOutputImageFormat getOutFormat(const imageStruct&img) {
using namespace Pylon;
struct SOutputImageFormat imageFormat;
switch(img.format) {
case GL_RGBA:
imageFormat.LinePitch=img.xsize*img.csize;
imageFormat.PixelFormat=Pylon::PixelType_RGBA8packed;
break;
case GL_LUMINANCE:
default:
imageFormat.LinePitch=img.xsize*img.csize;
imageFormat.PixelFormat=Pylon::PixelType_Mono8;
break;
}
return imageFormat;
}
bool convertFrom(Pylon::GrabResult Result) {
const struct Pylon::SImageFormat format=getInFormat(Result);
bool init=false;
#ifdef HAVE_LIBPYLONUTILITY
if(!converter)init=true;
if(converter && !converter->IsInitialized())init=true;
#endif
if(format!=inFormat)init=true;
if(init) {
makeConverter(format);
inFormat=format;
}
image.xsize=inFormat.Width;
image.ysize=inFormat.Height;
image.reallocate();
if(0) {;
#ifdef HAVE_LIBPYLONUTILITY
} else if(converter) {
const struct Pylon::SOutputImageFormat oformat=getOutFormat(image);
converter->Convert(image.data,
image.xsize*image.ysize*image.csize,
Result.Buffer(),
Result.GetPayloadSize(),
format,
oformat);
#endif
} else {
if(image.format==GL_RGBA)
image.fromRGBA(reinterpret_cast<unsigned char*>(Result.Buffer()));
else
image.fromGray(reinterpret_cast<unsigned char*>(Result.Buffer()));
}
return true;
}
bool convertTo(imageStruct&img) {
img.convertFrom(&image);
}
};
/////////////////////////////////////////////////////////
//
// videoPYLON
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
REGISTER_VIDEOFACTORY("pylon", videoPYLON);
videoPYLON :: videoPYLON() : videoBase("pylon")
, m_factory(NULL)
, m_camera(NULL)
, m_grabber(NULL)
, m_converter(new Converter())
, m_numBuffers(NUM_BUFFERS)
{
m_width=0;
m_height=0;
try {
m_factory = &Pylon::CTlFactory::GetInstance();
Pylon::TlInfoList_t tli;
int count= m_factory->EnumerateTls (tli);
int i=0;
for(i=0; i<count; i++) {
std::string s=tli[i].GetFriendlyName().c_str();
if("GigE"==s)
provide("gige");
provide(s);
}
} catch (GenICam::GenericException &e) {
// Error handling
throw(GemException(e.GetDescription()));
return;
}
}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
videoPYLON :: ~videoPYLON()
{
close();
}
////////////////////////////////////////////////////////
// frame grabber
//
/////////////////////////////////////////////////////////
bool videoPYLON :: grabFrame() {
if(NULL==m_camera || NULL==m_grabber)
return false;
struct Pylon::SImageFormat imageFormat;
struct Pylon::SOutputImageFormat outImageFormat;
if(m_grabber->GetWaitObject().Wait(3000)) {
Pylon::GrabResult Result;
m_grabber->RetrieveResult(Result);
switch(Result.Status()) {
case Pylon::Grabbed: {
m_converter->convertFrom(Result);
lock();
m_converter->convertTo(m_image.image);
m_image.image.upsidedown=true;
m_image.newimage=true;
unlock();
m_grabber->QueueBuffer(Result.Handle(), NULL);
}
break;
case Pylon::Failed:
std::cerr << "PYLON: grab failed and ";
default:
std::cerr << "PYLON: grab returned "<<Result.Status()<<std::endl;
break;
}
} else {
// timeout
std::cerr << "PYLON: grab timed out"<<std::endl;
m_grabber->CancelGrab();
return false;
}
return true;
}
/////////////////////////////////////////////////////////
// openDevice
//
/////////////////////////////////////////////////////////
bool videoPYLON :: openDevice(gem::Properties&props)
{
double d;
uint32_t channel=0;
if(props.get("channel", d))
channel=d;
if(m_camera)closeDevice();
if(NULL==m_factory)return false;
Pylon::IPylonDevice *device = NULL;
try {
if(m_devicename.empty()) {
if(m_id2device.empty())
enumerate();
std::map<std::string, Pylon::CDeviceInfo>::iterator it=m_id2device.begin();
if(m_devicenum>=0) {
std::advance( it, m_devicenum );
}
if(it != m_id2device.end()) {
device = m_factory->CreateDevice(it->second);
}
} else {
std::map<std::string, Pylon::CDeviceInfo>::iterator it=m_id2device.find(m_devicename);
if(it!=m_id2device.end())
device = m_factory->CreateDevice(it->second);
else
device = m_factory->CreateDevice(Pylon::String_t(m_devicename.c_str()));
}
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
return false;
}
if(device==NULL)
return false;
try {
m_camera=new Pylon::CBaslerGigECamera (device);
m_camera->Open();
uint32_t maxchannel=m_camera->GetNumStreamGrabberChannels();
if(channel>maxchannel)channel=maxchannel;
m_grabber=new Pylon::CBaslerGigEStreamGrabber(m_camera->GetStreamGrabber(channel));
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
close();
return false;
}
return true;
}
/////////////////////////////////////////////////////////
// closeDevice
//
/////////////////////////////////////////////////////////
void videoPYLON :: closeDevice() {
if(m_camera){
m_camera->Close();
delete m_camera;
}
m_camera=NULL;
if(m_grabber)delete m_grabber;
m_grabber=NULL;
}
/////////////////////////////////////////////////////////
// startTransfer
//
/////////////////////////////////////////////////////////
bool videoPYLON :: startTransfer()
{
if(NULL==m_camera)
return false;
if(NULL==m_grabber)
return false;
try {
m_grabber->Open();
// Set the image format and AOI
// m_camera->PixelFormat.SetValue(Basler_GigECameraParams::PixelFormat_Mono8Signed);
// m_camera->OffsetX.SetValue(0);
// m_camera->OffsetY.SetValue(0);
// m_camera->Width.SetValue(m_camera->Width.GetMax());
// m_camera->Height.SetValue(m_camera->Height.GetMax());
// Set the camera to continuous frame mode
/*
m_camera->TriggerSelector.SetValue(TriggerSelector_AcquisitionStart);
m_camera->TriggerMode.SetValue(TriggerMode_Off);
m_camera->AcquisitionMode.SetValue(AcquisitionMode_Continuous);
*/
// m_camera->ExposureMode.SetValue(ExposureMode_Timed);
// m_camera->ExposureTimeRaw.SetValue(100);
const size_t ImageSize = (size_t)(m_camera->PayloadSize.GetValue());
m_grabber->MaxBufferSize.SetValue(ImageSize);
m_grabber->MaxNumBuffer.SetValue(m_numBuffers);
m_grabber->PrepareGrab();
uint32_t i;
for (i = 0; i < m_numBuffers; ++i) {
CGrabBuffer *pGrabBuffer = new CGrabBuffer(ImageSize);
pGrabBuffer->SetBufferHandle(m_grabber->RegisterBuffer(
pGrabBuffer->GetBufferPointer(),
ImageSize));
// Put the grab buffer object into the buffer list
m_buffers.push_back(pGrabBuffer);
}
std::vector<CGrabBuffer*>::const_iterator x;
for (x=m_buffers.begin(); x != m_buffers.end(); ++x) {
// Put buffer into the grab queue for grabbing
m_grabber->QueueBuffer((*x)->GetBufferHandle(), NULL);
}
m_camera->AcquisitionStart.Execute();
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
return false;
}
return true;
}
/////////////////////////////////////////////////////////
// stopTransfer
//
/////////////////////////////////////////////////////////
bool videoPYLON :: stopTransfer()
{
if(m_camera) {
// Stop acquisition
try {
m_camera->AcquisitionStop.Execute();
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
}
}
if(m_grabber) {
try {
m_grabber->CancelGrab();
// Get all buffers back
Pylon::GrabResult r;
while(m_grabber->RetrieveResult(r)){;}
std::vector<CGrabBuffer*>::iterator it;
for (it = m_buffers.begin(); it != m_buffers.end(); it++) {
m_grabber->DeregisterBuffer((*it)->GetBufferHandle());
delete *it;
*it = NULL;
}
m_buffers.clear();
m_grabber->FinishGrab();
m_grabber->Close();
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
}
}
return true;
}
std::vector<std::string> videoPYLON::enumerate() {
m_id2device.clear();
std::vector<std::string> result;
if(NULL==m_factory)return result;
Pylon::DeviceInfoList_t devices;
if (0 == m_factory->EnumerateDevices(devices)) {
std::cout << "could not enumerate" << std::endl;
return result;
}
if(devices.empty() )
return result;
int i=0;
for(i=0; i<devices.size(); i++) {
std::string name;
Pylon::CDeviceInfo&device=devices[i];
bool added=false;
#if 1
#define SHOWNAME(x) std::cerr << x<<"["<<i<<"]: "<<name<<std::endl;
#else
#define SHOWNAME(x)
#endif
name=device.GetUserDefinedName();
if(!name.empty()) { m_id2device[name]=device; SHOWNAME("user")}
if(!added && !name.empty()) { result.push_back(name); added=true; }
try {
/* darn, this doesn't seem to work..., it would be great though */
Pylon::CBaslerGigEDeviceInfo&gdevice=dynamic_cast< Pylon::CBaslerGigEDeviceInfo&>(device);
name=gdevice.GetAddress ();
if(!name.empty()) { m_id2device[name]=device; SHOWNAME("address")}
if(!added && !name.empty()) { result.push_back(name); added=true; }
} catch (const std::bad_cast& e) {
// std::cerr << i<<" not a GigE&device"<<std::endl;
}
name=device.GetFullName();
if(!name.empty()) { m_id2device[name]=device; SHOWNAME("full")}
if(!added && !name.empty()) { result.push_back(name); added=true; }
name=device.GetSerialNumber();
if(!name.empty()) { m_id2device[name]=device; SHOWNAME("serial")}
if(!added && !name.empty()) { result.push_back(name); added=true; }
name=device.GetFriendlyName();
if(!name.empty()) { m_id2device[name]=device; SHOWNAME("friendly")}
if(!added && !name.empty()) { result.push_back(name); added=true; }
}
return result;
}
bool videoPYLON::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
int i=0;
gem::Properties props;
std::vector<std::string>keys;
gem::any type;
readable.clear();
writeable.clear();
props=gem::pylon::streamgrabberproperties::getKeys();
keys=props.keys();
if(m_grabber) {
GenApi::INodeMap*nodes=m_grabber->GetNodeMap();
for(i=0; i<keys.size(); i++) {
GenApi::INode *node=nodes->GetNode(keys[i].c_str());
if(node) {
switch(node->GetAccessMode()) {
case GenApi::RO: case GenApi::RW:
readable.set(keys[i], props.get(keys[i]));
default:
break;
}
}
}
} else {
#if 0
for(i=0; i<keys.size(); i++)
readable.set(keys[i], type);
#endif
}
props=gem::pylon::streamgrabberproperties::setKeys();
keys=props.keys();
if(m_grabber) {
GenApi::INodeMap*nodes=m_grabber->GetNodeMap();
for(i=0; i<keys.size(); i++) {
GenApi::INode *node=nodes->GetNode(keys[i].c_str());
if(node) {
switch(node->GetAccessMode()) {
case GenApi::WO: case GenApi::RW:
writeable.set(keys[i], props.get(keys[i]));
default:
break;
}
}
}
} else {
#if 0
for(i=0; i<keys.size(); i++)
writeable.set(keys[i], type);
#endif
}
props=gem::pylon::cameraproperties::getKeys();
keys=props.keys();
if(m_camera) {
GenApi::INodeMap*nodes=m_camera->GetNodeMap();
for(i=0; i<keys.size(); i++) {
GenApi::INode *node=nodes->GetNode(keys[i].c_str());
if(node) {
switch(node->GetAccessMode()) {
case GenApi::RO: case GenApi::RW:
readable.set(keys[i], props.get(keys[i]));
default:
break;
}
}
}
} else {
#if 0
for(i=0; i<keys.size(); i++)
readable.set(keys[i], type);
#endif
}
props=gem::pylon::cameraproperties::setKeys();
keys=props.keys();
if(m_camera) {
GenApi::INodeMap*nodes=m_camera->GetNodeMap();
for(i=0; i<keys.size(); i++) {
GenApi::INode *node=nodes->GetNode(keys[i].c_str());
if(node) {
switch(node->GetAccessMode()) {
case GenApi::WO: case GenApi::RW:
writeable.set(keys[i], props.get(keys[i]));
default:
break;
}
}
}
} else {
#if 0
for(i=0; i<keys.size(); i++)
writeable.set(keys[i], type);
#endif
}
#if 0
if(m_camera) {
try {
const Pylon::CDeviceInfo & di=m_camera->GetDeviceInfo();
Pylon::StringList_t names;
di.GetPropertyNames (names);
int i=0;
for(i=0; i<names.size(); i++) {
std::string key=names[i].c_str();
// std::cerr << "property#"<<i<<": "<<names[i]<<std::endl;
writeable.set(key, type);
readable.set (key, type);
}
} catch (GenICam::GenericException &e) {
std::cerr << e.GetDescription() << std::endl;
return false;
}
}
#endif
return false;
}
void videoPYLON::setProperties(gem::Properties&props) {
std::vector<std::string>keys=props.keys();
int i=0;
for(i=0; i<keys.size(); i++) {
const std::string key=keys[i];
bool didit=false;
if(m_grabber) {
try {
didit=gem::pylon::streamgrabberproperties::set(m_grabber, key, props);
} catch (GenICam::GenericException &e) {
error("videoPYLON: [%s] %s", key.c_str(), e.GetDescription());
//std::cerr << e.GetDescription() << std::endl;
didit=false;
}
}
if(!didit && m_camera)
try {
didit=gem::pylon::cameraproperties::set(m_camera, key, props);
} catch (GenICam::GenericException &e) {
error("videoPYLON: [%s] %s", key.c_str(), e.GetDescription());
//std::cerr << e.GetDescription() << std::endl;
didit=false;
}
}
}
void videoPYLON::getProperties(gem::Properties&props) {
std::vector<std::string>keys=props.keys();
int i=0;
for(i=0; i<keys.size(); i++) {
const std::string key=keys[i];
props.erase(key);
gem::any result;
if(m_grabber) {
try {
gem::pylon::streamgrabberproperties::get(m_grabber, key, result);
} catch (GenICam::GenericException &e) {result.reset(); }
}
if(result.empty() && m_camera)
try {
gem::pylon::cameraproperties::get(m_camera, key, result);
} catch (GenICam::GenericException &e) {result.reset(); }
if(result.empty())
continue;
props.set(key, result);
}
}
#endif /* HAVE_PYLON */

View file

@ -0,0 +1,113 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an video into a pix block
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
Linux version by Miller Puckette. msp@ucsd.edu
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__VIDEOPYLON_VIDEOPYLON_H_
#define _INCLUDE_GEMPLUGIN__VIDEOPYLON_VIDEOPYLON_H_
#include "plugins/videoBase.h"
#include <map>
#ifdef Status
/* ouch: Xlib.h defines "Status" as "int", but Pylon uses "Status" as a
* variable name
*/
# undef Status
#endif
#ifdef None
# undef None
#endif
#include "pylon/PylonIncludes.h"
#include <pylon/gige/BaslerGigECamera.h>
typedef Pylon::CBaslerGigECamera Camera_t;
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
pix_video
Loads in a video
KEYWORDS
pix
DESCRIPTION
"dimen" (int, int) - set the x,y dimensions
"zoom" (int, int) - the zoom factor (1.0 is nominal) (num / denom)
"bright" (int) - the brightnes
"contrast" (int) - the contrast
"hue" (int) - the hue
"sat" (int) - the saturation
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT videoPYLON : public videoBase {
public:
//////////
// Constructor
videoPYLON(void);
//////////
// Destructor
virtual ~videoPYLON(void);
////////
// open the video-device
virtual bool openDevice(gem::Properties&writeprops);
virtual void closeDevice(void);
//////////
// Start up the video device
// [out] bool - returns FALSE if bad
bool startTransfer(void);
//////////
// Stop the video device
// [out] bool - returns FALSE if bad
bool stopTransfer(void);
//////////
// get the next frame
bool grabFrame(void);
virtual std::vector<std::string>enumerate(void);
virtual bool enumProperties(gem::Properties&readable,
gem::Properties&writeable);
virtual void setProperties(gem::Properties&writeprops);
virtual void getProperties(gem::Properties&readprops);
protected:
class CGrabBuffer;
Pylon::PylonAutoInitTerm autoInitTerm;
Pylon::CTlFactory*m_factory;
Pylon::CBaslerGigECamera*m_camera;
Pylon::CBaslerGigEStreamGrabber*m_grabber;
class Converter;
Converter*m_converter;
uint32_t m_numBuffers;
std::vector<CGrabBuffer*> m_buffers;
std::map<std::string, Pylon::CDeviceInfo>m_id2device;
};
};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "videoPYLON", "videoPYLON.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="videoPYLON"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(PYLONROOT)\include&quot;;&quot;$(PYLONROOT)\include\cpp&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_PYLON"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib OLDNAMES.lib pylonbase.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(PYLONROOT)\lib\$(PYLONARCH)&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib OLDNAMES.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\videoPYLON.cpp">
</File>
<File
RelativePath="..\videoPYLON.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "videoPYLON", "videoPYLON.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="videoPYLON"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(PYLONROOT)\include&quot;;&quot;$(PYLONROOT)\include\cpp&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_PYLON"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib pylonbase.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(PYLONROOT)\lib\$(PYLONARCH)&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\videoPYLON.cpp">
</File>
<File
RelativePath="..\videoPYLON.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>