Compiling Basler Pylon SDK for OpenFrameworks on Ubuntu - c++

I am trying to use a Basler (https://www.baslerweb.com/) camera with some openCV stuff on openframeworks. I have previously used Point Grey cameras (with their "FlyCapture2" SDK) without too much trouble. Basler has something called Pylon SDK which works for Windows, Linux and Mac OS.
I can compile Pylon's own examples without any issue, but when I #include <pylon/PylonIncludes.h> then I immediately get compiler issues. I have modified the config.make file for my project appropriately (I think), so the compiler definitely finds the header files, but I keep getting errors relating to something much deeper in the Pylon library, specifically:
In file included from /usr/include/X11/Xlib.h:44:0,
from /usr/include/GL/glx.h:30,
from /home/stephen/of_v0.9.8_linux64_release/libs/openFrameworks/utils/ofConstants.h:184,
from /home/stephen/of_v0.9.8_linux64_release/libs/openFrameworks/ofMain.h:5,
from /home/stephen/of_v0.9.8_linux64_release/apps/myApps/canPointerOsc/src/main.cpp:1:
/opt/pylon5/include/GenApi/Types.h:130:9: error: expected identifier before numeric constant
None, //!< name resides in custom namespace
It seems that "None" is getting defined (into a numeric constant?) somewhere else. Curiously, this never happens when compiling their own samples. Is there something about the openFrameworks compiling process (options passed to G++?) that might break this part of their own code:
//! Defines from which standard namespace a node name comes from
//! \ingroup GenApi_PublicUtilities
typedef enum _EStandardNameSpace
{
None, //!< name resides in custom namespace
GEV, //!< name resides in GigE Vision namespace
IIDC, //!< name resides in 1394 IIDC namespace
CL, //!< name resides in camera link namespace
USB, //!< name resides in USB namespace
_UndefinedStandardNameSpace //!< Object is not yet initialized
} EStandardNameSpace;
Any thoughts?

Looks like there were conflicting definitions via the preprocessor, possibly buried somewhere in openFrameworks itself or one of its included dependencies. Adding the following lines before including the Pylon Header file solved the issue:
#undef None
#undef Status
Goddam you, preprocessors!

Related

CImg Compilation Error: t_normal not in global namespace

I'm currently working on a class assignment that requires the use of the CImg library. To be clear, the assignment is not linking the library into the program; The class is using it access the pixel data for later use in the heart of the assignment.
I'm working in Xcode (OS X 10.10). CImg (2.2.2) is installed from homebrew, and I've managed to navigate the weird way Xcode deals with search paths (added the header to the section), and have successfully-ish included CImg.
my full code is as below.
#include <iostream>
#define cimg_display 0 //I don't need X11 at all
#include "CImg.h"
using namespace cimg_library;
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
However, I get 17 Compile-time errors from CImg.h, which are very unusual, and all of the form:
"No member named 't_normal' in the global namespace; did you mean simply 't_normal'?"
Thinking I might have received a bad download, I have attempted to redownload CImg, with no luck. I have also gotten to this same point with non-homebrew versions of CImg.
To verify the download, I also compiled the examples from the command line and they ran perfectly.
Is there a problem with CImg that I'm not aware of, a problem with Xcode that I'm not aware of, or is there something fundamental that I'm missing (definitely an option, my C-style programming is a little rusty) ?
halp pls.
Your code runs fine if you do this:
Create a new Xcode project, with:
type = "Command Line Tool"
language = "C++"
Then go to "Build Settings" and add the path to the directory containing CImg.h to your "User Header Search Paths"

How to create a VTK project in Windows Form Project (VisualC++ 2012 )

I'm trying to embed scene created with Visualization ToolKit (VTK)library into VisualC++ 2012 created windows form so I can design my Windows native GUI interface.
I'd like to underline that, all examples with console app are configured with (Cmake), compiled with VC++2012 and works flawlessly, as instructed by the official VTK wiki page.
The issue is, if I try to call those VTK functions and class initializations inside of Win Form application I get the Error LNK1107: invalid or corrupt file: cannot read at 0x2E0 D:\.....\VTK_61_BUILD_VS2012\bin\Debug\vtkViewsCore-6.1.dll even if I add everything normally as expected, include headers and external library dependencies.
This makes me think that I'm originating from wrong Visual C++ 2012 project template or something obvious that I'm completely missing, otherwise compiler would arise many not found files or syntax error.
This is the first lines where I'm trying to invoke the VTK library, even the intellisense suggest the vtk..... named proc,functions and structures, but application fails to compile.
#pragma once
#include <vtkSmartPointer.h>
#include <vtkTriangle.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkRenderWindow.h>
namespace CLR_Project1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
...
...
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
What is the problem here ?
The following link (in particular the answer of Mr. bnsteel) helped me very much, when I had the same problem ==>
http://vtk.1045678.n5.nabble.com/VTK-and-Winforms-integration-td5721086.html
You can use Swig as it is suggested under the link. But it is not necessary. Using the similar way (passing the windows form panel handle) you can create a C++/CLI wrapper as jalal sadeghi proposed. You will pass the panel handle through the wrapper to your C++ library that does all the "VTK work". This way you don't have to create individual wrappers for all VTK classes, all the "VTK work" and dependencies on VTK stay hidden in your C++ layer.
Something like this ==>
C++ side
setImageRenderWindowParentID(void *theID){
... (init your vtk render window)
renWin->SetParentId(theID);
}
C++/CLI side
void setRenderWindowParentID(IntPtr parentID, .. also pass the panel size .. ){
void* p = parentID.ToPointer();
myCPPVTK->setRenderWindowParentID(p, .. also pass the panel size ..);
}
C# side
VTKWrapper.setRenderWindowParentID(m_panel.Handle, .. also pass the panel size ..);

Qt shared_ptr not found when including a library

I'm using Qt creator and the yaml-cpp library. I placed yaml-cpp under my source code directory and added it to the Qt project's include path like so:
INCLUDEPATH += Crypto \
Yaml
QMAKE_CXXFLAGS += -std=gnu++0x
DEFINES += __GXX_EXPERIMENTAL_CXX0X__
As you can see, I also told it to use C++ 11 because that is a requirement of this library. However, I get this error on compiling my project (this is the only error):
../ProjectName/Yaml/yaml-cpp/node/ptr.h:11:10: fatal error: 'boost/shared_ptr.hpp' file not found
#include <boost/shared_ptr.hpp>
^
I also tried, at the advice of some online resources, to replace it with #include <memory>, but this does not work. When I try this, it still cannot find shared_ptr.
I probably could compile the library and link Qt creator to it, but I would have to do this on every platform I use and on every machine that every project developer uses. It seems like a more elegant solution to put the source code inside my GitHub directory and compile it along with the project to minimize the overhead of someone compiling the project on their machine, particularly since this is an open source project.
Here is the source code of Yaml-Cpp's file in question:
#include "yaml-cpp/dll.h"
#include <boost/shared_ptr.hpp>
namespace YAML
{
namespace detail {
class node;
class node_ref;
class node_data;
class memory;
class memory_holder;
typedef boost::shared_ptr<node> shared_node;
typedef boost::shared_ptr<node_ref> shared_node_ref;
typedef boost::shared_ptr<node_data> shared_node_data;
typedef boost::shared_ptr<memory_holder> shared_memory_holder;
typedef boost::shared_ptr<memory> shared_memory;
}
}
It seems that you do not have boost installed. You would need to amend that first.
However, you could urge the yaml-cop developers to use the recent C++ standard more and more when their software is built using C++11 or later. C++11 is not a new thing anymore. It should be utilized as much as possible.

Stroupstrup Graphics Library Errors

I'm new to C++ and in my Intro to programming design and concepts class we're now on graphics. I've been able to make programs with just FLTK's library but we have to use Bjarne's library such as GUI.h, Graph.h, Simple_window.h, Point.h. A simple program like a simple window program won't compile and gives a usual response of:
Simple_window.h:17: error: reference to ‘Window’ is ambiguous
I have also tried compiling using:
fltk-config --compile main.cpp
This yields the same results.
I have tried running the make file that Bjarne has provided with in the folder but that always comes up with errors and makes no .o files.
Note: I have also tried compiling on mac OSX and Ubuntu.
I never used either of those libraries, but I saw that tutorials for FLTK always begin with using namespace fltk; statement, which imports all FLTK classes, including fltk::Window to the root namespace.
The library by B. Stroustrup is contained in namespace called Graph_lib and it also has a class called Window.
Now, the file Simple_window.h has using namespace Graph_lib; statement at the beginning, which imports Graph_lib::Window to the root namespace. And this is where the ambiguity is coming from.
So I would suggest to omit the using statement (at least from using namespace fltk) and to use FLTK classes with full specification (e.g. fltk::Window instead of just Window). This should solve the ambiguity.
As a side note, this is nice example, why having using namespace at file level in a header file is a bad idea.
References:
http://www.fltk.org/doc-2.0/html/index.html
http://www.stroustrup.com/Programming/Graphics/Simple_window.h
EDIT: I tried to compile the library containing Simple_window myself and, at least under linux, it the ambiguity seems to be between class Graph_lib::Window from the library and typedef Window from xlib as well. xlib is C library and you can't really do anything about it, so you will have to get rid of using namespace Graph_lib in Stroustup's library.
In the file Simple_window.h:
delete using namespace Graph_lib;
change Window to Graph_lib::Window
Button to Graph_lib::Button
and Address to Graph_lib::Address
Then in the file Simple_window.cpp:
change Address to Graph_lib::Address again
and reference_to<Simple_window> to Graph_lib::reference_to<Simple_window>
Then it should compile. If you have different version than the one that's on stroustrup.com, you may need to fully qualify (add Graph_lib::) more classes.
I just had the same kind of problems (unresolved external symbols) using Simple_window.h and trying to compile a the following peace of code:
int main(){
// create a reference point for the window
Point topLeft(50,50);
// initialize a Simple_window object to size: 600x400 pixels, labeled: My window
Simple_window myWindow(topLeft, 600, 400, "My window");
// pass control to GUI
myWindow.wait_for_button();
return 0;
}
The solution was to add to the project (along with the main.cpp) all the respective .cpp files of the included .h files:("Graph.h", "Window.h", "Simple_window.h", "GUI.h")

Windows/opengl glext.h build issue

So I'm trying to bring a c++ project using Qt and OpenGL written and compiled on a Linux machine over to my Windows 7 machine at home, but I'm running into some difficulty. First I learned that some gl things (like GL_TEXTURE0) were no longer defined because gl.h doesn't define them for windows. Also, the glext.h that I have does not define some functions like glActiveTexture. Both of these issues I found could be solved by bringing in a newer glext.h.
My most immediate issue seems to be that I'm not bringing it in correctly. If I do:
#define GL_GLEXT_LEGACY //should prevent old glext.h from being included
#define GL_GLEXT_PROTOTYPES //should make glActiveTexture be defined
#include <qgl.h>
#include "glext.h" //local up-to-date glext.h
#include <QGLShaderProgram>
then make tells me that I have undefined references to glActiveTexture. If I include QGLShaderProgram before glext.h, then I still have that problem, but make also warns me that I am redefining quite a few things that are defined in both QGLShaderProgram and glext, so I know the latter file is being included. Any help would really be appreciated.
You are on a right path, but like Nick Meyer wrote, you need to get pointers to the functions at runtime.
There is a nice and clean example already in Qt installation directory, at least since 4.6. Check "Boxes" from "demos"-directory. There is glextensions.h/cpp that takes care of those required functions in Qt-way, using Qt's QGLContext etc.
If you're lazy like me, just hop over to
http://glew.sourceforge.net
and use that, no need to fiddle around with different header files and manually retrieving function pointers. It's as simple as
/* in every source file using OpenGL */
#include <GL/glew.h>
and
/* for each OpenGL context */
if( createGLContext(...) == SUCCESSFULL )
glewInit()
If you're using Qt you should probably use qmake - and just add
QT += opengl
to your qmake project file.