OpenGL ES 1.1 on the raspberry pi - c

I'm trying to get started with OpenGL ES 1.1 on the raspberry.
As X is not accelerated on the raspberry I thought this could be a good (and fast) alternative.
Now what I'm trying to do is mostly UI stuff like menus and so on, nothing like crazy 3D gaming with extra terrestrial effects and shaders! That's why I've chosen OpenGL ES 1.1 instead of the 2.0.
Now I have taken a look at the hello_triangle.c code on the raspberry and have understood a little how it works and how you draw and move/rotate stuff.
Now the problem is that when rotating and moving stuff, the whole model is affected!
What I want to do is have multiple independent objects (like rectangles representing menu items for example) and move them independently, so I could for example rotate the current selected menu entry rectangle.
Thank you!
PS.: Here's a link to the hello_triangle code I've been studying

Related

Understanding the fisheye camera model proposed by Scaramuzza to undistort a fisheye image

I want to apologize for the broken english in this post. English is not my native language.
For a school project we are using a fisheye camera which needs to be undistorted.
The catch is however that we have to write all of our vision algorithms ourselves including the undistortion algorithm in C code.
I have been using the matlab camera toolbox to calculate the intrinsic parameters, but i find it difficult to understand how to apply these parameters with the given model that looks like this(if i even have to use it in the same way at all).
The matlab page and the paper also talks about stretching and shifting to go from the sensor plane to the image plane. Does this have to be incorporated into the algorithm?
Could someone explain how to undistort a distorted fisheye image to an undistorted image with this model?

Can I combine GameplayKit's pathfinding features with SceneKit?

The documentation states
GameplayKit also works well for 3D games built with the SceneKit framework
However, there seems to be no mention of using SceneKit's pathfinding features such as GKGraph with SCNNodes that exist in 3d space.
Are GameplayKit's pathfinding feature unsuitable for SceneKit games, or is there extra documentation somewhere to illustrate how to combine the two?
Depends on the scenario really. My current side project is a SceneKit based boat game; boats move on a 2D plane which means GameplayKit's 2D pathfinding works well.
It's not without complications though... SpriteKit gives you some useful functions such as obstaclesFromSpriteTextures:accuracy:, to help with the generation of your pathfinding graph. There is no corresponding function in SceneKit. I've adopted the approach of rendering my scene 'top down' to an offscreen buffer, and using edge detection to trace around the 2D projection of my islands.
For full 3D pathfinding I can't see GameplayKit being much help, well not without some hacks (eg; break 3D pathfinding down into several 2D planes).

Detect shapes using Open CV

I have been trying to detect shapes in an image and also arrive at a count as to how many such shapes are present in an image, for example a plus sign. Are there any built in functions to detect such shapes ? IF any please let me know.
Thank you.
You need to find all contours in an image and then filter them.
We know that the plus sign has 12 corners. So you need to filter all contours that have 12 corners. Of course, sometimes this can give you some unwanted objects. So you can filter again those contours that have angles between 2 lines(3 corners) max 0.3 cos for example.
Take a look at squares.cpp in samples directory of OpenCV. It finds all contours with 4 corners and angles max. 0.3 cos. So pretty much all squares.
You can also take a look at the Hough transform.
One way to detect shapes is to make use of cvBlobsLib.
A library to perform binary images connected component labelling
(similar to regionprops Matlab function). It also provides functions
to manipulate, filter and extract results from the extracted blobs,
see features section for more information.
For an example, see:
https://www.youtube.com/watch?v=Y8Azb_upcIQ
An alternative is to make use of EmguCV
Emgu CV is a cross platform .Net wrapper to the OpenCV image
processing library. Allowing OpenCV functions to be called from .NET
compatible languages such as C#, VB, VC++, IronPython etc. The wrapper
can be compiled in Mono and run on Windows, Linux, Mac OS X, iPhone,
iPad and Android devices.

How to do simple shape drawing in GTK?

I am new to Gtk and want to do simple drawing of shapes like circles and rectangles. I was looking at the gnome tutorial and the hello word example. However the curves section is undocumented. I was wondering if someone could point me in the right direction as to what should I look at, and maybe if I need to include some other supplementary library to draw?
The preferred drawing API in GTK 2 and 3 is Cairo. But if you need to develop a diagram program, with nodes that can react to events, you will need also to use a canvas, like GooCanvas.
Check out http://developer.gnome.org/gtk3/3.2/GtkDrawingArea.html about the GtkDrawingArea, plus http://developer.gnome.org/gdk/stable/gdk-Drawing-Primitives.html about Gdk-Drawing-Primitives and you are on the go.
You might also go a bit further by using this link and check out Cairo directly http://www.cairographics.org

Recreating <BevelBitmapEffect> in a Pixel Shader/Other Method in WPF

Now that <BevelBitmapEffect> (amongst other effects) has been depreciated, I'm looking to see how I could re-create the exact same thing in a Shader Effect (including it's properties of BevelWidth, EdgeProfile, LightAngle, Relief and Smoothness).
I'm somewhat familar with pixel shading, mostly just colors manipulation of the whole image/element in Shazzam, but how to create a bevel elludes me. Is this a vertex shader and if so, how would I get started? I have searched high and low on this but can't seem to find an inkling of information that would allow me to get started in reproducing <BevelBitmapEffect> in a custom Effect.
Or, based on a comment below, is this 3D in WPF and if so, are there code libraries out there for recreating a <BevelBitmapEffect> that mimics the one that came with previous versions of WPF?
To create the bevel you need to know the distance from the edge for each pixel (search in all directions until alpha=0). From this you can calculate the normal then shade it (see silverlight example). As you mentioned there isn't much content about bevels but there are some good resources if you search for bump mapping/normal mapping to which the shading is similar. In particular this thread has a Silverlight example using a pre-calculated normal map.
To do everything in hardware ideally you would use a multipass shader, WPF's built-in effects are multipass but it doesn't allow you to write your own.
To workaround this limitation:
You could create multiple shaders and nest your element in multiple controls applying a different effect to each one.
Target WPF 4.0 and use Pixel Shader 3.0, for the increased instruction count. Although this may be a too high a hardware requirement and there is no software fallback for PS 3.0
Do some or all of the steps in software.
Without doing one of these you'd be lucky to do a 3 or 4 pixel bevel before you reach the instruction limit as the loops needed to find the distance increase the instruction count quickly.
New Sample
Download. Here is an example that uses PixelShader 3.0. It uses one shader to find the distance (aka height) to the edge, another (based on the nvidia phong shaders) is used to shade it. Bevel profiles are created by adjusting input height either with code or a custom profile can be used by supplying a special texture. There are some other features to add but it seems easily performant enough to animate the properties. Its lacking in comments but I can explain parts if needed.
There's a great article by Rod Stephens on DevX that shows how to use System.Drawing to create the WPF effects (the ones that used to exist, such as Bevel) and more. You've gotta register to view the article though, it's at http://www.devx.com/DevXNet/Article/45039. Downloadable source code too.

Resources