|
I'm seeking a video encoder software for a camera control system.
The video encoder should provide an SDK and it should be able to support video streaming's buffer size less than 1s or near real time.
Could you please recommend some alternatives (open source/commercial)?
|
|
|
|
|
Would you be able to recommend a virtual camera utility (freeware/shareware)?
The utility needs to be able to read in an video file (such as video.avi) and outputs the video stream as a virtual camera device.
|
|
|
|
|
Until now i used the blend function glBlendFunc(GL_SRC_ALPHA,GL_ONE) to use transparency. But the problem with that is that although it blends black with the background to make it transparent it also blends all colours. That is, it adds the colour with the background colour so black becomes transparent but red blended with green(?) will give white.
The point is that i don't want to blend all colours but simply make a vertex/poly transparent if i set the colour to glColor4f(red, green, blue, alpha) so that the image will have the colour (red,green,blue) but also transparent, instead of blending red, green and blue if you know what i mean.
Here are the params i set on init (if it helps):
glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glDepthFunc(GL_LEQUAL);
glEnable(GL_COLOR_MATERIAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
Can anyone help me please?
----------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
VizCoder wrote: to use transparency.
the question is actually more complex than you think. OpenGL doesn't know how to do transparency. "Alpha blending" applies a mathematical function to the source and destination values of color from raster buffer to new data, to achieve a "similar" appearance. You can do better than this and get close to true transparency, but you must get smart on ordering of your scene and combination of blends. You've already realized that color add goes high to white which may not be the look you want. There are other blending functions, combining them with ordered triangles, you can get the look you want through design more than automation. True OpenGL transparency takes a bit of thought and work.
http://www.opengl.org/resources/faq/technical/transparency.htm[^]
http://www.derivativeinc.com/Tools/Touch000/Manual/Tips/011_AlphaBlending/AlphaBlending.asp[^]
http://www.sjbaker.org/steve/omniv/alpha_sorting.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I know about sorting the vertices and all that. That's not my problem. Why can't OpenGL simply blend the colour with the alpha value so that an alpha of 1.0 will mean (r,g,b) stays as (r,g,b) but alpha of 0.5 will blend 1/2 the red of the source with 1/2 the red of the dest (& same for green & blue). I keep reading that glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) does that trick but it doesn't work for me. Black came out as black even when alpha was at 0.
Or am i just doing something wrong?
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
The problem is that blending really doesn't know all that goes into the accumulation of color in the raster image. This is where some of the other layers come in. You can utilize a overlay or underlay to improve blending by providing a forced layer of "this is different than that". have you tried the blend program from the Red book on opengl? http://cs-sdl.sourceforge.net/index.php/Red_Book_Chapter_07[^] http://www.opengl.org/resources/code/samples/redbook/[^]
The issue is complicated because of performance consideration. True blending would mean that all objects are blended independently on their own layer such that the blend of background and foreground and even midground can all be weighted appropriately. But it doesn't work that way since all we have is a raster "destination" plane and a source object. Once the blend operation is finished the net result is a new destination plane (the raster plane) and all you can do is change the calculation and whether or not you write to the z-buffer which prevents something else from blending.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I really don't know anything about OpenGL. I just want to create transparent areas (among other things) so could you please just tell me how to make an area transparent. It must be possible since many games do it (like car windows).
See this picture: http://img187.imageshack.us/my.php?image=alphale2.png[^]
which shows what i am getting when i use the blend functions. The edges of the wave (which is from Windows Media Player) should fade to transparent. The edges are (0,0,0,0) and the inside is (r,g,b,1).
If you can't help me then i guess the second image (GL_SRC_ALPHA, GL_ONE) look good enough.
thanks
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
VizCoder wrote: which shows what i am getting when i use the blend functions.
I am not positive what the issue is, have you set your driver renderings to quality? are you blending these via vertex coloring or via alpha textures? I understand you don't want to learn all the hardware dependant modes of alpha blending, and only want to do transparency, but the problem is how to do transparency correctly.
When you see see light through a transparent window you see a mixture of different High Dynamic events. You may not realize it, and you may not care, but when you have to model this on a computer, you really need to care. Yes people do transparency, I do it regularly via Z-sorting. Worse, I do it with plane canopies. Why is that worse? because half the canopy is behind the cockpit. The cockpit exists between two transparent volumes. So now I must sort such that without loosing bits in a blending environment, one half of the canopy is merged with the background earth image, then the cockpit is drawn, and then the other half of hte canopy is merged with the after-rending result of the previous operations.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
El Corazon wrote: are you blending these via vertex coloring or via alpha textures?
I am blending via vertex colouring. And you're right, i don't really care about all of the High Dynamic events. I do a Computer Science degree at uni but graphics is not one of my courses. I am just doing this as a hobby because i like graphics. So i really shouldn't waste my time learning about OpenGL lighting effects (i might read up on it on the holidays). I guess i will just use GL_SRC_ALPHA, GL_ONE for now, as long as i don't blend many colours at once and end up with a white screen!
thanks for your help anyway
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
I've been using CastorTiu's amazing IconLib in my application.
http://www.codeproject.com/cs/library/IconLib.asp
He has a function in the library that adds an image to an icon. It can add images of many different bit types and they all work fine except for 8bit images. When 8 bit images go through this code which reproduces a full palette the for loop iterates 256 times and this causes the program to go unresponsive for too long... It does eventually finish but only after nearly freezing the program for a few seconds. I was wondering if anyone knew of an alternative for creating a full palette that isn't so intensive on the system.
Here is the function that causes the delays with 8bit images but not 4bit [16 iterations] or 32 bit [skips loop altogether]
public static RGBQUAD[] RGBQUADFromColorArray(Bitmap bmp)<br />
{<br />
int bits = Tools.BitsFromPixelFormat(bmp.PixelFormat);<br />
RGBQUAD[] rgbArray = new RGBQUAD[bits <= 8 ? (1 << bits) : 0];<br />
for(int i=0; i < bmp.Palette.Entries.Length; i++)<br />
{<br />
rgbArray[i].rgbRed = bmp.Palette.Entries[i].R;<br />
rgbArray[i].rgbGreen= bmp.Palette.Entries[i].G;<br />
rgbArray[i].rgbBlue = bmp.Palette.Entries[i].B;<br />
}<br />
return rgbArray;<br />
}
|
|
|
|
|
Hmm that loop should take under a millisecond if bmp.Palette.Entries.Length is 256.
Are you positive that's where time is being consumed (on the thread executing the loop)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Positive... I stepped through the entire thing and the slowdowns happen during the iterations of the loop.
Happens in my program and just to make sure it wasn't something I did, I loaded up the IconLib project itself and passed it an 8bit image and had the same problem.
|
|
|
|
|
This sounds kinda strange...
Copying 1 byte from one location to another 768 times shouldn't take long (unless you have a
REALLY slow machine. I'm pretty sure the original PC at 4.77 MHz could do it in under a
millisecond
If you break execution when it stalls is it really in the loop or is it maybe in the
Tools.BitsFromPixelFormat(bmp.PixelFormat) call.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Machine can more than handle this that's why I posted the question because it's so strange... Yes it does stall during the loop not during the bitsfrompixel
Bits from pixel is just a simply switch anyway
public static int BitsFromPixelFormat(PixelFormat pixelFormat)<br />
{<br />
switch (pixelFormat)<br />
{<br />
case PixelFormat.Format1bppIndexed:<br />
return 1;<br />
case PixelFormat.Format4bppIndexed:<br />
return 4;<br />
case PixelFormat.Format8bppIndexed:<br />
return 8;<br />
... etc.
|
|
|
|
|
Here's a picture of my actual breakpoints...
http://wwwp.mirror.waffleimages.com/files/13/13e214fd705683442d70081bb7c901230aac708a.png
With the wya they are setup in the picture it takes a while to manually step through 256times but it reaches the end eventually and all is fine... But only because it took some time to do manually.
If I remove the breakpoints on i < bmp.Palette.Entries.Length; and i++; the stall happens directly between int i=0; and return rgbArray;
There isn't any further question in my mind that something is going wrong during that palette copying inside that loop. But the real question is why? This machine is a beast and the rest of the code is fine just for somereason 256 iterations of
rgbArray[i].rgbRed = bmp.Palette.Entries[i].R;<br />
rgbArray[i].rgbGreen= bmp.Palette.Entries[i].G;<br />
rgbArray[i].rgbBlue = bmp.Palette.Entries[i].B;
stalls the program for 30 seconds or so.
|
|
|
|
|
I'm wondering if it's reallocating/recreating a new palette every time the Palette property is
accessed.
Maybe the optimized loop I posted below will help
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hmmm...
Is this managed C++? If so, does optimizing the loop help any?
public static RGBQUAD[] RGBQUADFromColorArray(Bitmap bmp)
{
int bits = Tools.BitsFromPixelFormat(bmp.PixelFormat);
if (bits <= 8)
{
RGBQUAD[] rgbArray = new RGBQUAD[1 << bits];
ColorPalette ^palette = bmp.Palette;
array<Color>^palcolors = palette->Entries;
for(int i=0; i < palcolors->Length; i++)
{
rgbArray[i].rgbRed = palcolors[i].R;
rgbArray[i].rgbGreen= palcolors[i].G;
rgbArray[i].rgbBlue = palcolors[i].B;
}
return rgbArray;
}
return 0;
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
You should be able to do the same thing. The point is, pull the Palette and Palette.Entries
property accesses OUT of the loop and loop through the entries array only.
Sorry I don't know the syntax - it should be simple for you I would think
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Wow that worked... You're a lifesaver and a genius.
I wouldn't have thought that could fix it either but I was willing to try anything, so thanks for suggesting what I thought didn't matter.
|
|
|
|
|
Cool! I had no idea using the properties in the loop would be that slow!
Good to know!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'll take a WILD stab at the C# syntax LOL...
public static RGBQUAD[] RGBQUADFromColorArray(Bitmap bmp)
{
int bits = Tools.BitsFromPixelFormat(bmp.PixelFormat);
if (bits <= 8)
{
RGBQUAD[] rgbArray = new RGBQUAD[1 << bits];
ColorPalette palette = bmp.Palette;
Color[] palcolors = palette.Entries;
for(int i=0; i < palcolors.Length; i++)
{
rgbArray[i].rgbRed = palcolors[i].R;
rgbArray[i].rgbGreen= palcolors[i].G;
rgbArray[i].rgbBlue = palcolors[i].B;
}
return rgbArray;
}
return 0;
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yep you got it, same thing I translated your C++ to.
In case you didn't see my above reply... You got it fixed thanks so much.
|
|
|
|
|
Hi fellows!
Did anyone of you ever something like a winamp credit window? (the 3D credits viewer when you click on "Nullsoft Winamp..." in the context menu).
Anyone seen some code for doing this in .NET?
Thank's in advance,
Stevie
|
|
|
|
|
SCENARIO
I have been learing to use C# and DirectX via small programs using the Express edition of c# 2005.
To take what I have learn't further I have decided to develop a small engine, it is nothing fancy and so far it is only Direct Draw, just developing my skills.
I have developed the engine as a class library that has methods such as
Graphics2D=sets up direct draw and creates 2 surfaces for double buffering
LoadImage=loads a file into an offscreen surface array and returns the index
LoadAnimImage=same but creates a frame array and color key for transparency
DrawImage(Index,etc)=Draws the indicated image from the surface array.
there is also an overloaded DrawImage which has a frame parameter added for drawing animations.
I also have a testing project that references the dll and uses its methods to show a scrolling background and an animated walking character with music.
MY PROBLEM
OK, all is working well, except that my surface array is static in the number of elements it has.
Here is the code that relates to my question
private Surface[] ImgList = new Surface[2];
public int LoadImage(string FileName)
{
sDesc.Clear();
sDesc.SurfaceCaps.OffScreenPlain = true;
ImgList[NumImages] = new Surface(FileName, sDesc, dddevice);
NumImages+= 1;
return NumImages;
}
public void DrawImage(int Image,int x,int y)
{
ssurf.DrawFast(0, 0, ImgList[Image-1],ImageRect,DrawFastFlags.DoNotWait);
}
As I said, the above works fine, but I now want to make the surface array dynamic using the ArrayList from the system.collection namespace
and here is my attempt
ArrayList al = new ArrayList();
public int LoadImage(string FileName)
{
sDesc.Clear();
sDesc.SurfaceCaps.OffScreenPlain = true;
al.Add(new Surface(FileName, sDesc, dddevice));Add a surface to the array
NumImages+= 1;
return NumImages;
}
public void DrawImage(int Image, int x, int y)
{
ssurf.DrawFast(0,0,al[Image-1],ImageRect,DrawFastFlags.DoNotWait);
}
When I build that I get
cannot convert from system.array to microsoft.directx.directdraw.surface
error, among others which are related to the above error.
The error occurs in the DrawImage method
From the article I read about ArrayList collections I got the impression that the elements added to in an ArrayList could be of any type. Obviously I am mistaken, I only have a vague understanding of collections.
Can someone please tell me
What am I doing wrong ?
and more importantly for me, how can I make the above work?
Any help would be much appreciated.
-- modified at 17:23 Sunday 3rd June, 2007
|
|
|
|