- 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

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 HALCON (or a modified version of that library), containing parts
covered by the terms of the MVTec Software GmbH - Software License Agreement for
HALCON , the licensors of this Program grant you additional permission to convey
the resulting work.

View file

@ -0,0 +1,44 @@
ACLOCAL_AMFLAGS = -I ../../m4 -I .
AM_CPPFLAGS = -I$(srcdir)/../../src
EXTRA_DIST = halcon.m4 LICENSE.txt README.txt
EXTRA_DIST += win-vs2003/videoHALCON.sln win-vs2003/videoHALCON.vcproj
EXTRA_DIST += win-vs2008/videoHALCON.sln win-vs2008/videoHALCON.vcproj
EXTRA_DIST += win-vs2008/HALCON.vsprops
plugindir=$(libdir)/Gem
plugin_LTLIBRARIES=
dist_plugin_DATA =
if HAVE_HALCON
plugin_LTLIBRARIES+= gem_videoHALCON.la
dist_plugin_DATA += halcon-videoplugin.pd
endif
gem_videoHALCON_la_CXXFLAGS =
gem_videoHALCON_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_videoHALCON_la_LDFLAGS += -no-undefined
endif
gem_videoHALCON_la_LIBADD =
# RTE
gem_videoHALCON_la_CXXFLAGS += @GEM_RTE_CFLAGS@
gem_videoHALCON_la_LDFLAGS += @GEM_RTE_LIBS@
#gem_videoHALCON_la_CXXFLAGS += @GEM_ARCH_CXXFLAGS@
#gem_videoHALCON_la_LDFLAGS += @GEM_ARCH_LDFLAGS@
# #gem_videoHALCON_la @MOREFLAGS@
# Dependencies
gem_videoHALCON_la_CXXFLAGS += @GEM_HALCON_CXXFLAGS@
gem_videoHALCON_la_LIBADD += @GEM_HALCON_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_videoHALCON_la_SOURCES= videoHALCON.cpp videoHALCON.h

View file

