OpenFrameworks + Python - c++

Is there any bindings to execute functions in OpenFrameworks (C++ toolkit) using Python 2.7? Or any alternative for this available?

Experiments on python 2.6 has been made, see #Babu answer. But not updates..
I don't know a lot about it but you can try to have a look at SIP (even i think it is an hard task to let it work completely):
SIP is a tool for quickly writing Python modules that interface with
C++ and C libraries. Its home page is at
http://riverbankcomputing.co.uk/software/sip/intro. It was written by
Phil Thompson who is still actively maintaining it.

I don't think there is a binding available for Python 2.7. For 2.6, it's available here,
For Windows: http://forum.openframeworks.cc/index.php/topic,3031.0.html
For OSX: http://forum.openframeworks.cc/index.php/topic,2763.0.html

I am also very interested by Python bindings, but it seems quite hard to implement...
That's why things like cppyy could be really handy! I didn't have a close look yet, but it's definitely on my todo list.

Interesting thing to checkout when working with OpenFrameWorks + Python is using BeautifulSoup to parse HTML and use that in OPenFrameworks to visualize the informations.

Related

How do I integrate C++ library with Python?

I want to integrate Berkelium (www.berkelium.org) with Blender to render browser in Blender scenes. Blender allows you to write python add-ons (http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions). I know only a little bit python what would be a good starting point for me? How do I call Berkelium methods in my python add-ons? Here is the link for Berkelium builds: https://github.com/sirikata/berkelium/downloads
It seems this is covered by the python docs. Perhaps this will be of interest.

How to use the C++ functions of OpenCV from Python?

I'm using the Python bindings of OpenCV and it's really great. However, there are functions in the C++ version that are missing from the Python bindings, BackgroundSubstractorMOG2, and a lots of feature detection algorithms for example. What would be the easiest way to call them from Python?
I hope this helps people looking for a fast and easy way.
Here is the github repo with the open C++ code I wrote for exposing code using OpenCV's Mat class with as little pain as possible. It was originally inspired by Yati Sagade's example.
[Update] This code now works for OpenCV 2.X and OpenCV 3.X. CMake and experimental support for Python 3.X are now also available.
I also found that a few months after my original utility was written, Sudeep Pillai also wrote a similar thing for C++/CMake. There seems to be OpenCV 2 and OpenCV 3 support as well. May be worth a try.
Have a look to SimpleCV. It Python base and it a warping OpenCV. Maybe you can found something there.

Rendering using OpenSG python bindings

Hey!! I'm looking for python bindings for opensg 1.8.. I haven't been able to find it. I have read somethin about pyopengs. Is it still available? I am working on linux platform (ubuntu). If anyone could direct me to it I would be grateful.
The homepage and source code is on google code: pyOpenSG Project
As one of the creators of pyOpenSG, I can tell you that it is definitely still alive and kicking. We use it in production software all the time. It has become so stable for us though that we don't often update the code base. The python binding generator that we use (py++) just keeps everything working between revisions.

Prototyping Qt/C++ in Python

