|
Hi there,
I'm working on a project to finding the depth from a 3D stereo Camera.
I have been advices to use "ch professional 6.1" with two usb cameras. Can anyone please point me or send me a complete code that reads from these two cameras and give me the stereo picture. I just want to concentrate on my work... finding depth.
Many thanks in advance
Sarkuzi
|
|
|
|
|
sarkuzi wrote: Can anyone please point me or send me a complete code that reads from these two cameras and give me the stereo picture. I just want to concentrate on my work... finding depth.
I'm not sure anything like that exist and if it does I kind of doubt that it would be totally reliable in real world situations without some human intervention. The problem I see is that there still is not an AI algorithm that can divide an image perfectly into different objects and object recognition is still a work in progress too. These would be needed for a computer to match the objects from the 2 webcams and then compare the differences in the 2 images to find depth. The only way it might be able to do this I would think is if you had a scene with no gradual transitions between colors of 2 different objects (this rarely exist in real world images but if you made an artificial scene it might work).
There are libraries available (such as the opencv library) that can help you alot to get the input of webcams if you don't mind writing some code. If you are looking for a stereo webcam I did find this on the internet one time http://www.minoru3d.com/[^] but I've never actually used it or tried it.
hope this helps,
Mike
|
|
|
|
|
I've been doing the same recently in c++ with Unity3d in mind, mainly for windows/vista, I suggest the video capture library found:-
www.muonics.net/school/spring05/videoInput/
or CodeVis library by mike ellis also very good, but not so hot with two cameras unless you want to start fiddling with the threading and serialisation.
Once you have the camera images into memory try passing them to open CV for starters (cvstereocorrespondance), if you wish to do realtime you will have to look a bit further, middlesbury college or uni have some stereo matching links to try, plus you could even look at CUDA by nvidea, but this then becomes graphics card capability based.
As soon as I've got my code reasonably working reasonably well I will either provide the code, or list the method code and cite the sources (depends on what licenses I'm restricted by at the time!
|
|
|
|
|
I'm trying to recreate this gradient pattern with GDI+ using C#:
Metal Circle[^]
My approach is to use a PathGradientBrush and define eight points around the circle where the gradient fades from one color to the next. Here's the results I've gotten so far (ignore the blue background and how the circle is cut off at the edges):
Metal Circle Test[^]
The problem seems to be the way the colors blend; the change in shading is too abrupt. So I'm looking for clues and pointers on how to improve my results. I'm studying the Blend property of the PathGradientBrush, but it's taking some time to wrap my head around it.
|
|
|
|
|
Hi Leslie,
I am not very familiar with gradient brushes, and didn't manage to get an angular one; all I tried resulted in radial gradients. So I tried it without gradients, and came up with a square cosine function; try the following in the Paint handler of some Control, say a Panel:
Graphics g=e.Graphics;
int cx=pan.Width/2;
int cy=pan.Height/2;
int r=cx;
if (r>cy) r=cy;
r-=20;
int t=cx/64;
if (t<2) t=2;
g.TranslateTransform(cx, cy);
int darkest=80;
int lightest=255;
for (int i=0; i<=90; i+=1) {
double cos=Math.Cos(i*Math.PI/180);
int c=darkest+(int)((lightest-darkest)*cos*cos);
Brush brush=new SolidBrush(Color.FromArgb(c,c,c));
int j=i+45;
g.RotateTransform(j);
g.FillRectangle(brush, -r, -t, 2*r, 2*t);
g.RotateTransform(-j);
j=225-i;
g.RotateTransform(j);
g.FillRectangle(brush, -r, -t, 2*r, 2*t);
g.RotateTransform(-j);
brush.Dispose();
}
BTW: the code is rather expensive, however you could turn the result into a bitmap and use that.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks, Luc. That's very close to what I'm looking for. I like your use of the cosine function. ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
You're welcome.
I would be interested to what you end up with.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I forgot to ask, how did you create your circle with gradient? I'd like to see the code that generated it, maybe I could still come up with a cheaper approach than painting all those rectangles...
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Luc Pattyn wrote: forgot to ask, how did you create your circle with gradient? I'd like to see the code that generated it, maybe I could still come up with a cheaper approach than painting all those rectangles...
What I have is a Circle class for drawing the actual circle. The idea being that I'll eventually have classes for other shapes and create controls that are composed of these objects that know how to paint themselves. With that in mind, here's some code from the circle class for creating the brush used for painting it:
private void CreateBrush()
{
if(brush != null)
{
brush.Dispose();
}
Rectangle r = new Rectangle(Location, Size);
PointF[] ptsF =
{
new PointF(0, 0),
new PointF(r.Width / 2, 0),
new PointF(r.Width, 0),
new PointF(r.Width, r.Height / 2),
new PointF(r.Width, r.Height),
new PointF(r.Width / 2, r.Height),
new PointF(0, r.Height),
new PointF(0, r.Height / 2)
};
brush = new PathGradientBrush(ptsF);
Color[] colors =
{
Color.Gray,
Color.White,
Color.Gray,
Color.DarkGray,
Color.Gray,
Color.White,
Color.Gray,
Color.DarkGray
};
brush.SurroundColors = colors;
brush.CenterColor = Color.White;
}
Basically, I was just trying to get the algorithm right; then I'd factor out the code into a "MetalCircle" class or whatever.
I think the Blend property may be key to improving the look.
|
|
|
|
|
Hi Leslie,
I combined your and my techniques, and now have a metallic circular brush that can be reused since it scales with the Graphics:
PathGradientBrush brush;
private void makeCircularMetalBrush() {
List<PointF> points=new List<PointF>();
List<Color> colors=new List<Color>();
int darkest=80;
int lightest=255;
double rplus=1.03;
for (int i=0; i<360; i+=5) {
double angle=(i+45)*Math.PI/180;
double cos=Math.Cos(angle);
double sin=Math.Sin(angle);
points.Add(new PointF((float)(rplus*cos), (float)(rplus*sin)));
angle=i*Math.PI/180;
cos=Math.Cos(angle);
int c=darkest+(int)((lightest-darkest)*cos*cos);
colors.Add(Color.FromArgb(c, c, c));
}
brush = new PathGradientBrush(points.ToArray());
brush.SurroundColors = colors.ToArray();
brush.CenterColor = Color.White;
}
private void pan_Paint(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
int cx=pan.Width/2;
int cy=pan.Height/2;
int r=cx;
if (r>cy) r=cy;
r-=20;
g.TranslateTransform(cx, cy);
g.ScaleTransform(r, r);
g.FillEllipse(brush, new RectangleF(-1, -1, 2, 2));
}
As a result metallic painting has become much cheaper now.
BTW: for larger shapes (e.g. the surrounding rectangle) another brush would be required, since its characteristic points would fall inside the new shape, and whatever is beyond the brush shape would be painted white.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi Luc,
I've put this project aside for now due to other projects taking up my time but may return to it soon. Just wanted to thank you for your example and that I will study it in depth when I start working on it again.
|
|
|
|
|
You're welcome. I wanted to get something done with those strange brush objects anyway. Never had used them before, except for the solid ones of course.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi Leslie,
I just added a new section to my web site, and the metallic circle[^] stuff is now the subject of one of the mini articles you can find there.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Ooooh, shiny!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi All
I am having issue to create URL for webcam. Actually the problem is, i am having 4 webcams i want to make different URLs for each cam, so that one can access my cam using that URL.
Do i need to install some sort of Server or IIS will work for this..
Any anybody having any suggestion or any solution, please let me know.
Thanks
Din
|
|
|
|
|
Hi
When I do File_New -> Attach Image, the image file can be loaded into memory.
But when I do File_open, the image file can not be loaded into memory. I did following:
Gdiplus::Graphics gr(dc);
gr.SetPageUnit(Gdiplus::UnitPixel);
gr.DrawImage(pBmp, p, 3);
What is problem?
Thanks
|
|
|
|
|
I'm trying to create an emboss/bevelled effect on circles and rectangles using C# with GDI+. Here's an example of a circle created with a drawing program with the emboss effect enabled:
Circle[^]
What it looks like to me is that you have two circles. The top circle is smaller and centered on the larger circle below it. Also, there is no shading on the top circle. Below that you have a base, which looks like a circle with a gradient going from light to dark.
Combined they give the overall look of an embossed circle.
Here's a square:
Square[^]
It's a bit more complicated. It looks like the right and bottom corners are quite a bit darker than the left and top corners. That's easy enough to mimic, but there's also something going on with the corners that I'm not sure how to duplicate.
I'm looking for any pointers on doing these types of basic effects with C# and GDI+. I've done some googling, but the results are focused on applying these effects to existing images. Since I'm building primitive shapes from scratch, I figure there are probably easier ways.
modified on Monday, June 8, 2009 8:51 PM
|
|
|
|
|
You're basically trying to simulate a 3D object with the light source in the upper left of the picture. If you want the details, you might search for 3D lighting algorithms. BTW, the link to the picture of your square is broken.
"Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke I'm a proud denizen of the Real Soapbox[ ^] ACCEPT NO SUBSTITUTES!!!
|
|
|
|
|
Tim Craig wrote: BTW, the link to the picture of your square is broken.
Thanks, and fixed. ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Are you looking to create graphical controls on the fly? The gradient idea sounds reasonable. The corners probably aren't that critical if that is the application.
"Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke I'm a proud denizen of the Real Soapbox[ ^] ACCEPT NO SUBSTITUTES!!!
|
|
|
|
|
Tim Craig wrote: Are you looking to create graphical controls on the fly? The gradient idea sounds reasonable. The corners probably aren't that critical if that is the application.
My goal is to create a widget set for Windows Forms (and maybe eventually WPF) made up of knobs, sliders, and quite a few other custom controls. I'm hoping there's a market for this sort of thing. At any rate, I've spent the past couple of years writing VST plugins. In this arena custom UI's are the rule, and I'd like to take the knowledge I've gained creating in creating them and applying that to a .NET custom control library.
Here's an example of a VST UI I created:
Super Filter[^]
It's completely bitmap based.
So I'm trying to get my GDI+ chops up to the point where I can recreate the same level of detail only "on the fly," as you put it. My goal would be a set of controls that are drawn with GDI+ rather than pre-rendered with bitmaps. For examples, say you have a knob control. It would be cool to give it a Bevel property that let you set how beveled the edges looked.
While I have a feel for what makes up an image like a knob, recreating that programmically is another matter. I'm trying to walk the line between getting enough knowledge to do the job and diving headlong into studying mathematically intensive graphics algorithms.
The gradient approach seems ok, but I think I need to tweak how the colors fade a bit instead of relying on the default linear setting. The square shape seems more challenging in that the corners look like they need special care.
Anyway, I didn't mean to write such a long post. But at least you have an idea where I'm coming from. ![Big Grin | :-D](https://www.codeproject.com/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
That's pretty. I used to work with software for controlling instruments but we never tried to replace the front panel. We were sitting on top trying to automate the process. I don't know what kind of market there is for these kinds of widgets but there is one. National Instruments has made a good business out of them with their other offerings.
As far as GDI+ goes, I wonder if you'll have any performance issues since as far as I know, it's still not hardware accelerated. Maybe going to something like OpenGL (or even Direct3D ) and doing it in full 3D might be faster since they are hardware accelerated? I know there are widgets done for OpenGL applications so there is a model. But then all the display is OpenGL.
"Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke I'm a proud denizen of the Real Soapbox[ ^] ACCEPT NO SUBSTITUTES!!!
|
|
|
|
|
I have two threads running in my application , each having its own separate GLX Rendering contexts.
But these two threads share the same window(X window). At start only one thread renders its graphics into the window.
Everythings works fine till this point of time.
Later , this thread's rendering is stopped and new thread(second thread) is created with new rendering context.But this new
rendering context is also attached to the same window.
But when this second thread starts rendering , I see some flickering on the screen.
Can anybody tell me whats happening ?
|
|
|
|
|
Hi all,
I want to Watermark(Overlay) an existing video. I don't want to
capture a new Video . For that I m using DirectShowLib DxText Sample
Application(in C#) for VideoWatermarking on an existing video.
It works fine but it only display the video with watermark as a
preview on screen.
Now I need to save the watermarked video on the disk as a new file.
Video Watermarking is also possible with VMR9Compositor sample code. But same problem is also exist with these code. It Shows only preview.
How can I save the new Video with watermark?
Thanks in Advance
|
|
|
|
|
I am having trouble transforming my objects in world space. Its seemigly simple, but i've tried many thing i found online, and still i cant crack it.
Heres the code:
I have a created cube, and am trying to transform a position matrix just before rendering it.
<per>
D3DXMATRIXA16 matWorld;
D3DXMatrixTranslation(&matWorld,10.0f,10.0f,50.0f);
HR(gd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ));
HR(gd3dDevice->SetStreamSource(0, SphereVertexBuffer, 0, sizeof(VertexPos)));
HR(gd3dDevice->SetIndices(SphereIndexBuffer));
HR(gd3dDevice->SetVertexDeclaration(VertexPos::Decl));
HR(gd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,0,0,num_vertices,0,4*meridians*(parallels-1)));
</per>
The code looks legit to me, so maybe the problem is in some other part of the code, or somehow in the way i set up my world. The world is in right handed coordinate system, i doubt it, buy might this be a problem?
Also another question, when i change the world matrix, as i understand it, EVERYTHING drawn after this is moved right? So i may be moving the ground and everything along with my object? But then againt i can use my camera as reference, and still dont see any displacement!
Any ideas?
ps. I am also using effects(ID3DXEffect*), maybe i need to use its settransform?!
|
|
|
|
|