@ -0,0 +1,147 @@
videoHALCON
===========
HALCON-backend for pix_video
HALCON is a commercial library that can do image-acquisition from so-called
"professional" hardware, available from MVTec.
You have to purchase their framework (there might be a cheap evaluation version)
in order to use it with Gem.
http://www.mvtec.com/halcon/
installation instructions for linux
===================================
0. obvious prerequisites
you need a C++-compiler, Pd (inclusing headers) and the Gem-sources (including
the videoHALCON plugin)
you should have Gem running (preferrably self-compiled)
1. getting HALCON
get HALCON 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 HALCONROOT
the architecture you chose (eg. "x86-linux2.4-gcc40") shall be called HALCONARCH
note: when running anything HALCONic, you will need to set HALCONROOT and
HALCONARCH as environment-variables; it's a good idea to do so right now:
e.g.
$ export HALCONROOT=${HOME}/lib/halcon
$ export HALCONARCH=x86-linux2.4-gcc40
$ ls -l ${HALCONROOT}/lib/${HALCONARCH}
if all went well, you should see a number of files from the halcon installation.
if not, adapt HALCONROOT and HALCONARCH to your system.
2. compiling videoHALCON
open a terminal and enter this directory
$ cd [Gem]/src/plugins/videoHALCON/
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 HALCON.
if you have set HALCONROOT and HALCONARCH correctly, then the HALCON-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-halcon=${HOME}/lib/halcon --with-halconarch=x86-linux2.4-gcc40
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 HALCON... 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_videoHALCON.so" next to your Gem-binary.
3. using videoHALCON
start Pd/Gem
create an object [pix_video]
on the Pd-console, you should see (among other things) something like:
"[pix_video]: backend #0='halcon' : halcon iidc gige falcon"
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 "halcon"
probably this won't work, with Gem complaining that it cannot find
"libhalconcpp.so" or similar.
in this case should tell the linker where to find the halcon-libraries, using
the LD_LIBRARY_PATH variable:
$ LD_LIBRARY_PATH=${HALCONROOT}/lib/${HALCONARCH} pd -lib Gem
should do the trick.
an alternative would be to install the files found in
${HALCONROOT}/lib/${HALCONARCH} into your system's library folder (e.g.
/usr/local/lib/) and/or add this folder to /etc/ld.so.conf
afaik, you really MUST set the HALCONROOT, in order to make halcon find your
license files.
once the plugin loaded correctly, you can start using it.
tell [pix_video] to open a device named like "<name>:<cameratype>:<device>"
(that's 3 parameters, separated by colons)
the exact meaning of these parameters can be obtained from the HALCON
documentation for your halcon-backend
http://www.mvtec.com/download/release/hacq-x86sse2-linux2.4-gcc40-9.0.html
examples:
[device File:../examples/data/(
this will use the HALCON's "File" (virtual framegrabber) driver, that will read
all images in the ../examples/data directory and display them.
[device GigEVision::0013d453dbc1(
this will use the "GiGE" backend, using the "default" camera-description
(meaning that it will be obtained from the camera; you could also specify an
XML-file here), and connecting to the GiGE camera with the MAC-address
00:13:d4:53:db:c1
which exact HALCON-backends are available depends on what you have installed.
possible issues
===============
due to lack of hardware (and HALCONs outdated iidc interface) i have not been
able to test anything but the "File" backend.
in theory however, all should work
some backends (e.g. "1394IIDC") require a camera-type containing colons; since
colons are already used for delimiting, this obivously won't work.
if you have idea's (and code) to solve this, i will be happily include them.
fmgasdr
IOhannes m zmölnig
Graz, 23.06.2010

View file

@ -0,0 +1,24 @@
AC_PREREQ(2.60)
AC_INIT([videoHALCON],[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([videoHALCON.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_HALCON
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,77 @@
#g++ -O6 -march=pentium -mtune=pentiumpro -I/home/zmoelnig/halcon//include -I/home/zmoelnig/halcon//include/cpp ./ean13.cpp -I/home/zmoelnig/halcon//include -I/home/zmoelnig/halcon//include/cpp \
# -L/usr/X11R6/lib -lXext -lX11 -lpthread -lm -ldl -L/home/zmoelnig/halcon//lib/x86-linux2.4-gcc40/ -lhalconcpp -lhalcon -o ../bin/x86-linux2.4-gcc40/ean13
## CFLAGS: -I${HALCONROOT}/include -I${HALCONROOT}/include/cpp
## LDFLAGS: -L${HALCONROOT}/lib/${HALCONARCH} -lhalconcpp -lhalcon
AC_DEFUN([GEM_CHECK_HALCON],
[
AC_ARG_VAR([HALCONROOT], [root-directory where you installed HALCON (override this with '--with-halcon=${HALCONROOT}'])dnl
AC_ARG_VAR([HALCONARCH], [architecture for you HALCON-installation (e.g. 'x86-linux2.4-gcc40'])dnl
AC_ARG_WITH([halcon],
AC_HELP_STRING([--with-halcon], [enable HALCON video capturing (overrides $HALCONROOT)]))
AC_ARG_WITH([halconarch],
AC_HELP_STRING([--with-halconarch], [set halcon-arch (overrides $HALCONARCH]))
have_halcon="no"
if test "x$with_halcon" != "xno"; then
if test -d "${with_halcon}" ; then
HALCONROOT=${with_halcon}
fi
if test "x$with_halconarch" != "x"; then
HALCONARCH=${with_halconarch}
fi
tmp_halcon_includes=""
if test -d "${HALCONROOT}/include" ; then
AC_LIB_APPENDTOVAR([tmp_halcon_includes], "-I${HALCONROOT}/include")
fi
if test -d "${HALCONROOT}/include/cpp" ; then
AC_LIB_APPENDTOVAR([tmp_halcon_includes], "-I${HALCONROOT}/include/cpp")
fi
if test -d "${HALCONROOT}/lib/${HALCONARCH}" ; then
tmp_halcon_ldflags="-L${HALCONROOT}/lib/${HALCONARCH}"
fi
tmp_halcon_ldflags="-lhalcon ${tmp_halcon_ldflags}"
tmp_halcon_cppflags_org="$CPPFLAGS"
tmp_halcon_libs_org="$LIBS"
CPPFLAGS="$CPPFLAGS $tmp_halcon_includes"
LIBS="-lm"
AC_CHECK_HEADER(HalconCpp.h,
[
have_halcon="yes"
],[
have_halcon="no"
])
if test "x$have_halcon" = "xyes"; then
AC_CHECK_LIB(halconcpp, main, , [have_halcon="no"], ["${tmp_halcon_ldflags}"])
fi
CPPFLAGS="$tmp_halcon_cppflags_org"
LIBS="$tmp_halcon_libs_org"
if test "x$have_halcon" = "xyes"; then
AC_DEFINE([HAVE_HALCON], [1], [video capturing using MVtec's HALCON])
GEM_HALCON_CXXFLAGS="${tmp_halcon_includes}"
GEM_HALCON_LIBS="-lhalconcpp ${tmp_halcon_ldflags}"
fi
AC_MSG_CHECKING([for HALCON])
AC_MSG_RESULT([$have_halcon])
fi
AM_CONDITIONAL(HAVE_HALCON, test x$have_halcon = xyes)
AC_SUBST(GEM_HALCON_CXXFLAGS)
AC_SUBST(GEM_HALCON_LIBS)
])

View file

@ -0,0 +1,693 @@
////////////////////////////////////////////////////////
//
// 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
#include "videoHALCON.h"
#include "plugins/PluginFactory.h"
#include <sstream>
using namespace gem::plugins;
#include "Gem/RTE.h"
#include "Gem/Files.h"
#include "Gem/Dylib.h"
#if 0
# define debug ::post
#else
# define debug
#endif
/////////////////////////////////////////////////////////
//
// videoHALCON
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
#ifdef HAVE_HALCON
REGISTER_VIDEOFACTORY("halcon", videoHALCON);
static std::vector<std::string>s_backends;
static std::vector<std::string>getBackends(void) {
if(s_backends.size()>0)return s_backends;
#ifdef _WIN32
std::string path = gem::files::expandEnv("%HALCONROOT%/bin/%HALCONARCH%/hAcq", true);
#else
std::string path = gem::files::expandEnv("$HALCONROOT/lib/$HALCONARCH/hAcq", true);
#endif
std::string pattern = path+std::string("*") +GemDylib::getDefaultExtension();
std::vector<std::string>listing=gem::files::getFilenameListing(pattern);
//std::cerr << "pattern: '"<<pattern<<"' got "<<listing.size()<<" results " << std::endl;
int i=0;
for(i=0; i<listing.size(); i++) {
std::string needle="hAcq";
const size_t found = listing[i].rfind(needle);
//std::cerr << "checking: '"<<listing[i]<<"' found " << found << std::endl;
if(std::string::npos != found) {
const size_t start=found+needle.length();
const size_t stop =listing[i].rfind(GemDylib::getDefaultExtension()) - start;
std::string backend=listing[i].substr(start, stop);
//std::cerr << "checking: '"<<listing[i]<<"' -> " << backend << std::endl;
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
if(H_MSG_TRUE==info_framegrabber(backend.c_str(),
"revision",
&Information,
&ValueList)) {
s_backends.push_back(backend);
}
} catch (Halcon::HException &except) {
//error("%s", except.message);
}
}
}
return s_backends;
}
// exception handler
static void MyHalconExceptionHandler(const Halcon::HException& except)
{
// the exception handler is needed in order to prevent halcon from crashing
// we just pass on the exception to upstream...
throw except;
}
videoHALCON :: videoHALCON() : videoBase("halcon"),
m_grabber(NULL)
{
m_width=0;
m_height=0;
Halcon::HException::InstallHHandler(&MyHalconExceptionHandler);
m_backends=getBackends();
if(m_backends.size()>0) {
int i=0;
for(i=0; i<m_backends.size(); i++) {
provide(m_backends[i]);
}
}
}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
videoHALCON :: ~videoHALCON()
{
close();
}
////////////////////////////////////////////////////////
// frame grabber
//
/////////////////////////////////////////////////////////
bool videoHALCON :: grabFrame() {
Halcon::HImage img;
if(NULL==m_grabber)
return false;
try {
img=m_grabber->GrabImageAsync(-1);
} catch (Halcon::HException& except) {
error("Halcon::GrabImage exception: '%s'", except.message);
return false;
}
Halcon::HTuple typ, W, H, pR, pG, pB;
long r, g, b, h, w;
try {
r = img.GetImagePointer3(&pG, &pB, &typ, &W, &H);
} catch (Halcon::HException& except) {
error("Halcon::GetImagePointer exception: '%s'", except.message);
return false;
}
try {
#if 0
#define GETTUPLE(x, y) { try {x=y[0]; } catch (Halcon::HException& except) { error("HTuple exception @ %d: '%s'", __LINE__, except.message); } } while(0)
GETTUPLE(g, pG);
GETTUPLE(b, pB);
GETTUPLE(w, W);
GETTUPLE(h, H);
#else
g=pG[0];
b=pB[0];
w=W[0];
h=H[0];
#endif
const unsigned char* ptrR=(const unsigned char*)r;
const unsigned char* ptrG=(const unsigned char*)g;
const unsigned char* ptrB=(const unsigned char*)b;
//post("image[%dx%d]: %x %x %x --> %x %x %x", w, h, r, g, b, ptrR, ptrG, ptrB);
lock();
m_image.image.xsize=w;
m_image.image.ysize=h;
m_image.image.setCsizeByFormat(GL_RGBA);
m_image.image.reallocate();
long row, col;
unsigned char*data=m_image.image.data;
for(row=0; row<h; row++) {
for(col=0; col<w; col++) {
// post("[%d,%d]", row, col);
data[chRed ]=*ptrR++;
data[chGreen]=*ptrG++;
data[chBlue ]=*ptrB++;
data[chAlpha]=255;
data+=4;
}
}
m_image.newimage=true;
m_image.image.upsidedown=true;
unlock();
} catch (Halcon::HException& except) {
verbose(1, "Halcon::HTuple exception: '%s'", except.message);
}
return true;
}
/**
* device name parser
*/
static std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while(std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}
static std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
return split(s, delim, elems);
}
static std::string parsedevicename(std::string devicename, std::string&cameratype, std::string&device) {
std::string name;
if(devicename.empty())return name;
std::vector<std::string> parsed = split(devicename, ':');
switch(parsed.size()) {
default:
verbose(1, "could not parse '%s'", devicename.c_str());
return name;
case 3:
if(parsed[2].size()>0)
device=parsed[2];
case 2:
if(parsed[1].size()>0)
cameratype=parsed[1];
case 1:
name=parsed[0];
}
verbose(1, "HALCON: name ='%s'", name.c_str());
verbose(1, "HALCON: camera='%s'", cameratype.c_str());
verbose(1, "HALCON: device='%s'", device.c_str());
return name;
}
/////////////////////////////////////////////////////////
// openDevice
//
/////////////////////////////////////////////////////////
static void printtuple(Halcon::HTuple t) {
int i=0;
for(i=0; i< t.Num(); i++) {
Halcon::HCtrlVal v=t[i];
std::cerr<<"["<<i<<"]: ";
switch(v.ValType()) {
case Halcon::LongVal:
std::cerr << v.L();
break;
case Halcon::DoubleVal:
std::cerr << v.D();
break;
case Halcon::StringVal:
std::cerr << v.S();
break;
case Halcon::UndefVal:
std::cerr << "<undef>";
}
std::cerr << std::endl;
}
}
static void printinfo(std::string name, std::string value) {
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
std::cerr << "getting info for "<<name<<"."<<value<<std::endl;
Herror err=info_framegrabber(name.c_str(),
value.c_str(),
&Information,
&ValueList);
std::cerr << "got info for "<<name<<"."<<value<<":"<<std::endl;
printtuple(Information);
std::cerr << "got values: " << std::endl;
printtuple(ValueList);
std::cerr << std::endl;
} catch (Halcon::HException &except) {
error("%s", except.message);
}
}
static void getparam(Halcon::HFramegrabber*grabber, std::string name) {
try {
Halcon::HTuple result=grabber->GetFramegrabberParam(name.c_str());
std::cerr << "got parm for "<<name<<std::endl;
printtuple(result);
} catch (Halcon::HException &except) {
error("%s", except.message);
}
}
bool videoHALCON :: openDevice(gem::Properties&props)
{
m_backendname.clear();
if(m_grabber)closeDevice();
double d=0;
int w=0, h=0, p=0;
if(props.get("width", d))
w=d;
if(props.get("height", d))
h=d;
if(props.get("channel", d))
p=d;
const int width=(w>0) ?w:0;
const int height=(h>0)?h:0;
const int port=(p>0)?p:-1;
m_width=width;
m_height=height;
/* m_devicename has to provide:
* backendid
* cameratype
* device
*
* originally i though about using ":" as s delimiter,
* e.g. "GigEVision::001234567890" would use the GigE-device @ "00:12:34:56:78:90" with "default" cameratype
* however, ":" is already internally used by e.g. the "1394IIDC" backend, that uses "format:mode:fps" as cameratype
*
* either use another delimiter, or find some escaping mechanism (e.g. '1394IIDC:"0:4:5":0x0814436102632378'
*
* another idea would be to get an idea about which <driver> was selected in [pix_video] and use that as the <backendid>
* for this to work, we would have to provide a list of valid backends (e.g. dynamically query what is installed)
* i don't think this is currently possible with halcon
*
*/
std::string cameratype="default";
std::string device="default";
std::string name;
if(m_devicename.empty()) {
if(m_device2backend.size()>0) {
std::map<std::string, std::string>::iterator it( m_device2backend.begin() );
std::advance( it, m_devicenum );
if(it != m_device2backend.end()) {
device=it->first;
name=it->second;
}
}
} else {
std::map<std::string, std::string>::iterator it = m_device2backend.find(m_devicename);
if(it != m_device2backend.end()) {
device=it->first;
name=it->second;
} else {
name=parsedevicename(m_devicename, cameratype, device);
}
}
if(name.empty()) {
return false;
}
try {
m_grabber = new Halcon::HFramegrabber(
name.c_str(), /* const HTuple &Name, */
1, 1, /* const HTuple &HorizontalResolution = 1, const HTuple &VerticalResolution = 1, */
width, height, /* const HTuple &ImageWidth = 0, const HTuple &ImageHeight = 0, */
0, 0, /* const HTuple &StartRow = 0, const HTuple &StartColumn = 0, */
"default", /* const HTuple &Field = "default", */
8, /* const HTuple &BitsPerChannel = -1, */
"rgb", /* const HTuple &ColorSpace = "default", */
-1, /* const HTuple &Gain = -1, */
"default", /* const HTuple &ExternalTrigger = "default", */
cameratype.c_str(), /* const HTuple &CameraType = "default", */
device.c_str(), /* const HTuple &Device = "default", */
port /* const HTuple &Port = -1, */
/* const HTuple &LineIn = -1 */
);
} catch (Halcon::HException &except) {
error("%s", except.message);
m_grabber=NULL;
return false;
}
#if 0
printinfo(name, "parameters");
printinfo(name, "parameters_readonly");
printinfo(name, "parameters_writeonly");
printinfo(name, "port");
getparam(m_grabber, "color_space_values");
getparam(m_grabber, "revision");
#endif
m_backendname = name;
return true;
}
/////////////////////////////////////////////////////////
// closeDevice
//
/////////////////////////////////////////////////////////
void videoHALCON :: closeDevice() {
if(m_grabber)delete m_grabber;
m_grabber=NULL;
m_backendname.clear();
}
/////////////////////////////////////////////////////////
// startTransfer
//
/////////////////////////////////////////////////////////
bool videoHALCON :: startTransfer()
{
if(NULL!=m_grabber)
m_grabber->GrabImageStart(-1);
return true;
}
/////////////////////////////////////////////////////////
// stopTransfer
//
/////////////////////////////////////////////////////////
bool videoHALCON :: stopTransfer()
{
return true;
}
std::vector<std::string> videoHALCON::enumerate() {
std::vector<std::string> result;
std::vector<std::string> backends;
m_device2backend.clear();
if(m_backendname.empty()) {
backends=m_backends;
} else {
backends.push_back(m_backendname);
}
int i=0;
for(i=0; i<backends.size(); i++) {
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
if(H_MSG_TRUE != info_framegrabber(backends[i].c_str(),
"device",
&Information,
&ValueList))
continue;
int j=0;
for(j=0; j<ValueList.Num(); j++) {
Halcon::HCtrlVal v=ValueList[j];
std::string device;
switch(v.ValType()) {
case Halcon::StringVal:
device=v.S();
// some backends seem to be a bit buggy and report instructions what you should give rather than enumerate devices
if("LPS36"==backends[i] && "<ip_address>"==device) {
// e.g. LPS-36 gives us "<ip_address>" (probably it does return a valid IP-address if we had such a device, dunno)
} else {
m_device2backend[device]=backends[i];
result.push_back(device);
}
break;
default:
break;
}
}
} catch (Halcon::HException &except) {
// ...
}
}
return result;
}
bool videoHALCON::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
int i=0;
gem::any typeval;(void*)0;
readable.clear();
m_readable.clear();
writeable.clear();
m_writeable.clear();
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
Herror err=info_framegrabber(m_backendname.c_str(),
"parameters",
&Information,
&ValueList);
if(ValueList.Num()>0) {
for(i=0; i< ValueList.Num(); i++) {
Halcon::HCtrlVal v=ValueList[i];
if(v.ValType() == Halcon::StringVal) {
readable.set(v.S(), typeval);
m_readable[v.S()]=ValueList;
writeable.set(v.S(), typeval);
m_writeable[v.S()]=ValueList;
}
}
}
} catch (Halcon::HException &except) {
error("%s", except.message);
}
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
Herror err=info_framegrabber(m_backendname.c_str(),
"parameters_readonly",
&Information,
&ValueList);
if(ValueList.Num()>0) {
for(i=0; i< ValueList.Num(); i++) {
Halcon::HCtrlVal v=ValueList[i];
if(v.ValType() == Halcon::StringVal) {
readable.set(v.S(), typeval);
m_readable[v.S()]=ValueList;
writeable.erase(v.S());
m_writeable.erase(v.S());
} else {
std::cerr << "unknown ro" <<std::endl;
}
}
}
} catch (Halcon::HException &except) {
error("%s", except.message);
}
try {
Halcon::HTuple Information;
Halcon::HTuple ValueList;
Herror err=info_framegrabber(m_backendname.c_str(),
"parameters_writeonly",
&Information,
&ValueList);
if(ValueList.Num()>0) {
for(i=0; i< ValueList.Num(); i++) {
Halcon::HCtrlVal v=ValueList[i];
if(v.ValType() == Halcon::StringVal) {
writeable.set(v.S(), typeval);
m_writeable[v.S()]=ValueList;
readable.erase(v.S());
m_readable.erase(v.S());
} else {
std::cerr << "unknown wo" <<std::endl;
}
}
}
} catch (Halcon::HException &except) {
error("%s", except.message);
}
return true;
}
void videoHALCON::setProperties(gem::Properties&props) {
if(NULL==m_grabber)return;
std::vector<std::string>keys=props.keys();
int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
std::string s;
double d;
if(m_writeable.find(key) != m_writeable.end()) {
try {
const Halcon::HTuple Param=key.c_str();
Halcon::HTuple Value;
switch(props.type(key)) {
case gem::Properties::STRING:
if(props.get(key, s)) {
try {
m_grabber->SetFramegrabberParam(Param, s.c_str());
} catch (Halcon::HException& except) {
error("Halcon::SetFramegrabberParam(%s) exception: '%s'", key.c_str(), except.message);
}
}
break;
case gem::Properties::DOUBLE:
if(props.get(key, d)) {
try {
m_grabber->SetFramegrabberParam(Param, d);
} catch (Halcon::HException& except) {
try {
long l=d;
m_grabber->SetFramegrabberParam(Param, l);
} catch (Halcon::HException& except) {
error("Halcon::SetFramegrabberParam(%s) exception: '%s'", key.c_str(), except.message);
}
}
}
break;
default:
error("Halcon::SetFramegrabberParam(%s): invalid type", key.c_str());
break;
}
} catch (Halcon::HException& except) {
error("Halcon::SetFramegrabberParam(%s) exception: '%s'", key.c_str(), except.message);
}
} else {
if("width" == key) {
double d=0;
if(props.get(key, d)) {
try {
m_grabber->SetFramegrabberParam("image_width", d);
} catch (Halcon::HException& except) {
try {
long l=d;
m_grabber->SetFramegrabberParam("image_width", l);
} catch (Halcon::HException& except) {
error("Halcon::SetFramegrabberParam(width) exception: '%s'", except.message);
}
}
m_width=d;
}
} else if ("height" == key) {
double d=0;
if(props.get(key, d)) {
try {
m_grabber->SetFramegrabberParam("image_height", d);
} catch (Halcon::HException& except) {
try {
long l=d;
m_grabber->SetFramegrabberParam("image_height", l);
} catch (Halcon::HException& except) {
error("Halcon::SetFramegrabberParam(height) exception: '%s'", except.message);
}
}
m_height=d;
}
}
}
}
}
void videoHALCON::getProperties(gem::Properties&props) {
if(NULL==m_grabber)return;
std::vector<std::string>keys=props.keys();
int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
if(m_readable.find(key) != m_readable.end()) {
try {
Halcon::HTuple hresult=m_grabber->GetFramegrabberParam(key.c_str());
gem::any nonetype;
int j=0;
for(j=0; j< hresult.Num(); j++) {
Halcon::HCtrlVal v=hresult[j];
switch(v.ValType()) {
case Halcon::LongVal:
props.set(key, static_cast<double>(v.L()));
break;
case Halcon::DoubleVal:
break;
case Halcon::StringVal:
props.set(key, std::string(v.S()));
break;
case Halcon::UndefVal:
props.set(key, nonetype);
default:
break;
}
}
} catch (Halcon::HException& except) {
error("Halcon::GetFramegrabberParam exception: '%s'", except.message);
}
}
}
}
#else
videoHALCON :: videoHALCON() : videoBase("")
{ }
videoHALCON :: ~videoHALCON()
{ }
#endif /* HAVE_HALCON */

View file

@ -0,0 +1,109 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
grab images using HALCON
HALCON is a proprietary machine vision library by MVtec, that supports a wide range
of image acquisition devices (most noteable: GigE-cameras)
see http://halcon.de/
you will need to get a license key from your vendor
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" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__VIDEOHALCON_VIDEOHALCON_H_
#define _INCLUDE_GEMPLUGIN__VIDEOHALCON_VIDEOHALCON_H_
#include "plugins/videoBase.h"
#include <map>
#if defined HAVE_LIBHALCON
# define HAVE_HALCON
#endif
#ifdef Status
/* ouch: Xlib.h defines "Status" as "int", but Halcon uses "Status" as a
* variable name
*/
# undef Status
#endif
#ifdef HAVE_HALCON
# include "HalconCpp.h"
#endif
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
pix_video
Loads in a video
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT videoHALCON : public videoBase {
public:
//////////
// Constructor
videoHALCON(void);
//////////
// Destructor
virtual ~videoHALCON(void);
#ifdef HAVE_HALCON
////////
// open the video-device
virtual bool openDevice(gem::Properties&);
virtual void closeDevice(void);
//////////
// Start up the video device
// [out] int - returns 0 if bad
bool startTransfer(void);
//////////
// Stop the video device
// [out] int - returns 0 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:
Halcon::HFramegrabber*m_grabber;
std::string m_backendname;
std::vector<std::string> m_backends;
std::map<std::string, Halcon::HTuple>m_readable, m_writeable;
/* short-cut device-name as found by "enumerate"
* this maps the devicename to the backend that provides the device
*/
std::map<std::string, std::string>m_device2backend;
#endif /* HAVE_HALCON */
};
};};
#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}") = "videoHALCON", "videoHALCON.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="videoHALCON"
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;$(HALCONROOT)\include&quot;;&quot;$(HALCONROOT)\include\cpp&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_HALCON"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib halcon.lib halconcpp.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;$(HALCONROOT)\lib\$(HALCONARCH)&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="..\videoHALCON.cpp">
</File>
<File
RelativePath="..\videoHALCON.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="HALCON"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(HALCONROOT)\include&quot;;&quot;$(HALCONROOT)\include\cpp&quot;"
PreprocessorDefinitions="HAVE_HALCON"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="halcon.lib halconcpp.lib"
AdditionalLibraryDirectories="$(HALCONROOT)\lib\$(HALCONARCH)"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "videoHALCON", "videoHALCON.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,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="videoHALCON"
ProjectGUID="{4B82D19E-ABA3-4DE8-8144-AA6087C52454}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;.\HALCON.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\videoHALCON.cpp"
>
</File>
<File
RelativePath="..\videoHALCON.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>