I want to write a C++ application with Qt, but build a prototype first using Python and then gradually replace the Python code with C++.
Is this the right approach, and what tools (bindings, binding generators, IDE) should I use?
Ideally, everything should be available in the Ubuntu repositories so I wouldn't have to worry about incompatible or old versions and have everything set up with a simple aptitude install.
Is there any comprehensive documentation about this process or do I have to learn every single component, and if yes, which ones?
Right now I have multiple choices to make:
Qt Creator, because of the nice auto completion and Qt integration.
Eclipse, as it offers support for both C++ and Python.
Eric (haven't used it yet)
Vim
PySide as it's working with CMake and Boost.Python, so theoretically it will make replacing python code easier.
PyQt as it's more widely used (more support) and is available as a Debian package.
Edit: As I will have to deploy the program to various computers, the C++-solution would require 1-5 files (the program and some library files if I'm linking it statically), using Python I'd have to build PyQt/PySide/SIP/whatever on every platform and explain how to install Python and everything else.
I want to write a C++ application with Qt, but build a prototype first using Python and then gradually replace the Python code with C++. Is this the right approach?
That depends on your goals. Having done both, I'd recommend you stay with Python wherever possible and reasonable. Although it takes a bit of discipline, it's very possible to write extremely large applications in Python. But, as you find hotspots and things that can be better handled in C++, you can certainly port relevant parts to C++.
Is there any comprehensive documentation about this process or do I have to learn every single component, and if yes, which ones?
Here's what I'd recommend for the various pieces:
EDITOR/IDE: Use any editor/IDE you're comfortable with, but I'd highly recommend one that supports refactoring. If you're comfortable with Eclipse, use it. If you want to mainly go the C++ route and you're not too familiar with any editors, you might be better off with QtCreator. Eric is an extremely good Python IDE with support for refactoring, unless you're going to be doing lots of C++, take a look at it. Even better, its source code is an example of good PyQt usage and practices.
PROCESS:
The quick summary:
Write your application in Python using PyQt
When identified as hotspots, convert decoupled Python classes to C++
Create bindings for those classes using SIP
Import the newly defined libraries in Python in place of their Python counterparts
Enjoy the speed boost
General details:
Write the application in Python using PyQt. Be careful to keep a good separation of concerns so that when you need to port pieces to C++ they will be separate from their dependencies. When you finally need to port something to C++, write it in C++/Qt and then create bindings for it using SIP. SIP has a good reference manual on the process, and you have all of PyQt as an example.
DEPLOYMENT:
C++ - For many applications the dependencies are sufficiently simple that it's not too difficult to create an installer using a tool like NullSoft's Installer or InnoSetup.
Python/PyQt - PyQt applications are a bit more difficult to install because of the dependency on Python and its dependence on the presence of the Qt libraries. One person documented his efforts on this post at ARSTechnica. py2exe works pretty well on Windows and should work fine. IME, freeze.py, which comes with the Python source, sometimes has problems determining which shared libraries are truly necessary and will sometimes end up creating a binary whose dependencies aren't present. Py2app can be made to work on Mac OS X.
But worse, however, is the PyQt/Qt licensing. If you are developing a commercial application, you need to have a commercial PyQt (and Qt) license and make sure to prevent the users from easily modifying the source or otherwise writing code against the PyQt/Qt API because of licensing restrictions. Because of that, the PyQt author created a tool called VendorId (although it has a Python license). Within VendorId is a tool called SIB that can be used to create an executable which depends only on the Python interpreter. But, if you're going to go this far, you might want to install a custom Python along with your application.
DISCLAIMER: I haven't used PySide at all, so I'm not sure how it compares to PyQt. Also, note the following warning on their website:
PySide is a work in progress and is not yet suited for application development requiring production-level stability.
But, on a good note, they intend, at least for the initial release to "maintain API compatibility with PyQt." So, aside from the C++ bindings, you could easily switch between the two later.
If you are just learning Qt and want to leverage the speed of prototyping that Python gives you, then I would recommend you make a sample project using PyQt. As you said, there is a debian package, so you are just a simple apt-get away from making your first application.
I personally use gVim as my Python/Qt editor, but you can really use any Python-friendly editor without much trouble. I liked WingIDE and they have auto-complete for Qt but once you sip from the vim kool-aid it's hard to switch.
I would say that PySide is 95%+ compatible with PyQt and the LPGL license is nice, but if you are just trying to prototype your first Qt app, then I don't think there is a real reason to use PySide. Although, I do like the PySide docs better, you can also just use them and replace all the library references with PyQt.
Depending on the complexity of the application you are building, it might be better off to just start from scratch with a C++ version than to try to do a bunch SIP refactoring black magic. Once you have a solid grasp of the Qt framework, you should be able to switch between the C++ and Python bindings pretty effortlessly.
I would draw UI mockups before starting to code prototypes. Here are some benefits:
Quicker than coding prototypes as there is no programming involved
Quickly fill widgets, such as tables and trees, with data
Add descriptions and notes to your screens
Easily integrate mockups into specification documents without having to capture screens
Validate UI design concepts before implementing
There are a lot of tools that can help you do that, but if you are going to use Qt, MockupUI may be a good choice as it renders Qt widgets with native styles for Windows 7,8 or 10 which makes your mockup look more realistic.

Please help my learning in Django

Hi All I am new on Django and python.I want to wirte program with Django .So please share me useful ideas and concept.How can I set up djanog in my window OS.
I little confuse and occur some errors while I read ebooks.
Share me with all experiences please in step by step.
Thank for all
http://www.djangobook.com is your friend. Free, well written and generally ace.
First, if you're new in python read dive into python, you must use python 2.5 or 2.6 not 3 (for django at least)
For windows here's a good tutorial. Then read the djangobook
For further information you can read Pro Django
And remember the oficial docs is very well written.
This may help you to start
This is great resource for you Getting Started with Django
Enjoy.
The first thing you should do is get yourself a project, it can be anything. The classic django-learning project is a blog.
Python is fairly easy to learn once you have some programming experience. I recommend that you go through the official tutorial. This google class also looks pretty good. You don't need to know the standard library all that much -- just enough python to find your way around whenever you need something. I'd say you can pick up python in a few afternoons of work.
After that, go through the django tutotial to get an idea of how to get started. Then start with your project using the docs which are quite good. They also contain an overview and installation section which may be handy. After you've gotten your feet wet, read the django book and then go fix all the things that could be better about your project.
Just like with any kind of programming, the key is to be constantly practicing and improving your code.