GPU rendering images with Python cv2 on Raspberry Pi - python

I am using the Raspberry Pi 2 to load large resolution images using opencv. I have sketch running, but without apparent "OpenGL" support as the opencv library states that it is not supported:
OpenCV Error: no OpenGL support (Library was built without openGL support)
I attempted to install pyOpenGL, but this had no effect. I am pretty new to graphics programming, so I'd take any suggestions on how to render to the GPU of the Raspberry Pi.

Ive stumbled across a Python friendly module that contains a GLSL API with quite a bit of examples :
http://pi3d.github.io/html/

You shouldn't need to deal with the gpu. Try following this blog, as it seems to have OpenCV install instructions. You might want to set INSTALL_PYTHON_EXAMPLES ON, but that is the only difference I could see.
Then you should be able to use it with python. If not, you may need to add it to your PATH.

Related

sdl2 (pysdl2) without x11 using directFB or OpenGL ES

I am working on Debian based embedded systems that avoids the overhead of windowing systems by running graphics directly to the screen using FBCON (similar to DirectFB). This is common with Raspberry Pi screens and there are plenty of resources to do this with pygame 1.9.1 (SDL1.2 based) and FBCON. Python 2.7 and pygames 1.9.1 running with FBCON is my currently working arrangement.
I want to move to Python 3 and the improved SDL2 library (pygames updates are very slow), but I need to retain the lower level graphics capability. I see little documentation of the level of support besides a couple mentions of DirectFB capability.
I am not using Raspberry Pi, so specific solutions to the Pi will be less helpful for me.
Before going to deep, I wanted to see if anybody else has experience with this.
Has anybody successfully run pysdl2 or just sdl2 without x11?
Was there any issues or changes besides the flag for the DirectFB driver?
Has anybody tried this with the alpha pygames 1.9.2?
Besides being helpful for myself I think this would be great for the community. I see other asking similar questions but with minimal or no useful answers.
Thanks for the time
References:
pysdl2
libsdl

PyGObject or PyGtk

I need to write a program on my Raspberry Pi to get a video and audio stream with Gstreamer from network and play them.(I have two stream. one for video and one for audio) and i need a custom GUI. I followed the below link :
http://www.jonobacon.org/2006/08/28/getting-started-with-gstreamer-with-python/
It used PyGtk and I want to switch to PyGObject. my question is : does PyObject support Gstreamer as well as PyGTK? or I should stuck to PyGTK? Or do you have a better solution to do that on Raspberry Pi
Considering the age of the article you linked, you might already know that there are newer versions of the libraries around. PyGtk and PyGst don't provide bindings for these.
Python GObject Introspection supports the Gkt-3.0 and Gst-1.0 versions. So you're safe using PyGObject for your program.
There's a quite good documentation on lazka.github.io/pgi-docs/ covering a lot more bindings as well.
Besides if you're going to build an audio/video player have a look at the playbin element. It's a complete pipeline supporting an audio-, a video- and a text-sink at once.

Accessing a webcam with Python 3.X

For a school project I am using a Raspberry Pi to detect certain colours in a webcam image. However, I can't seem to find any way to access the webcam using Python 3.X. Are there any libraries out there that work with python 3.X that work for both windows and linux (I'm creating the program on windows 7 but going to be using it on the R-Pi)?
If not, I suppose I could end up settling for Python 2.7 simply because the R-Pi has both versions installed on it (Although I don't know 2.7 so it may not go too well).
There are several ways to do this:
You can use OpenCV which has support for getting data from a webcam and there are Python wrappers for it;
gstreamer has python bindings too;
Also, on GNU/Linux, you can use v4l2.

Why is OpenCV python crashing in Windows?

I am running OpenCV2.2 on Windows 7 64-bit.
I built OpenCV using cmake with MinGW 32-bit.
I have no problem with the C/C++ build. However the python bindings seem to have some problems. Most of the python samples are crashing.
The HighGui functions seem to cause trouble. Python crashes when I try to read an image (using imread, LoadImage or LoadImageM), display an image (imshow or ShowImage) or even create and manipulate windows (NamedWindow, MoveWindow, etc).\
WaitKey doesn't crash python but it always returns a -1 immediately, no matter how long the delay I provide. Similarly imgproc functionality listed under "Image Filtering" in the reference seem to crash python. I haven't been able to test it with too many other functions, mainly because I can't load in images and I am forced to test it with matrices i have built myself.
I am currently using python 2.6.6 (32-bit) , but I got the same problem with python 2.7 (32-bit). I also tried building the python wrappers for OpenCV2.1, and I got the same problem. It's very likely a problem specific to my setup. I've been cracking my head against this problem for quite some time now, I would appreciate any help.
Thanking you in advance.
Regards,
Anush.

OpenGL in Python with Snow Leopard?

I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of extra 32-bit libraries.
I've already tried a PyOpenGL/wxPython tutorial. When I ran the code, it crashed with this message:
ImportError: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core_.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)
It looks like there's a bug in wxPython that prevents it from working on a 64-bit system.
I also looked at Pyglet, but they have a similar issue. They provide a work-around (setting Python to 32-bit mode), but it doesn't look like they're going to fix it.
Finally, I looked at PyGLUT, but I think it's only for Windows.
Are there any other libraries that would let me access OpenGL and draw on the screen? Again, I'd prefer to stay in 64-bit mode, but if nothing works, I'll switch to 32-bit and try wxPython or Pyglet again.
Edit: I've also tried PyGame. It depends on SDL which is broken in SL. I thought about trying to use Cocoa through PyObjc, but the Xcode Python application templates have been removed.
I've used PyOpenGL 3.0.0 quite successfully on Snow Leopard. It uses ctypes, so it should be making 64-bit calls if those libraries are available (and Snow Leopard's Python includes a 64-bit version). I haven't used the wxPython stuff with PyOpenGL so that's where you might be running into problems, but PyOpenGL also includes GLUT, which both run fine.
There's probably no good reason to avoid 32-bit mode. Unless your Python programs need to larger address space, of course.
You could try pygame. Pygame is a python wrapper around SDL. According to their website they have Max OS X binaries. Here is a simple example of using pygame with OpenGL. Once you are able to create the window and handle events most OpenGL programming is just like it would be in C or C++, but with some added python goodness. For OpenGL a great tutorial is NeHe.
Also when programing with OpenGL in python remember that Python datastructures can be rather slow when it comes to requirements for 3D graphics. PyGL developers for example recommend using ctypes for operations that concern graphics, since that way you can get enough performance for some complicated geometry with bareable FPS.

Categories