Graphic programming over video playback [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to make some GUI mockup program for video player, so my idea is just to show some menu pictures over real video being playback. I have working program made with C and SDL just to load pictures and make a slideshow, but i don´t know how to put this over video with transparencies.
Do you have a hint?
ps. i usually program with python and C, so if there is any solution with this two i highly appreciate.
Thanks!

Suggestion: use Openframeworks
http://www.openframeworks.cc/documentation
It is in C++ though, and not C.
Check the documentation for class ofVideoPlayer

I think you can use this tutorial, to get a working video player in SDL: http://dranger.com/ffmpeg/tutorial01.html
The tutorial is using SDL and ffmpeg. In the "tutorial 01", the video frame is converted to 24-bit RGB, so you can just do some tricks and translate to a surface.
If you want the overlay, you can see this library: http://www.libsdl.org/projects/sdlyuvaddon/
There is a function (Get_YUV_From_Surface) to convert a surface to YUV. You will need to modify it to fit your needs, but you can see the function to get some ideas.

You could render the video with OpenGL using a textured quad, and then do all your 2D drawing on top (with an appropriate 2D projection matrix setup) using GL.
SDL OpenGL support
Python OpenGL bindings
Depending on your codec, you are quite likely to end up with YUV data (rather than RGB). Depending on the platform and your hardware, you may be able to use a native texture type, to avoid having to convert to RGB first.
By using alpha blending, you can easily come up with some very sophisticated looking UIs. You will probably want to look into something like FreeType to handle the font rendering, as this is one area of GL that is platform-specific and fiddly to get working.
There are loads of tools, scene graphs, widget libraries and so on for OpenGL you can use too.

You can use Gstreamer with both C/python.
all you have to do is to overlay a rendered video on a window.
Check out the doc of how to do it https://gstreamer.freedesktop.org/documentation/video/gstvideooverlay.html?gi-language=c#GstVideoOverlay

Related

Math Functions graph in c [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm new here, I searched for any related post like my question and I found nothing
I have a project to create a math function graph in a console like f(x)=ax^2+bx+c the user give me a b c and I draw the function.
Someone told me that there are a library called graphic.h that help me with that
so if someone can help me, I'm not finding anything about graphic.h and my project
And if there are another library or anything that could help
Thanks
Sorry for incomplete answer but you have incomplete question so it is impossible to answer ...
What environment you have to use ? You wrote console but what compiler and OS ? because graphics is very different for each
DOS
many schools still use DOS console apps which is not the same as win or linux console. In DOS there is graphics.h which switch to gfx video mode and then you can use CGA/EGA/VGA and sometimes VESA graphics. Haven't done anything in it since Turbo Pascal 7.0 few decades ago.
for DOS I am using direct VGA/VESA access instead (works on win32 too) but anyway look here and here for info about graphics.h with examples.
graphics.h stands for BGI (Borland Graphics Interface) but you need CGA/EGA/VGA or VESA for proper functionality. Most gfx cards emulate them so that should be no problem just do not expect any arbitrary pixel or color resolution. It can handle 640x480x16 or 320x200x256 and the rest depends on your HW. This lib is native only to ancient Borland/Embarcadero compilers so you will find it somewhere in include path so use < > not " " !!! (you do not need to copy it to your project).
#include <graphics.h>
Windows
You have to create graphics window by WinApi or by IDE of your programing language and then you can use GDI which is part of WinAPI and most compilers have libs for it natively.
linux or different GUI OS
I do not code for such so I do not know exactly but should be similar to Windows
OpenGL (any GUI OS and also sometimes DOS with proper drivers)
if you use OpenGL then you can find tons of examples how to create gfx window + OpenGL and also OpenGL GLUT (OpenGL utilities) have functions that take care of windows stuff. You just code code for events like keystroke, mouse move, redraw ...
google NeHe OpenGL tutorials ... not my favorite but beginners like it
Look here for some more info
Now for the function plot
clear gfx screen
create for loop from xmin to xmax
compute y value for each x
do not forget to scale and offset x,y values to fit your gfx area !!!
draw line from previous to actual point
with different color than clear ...

graphics program by OpenGL without windows programming [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to do graphics program by OpenGL. But I don't have any experienced in windows programming. Any suggestion?
See these links
lazy foo tutorial for SDL to simplify some file and inputs handling
SDL and OpenGL
Kore engine uses Opengl and SDL and is open source
Kore Engine wiki Some more info on the Kore Engine
My own project using SDL and OPENGL host on Google code
Note that you'll need to code in C++ with those links
EDIT:
I tried GLUT and SFML, and both are easier to use than SDL and OpenGL alone.
GLUT is pretty straightforward but is limited in its scope.
SFML brings the good things of SDL and OpenGL, but with a nice C++ interface instead of the old C interface of SDL and raw OpenGL calls (which are still possible to do). Big performance gain out of the box for the same project, SFML is just better optimized than my own code with SDL.
But I don't have any experienced in windows programming. Any suggestion?
Well, you need to create a window somehow, so that the user can see the beautiful pictures you'll draw using OpenGL. But you're right: Opening a window and creating a OpenGL context is tedious, no matter which OS you're doing it on (the most simple one would be probably NSOpenGLView of MacOS X).
Luckily there are some libraries that abstract away the OS dependent parts of creating a window and creating and attaching a OpenGL context to it.
GLUT is probably the oldest one of those. I discourage using the original GLUT and recommend to use FreeGLUT or OpenGLUT instead, as those are actively maintained. They are easy to use. But GLUT don't give you control over the event loop which essentially means, it's ill suited for creating games.
SDL is actually a whole bunch of sub-libraries, the main library providing creating of windows. Also provides OpenGL support, but has not been tailored for it. Personally these days I'd use SDL for everything but creation of a OpenGL window. But it's fine for audio, loading graphics and such.
GLFW is IMHO one of the nicest OpenGL frameworks out there. It has a well designed API, gives you full control over the event loop and is actively maintained. Also it focuses on exactly one task: Create a OpenGL window and provide a message pump for user input.

What simple C graphics library would you recommend? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last year.
Improve this question
I'm learning C and I would like to start graphics programming, but start it simple, without spending hours just to understand what functions will I need.
I would like something to draw pixels, squares, maybe sprites, simple stuff, like in BASIC.
I tried SDL and got overwhelmed very quickly. Same with Allegro, it's hard to get it to work on Xcode 4 and documentation is lacking.
Maybe there is some custom one? Also would be nice if it works on Mac OS.
Any book recommendations are welcome, like simple C graphics programming or game programming, whatever.
If SDL is overwhelming, perhaps graphics programming is not the place to start in C. If you want to get familiar with the concepts involved in coding up graphics, try it in a higher level language like Python (with pygame or pyglet.) Most high-level languages have good bindings to graphics libraries. If you really want to learn C by writing games, maybe something more text-oriented (ncurses-based?) is appropriate.
Once you understand the fundamental idioms of graphics programming, applying them to different languages becomes much easier. You'll be able to go from pygame to SDL in C without too much extra pain beyond that inherent in going from Python to C.
I'd go for QuickCG. Here you can find sources and some tuts.
The best you can use at least which is both portable and now almost an industry standard, simple graphics can be done using OpenCV. This is not limited to just drawing lines or primitives, or should I say simple graphics, I have used it for industry standard image processing products and computer vision problem solving. This will be fun if you start learning it. OpenGL is also another place to start. It might well suit what you want. Mostly related to graphics, rather than computer vision or image processing
Another option would be to investigate the Postscript language to get a feel for the stencil/paint image model. And then you could more easily get started with Cairo which implements the same model. A big advantage to the stencil/paint model is device independence. With Cairo you can perform the same drawing commands to output to a window, an in-memory pixmap, or a pdf file writer.
"g2 graphics library" is the most simple. The programming language is C. But does not support "only" 64 bit systems (it supports 32 bit like Mac OS Mojave, and Ubuntu, have not checked up with Windows MSYS MinGw). To create User Interfaces i recommend FLTK (Fast Light Toolkit) with the UI-builder Fluid.
https://sourceforge.net/projects/g2gl/
https://www.fltk.org/software.php

A Simple, 2d cross-platform graphics library for c or c++? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
As in title, i need a 2d graphics library that is cross-platform, and provides simple functions, like in Basic; essentially, i only need to paint a pixel a certain color-I do not need hardware acceleration, or any kind of 3d support. I've found a couple ones, but they're not cross-platform.
Anyone knows a solution for me?
What about SDL?
Perhaps it's a bit too complex for your needs, but it's certainly cross-platform.
Am I missing something to wonder why noone suggests OpenGL? To use it for 2d would be very simple. The OP only wants to color a pixel. It doesn't get simpler than glBegin/glColor/glVertex/glEnd.
Qt 5
GTK+
Cairo
and many many more ...
[In no particular order.] However, if you have any other requirements, let us know. BTW: I am not just posting results of a Google query here, I have used all of these (and SDL -- wrote my first few games in SDL :) and I'd say without a set of requirements, it's very difficult to choose among the ones listed.
Heavy-weight:
GTK
QT
WxWidgets
Lightweight:
FLTK
Fox
Tk
Lua IUP
Ultimate++
dlib
Drawing frameworks without GUI widgets:
SDL
Cairo
http://www.allegro.cc/
http://en.wikipedia.org/wiki/Allegro_library
One neat engine I came across is Angel-Engine. Info from the project site:
Cross-Platform functionality (Windows and Mac)
Actors (game objects with color, shape, responses, attributes,
etc.)
Texturing with Transparency
"Animations" (texture swapping at defined intervals)
Rigid-Body Physics
A clever programmer can do soft-body physics with it
Sound
Text Rendering with multiple fonts
Particle Systems
Some basic AI (state machine and pathfinding)
Config File Processing
Logging
Input from a mouse, keyboard, or Xbox 360 controller
Binding inputs from a config file
Python Scripting
In-Game Console
Some users (including me) have succesfully (without any major problems) compiled it under linux.
I would recommend DISLIN. It's cross platform, has support for many languages, and has very intuitive naming of routines.
Also, just noticed that nobody mentioned PLPLOT, also cross platform, multi lingual ...
Picasso graphic library you can used: cross platform
https://code.google.com/p/picasso-graphic/
A cross platform 2D graphics library for .Net is The Little Vector Library
You could use it in conjunction with Unity 3D (recommended) or Xamarin, for example, to create 2D graphics on a variety of platforms.

Where can I find a simple graphics C library for writing directly onto a frame? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I need a simple graphics C library to use on a device where I will be writing directly to the frame.
The frame is located in regular memory.
There is no graphics acceleration hardware.
Nothing fancy. I just want to be able to draw lines, circles, OSD stuff like strings as well.
It would be nice to have functions that use good, lean algorithms (my CPU is an ARM9 running at 400MHz).
What are some recommendations for this?
For very simple needs (lines, circles, polygons, text) I have always just made my own. Check out bresenham's algorithm for lines and circles, Wu's modifications for antialiasing on circles and lines.
Gimp will output C code for images, which is what I do for fonts, and drawing them is pretty easy. I have used anti-aliasing (gimp --> grayscale, use the grayscale value as the alpha), but haven't done proportional fonts. They aren't much harder, and can make the display a bit nicer, but I haven't needed them yet.
Polygons are simply multiple lines, and filled polygons are quite fun to implement.
It's not a lot of work, and you'll grow from the experience.
If, however, you decide you want to render SVG or some other complex vector language, then a library is in order. But for simple things, this isn't complex.
-Adam
I'd like to second OpenGL, especially the OpenGL|ES variant.
Here is a link to a Software based OpenGL-Renderer: http://sourceforge.net/projects/ogl-es
I've spend the last three years writing commercial software rasterization codes on ARM9 and similar processors, so I think I can comment on use of cairo and other high level APIs:
They work very well and are incredible powerfull, but on a target as limited as an ARM9 you will never be happy with the performance. The graphic libs are written with your typical Desktop PC in mind, and they trade precision for performance. This is nice for high quality SVG rendering, but to slow on a humble ARM.
The Vincent OpenGL|ES I've suggested above has a on the fly dynamic code generation engine for ARM-CPUs in place, so you get almost the performance of hand-optimized assembler code.
If you can limit yourself to just one bitmap-format, just two blend-modes and a hand full of rendering primitives you may get better performance by writing a dozen of render-routines yourself. Depending on your experience and requirements that can take anything from two days to a month though..
Cairo is pretty powerful and easy to use. I think Mozilla uses it as the basis for the <canvas> element and the SVG renderer.
From your requirements it appears you need something like an embedded framebuffer library (or whatever it is called). I played around with some of the following a few years back for an embedded browser (which didn't make it to the market). Unfortunately, I can't remember much to give you any analysis. Have a look:
DirectFB
GTK/X (or a port using directFB)
Cairo (as another poster has suggested -- this is very powerful)
Also, this article may be of interest.
Try SDL. From the web page:
Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power."
OPenGL has a set of 2d functions, not sure if it is too bloated for you or if it can be trimmed down. It is written in C, at least.
I found the Adafruit GFX library to my liking.
Very very simple and basic:
https://github.com/adafruit/Adafruit-GFX-Library

Resources