capturing image from web cam

May 8, 2010 at 7:38 PM

Hi, great project.

how can I capture image from web camera?

thanks in advance

May 8, 2010 at 9:18 PM

I just fount solution myself.

please let me know if someone has better idea

DrawingVisual visual = new DrawingVisual();
DrawingContext context = visual.RenderOpen();
VisualBrush elementBrush = new VisualBrush(videoElement);
int w = _width;
int h = _height;
context.DrawRectangle(elementBrush, null, new Rect(0, 0, w, h));
context.Close();
RenderTargetBitmap bitmap = new RenderTargetBitmap(w, h, 0, 0, PixelFormats.Default);
bitmap.Render(visual);
BitmapSource bitmapSource = bitmap;
Image im = new Image();
im.Source = bitmap;

BR

Temo Namoradze

Coordinator
May 8, 2010 at 9:27 PM
RenderTargetBitmap might be easier. Also setting EnableSampleGrabbing and hooking the new frame event on the video capture element should work also.

-Jer

On May 8, 2010, at 2:18 PM, "gteam" <notifications@codeplex.com> wrote:

From: gteam

I just fount solution myself.

please let me know if someone has better idea

DrawingVisual visual = new DrawingVisual();
DrawingContext context = visual.RenderOpen();
VisualBrush elementBrush = new VisualBrush(videoElement);
int w = _width;
int h = _height;
context.DrawRectangle(elementBrush, null, new Rect(0, 0, w, h));
context.Close();
RenderTargetBitmap bitmap = new RenderTargetBitmap(w, h, 0, 0, PixelFormats.Default);
bitmap.Render(visual);
BitmapSource bitmapSource = bitmap;
Image im = new Image();
im.Source = bitmap;

BR

Temo Namoradze

Nov 19, 2013 at 1:17 PM
gteam wrote:
I just fount solution myself. please let me know if someone has better idea DrawingVisual visual = new DrawingVisual();DrawingContext context = visual.RenderOpen();VisualBrush elementBrush = new VisualBrush(videoElement);int w = _width;int h = _height;context.DrawRectangle(elementBrush, null, new Rect(0, 0, w, h));context.Close();RenderTargetBitmap bitmap = new RenderTargetBitmap(w, h, 0, 0, PixelFormats.Default);bitmap.Render(visual);BitmapSource bitmapSource = bitmap;Image im = new Image();im.Source = bitmap; BR Temo Namoradze
I do exactly the same, but approximatly 1 out of 100 pictures are totally black.
What could this be?