Click here to Skip to main content
15,887,344 members
Home / Discussions / C#
   

C#

 
GeneralRe: Capturing from Webcam without preview to the user Pin
Paul Conrad7-Sep-15 7:21
professionalPaul Conrad7-Sep-15 7:21 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:23
mvePete O'Hanlon6-Sep-15 23:23 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:32
Sultan Uz Zaman6-Sep-15 23:32 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:37
mvePete O'Hanlon6-Sep-15 23:37 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:47
Sultan Uz Zaman6-Sep-15 23:47 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon7-Sep-15 0:12
mvePete O'Hanlon7-Sep-15 0:12 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman7-Sep-15 4:43
Sultan Uz Zaman7-Sep-15 4:43 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:38
Sultan Uz Zaman6-Sep-15 23:38 
Please find below the extarct of my application where the stream is stored in an image control named frameHolder and function SavePic grabs the current frame and save it to disk. frameHolder is shown on the Main Window. Making it invisible captures blank picture.

MainWindow.xaml.cs

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
LoaclWebCamsCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
LocalWebCam = new VideoCaptureDevice(LoaclWebCamsCollection[0].MonikerString);
LocalWebCam.DesiredFrameSize = new System.Drawing.Size(320, 240);

//MessageBox.Show(LocalWebCam.DesiredFrameSize.ToString());
LocalWebCam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);

LocalWebCam.Start();


}

void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
BitmapImage bi = new BitmapImage();
try
{
img = (Bitmap)eventArgs.Frame.Clone();

MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);


bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();

bi.Freeze();
Dispatcher.BeginInvoke(new ThreadStart(delegate
{
frameHolder.Source = bi;
}));

}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "NW CDM Test of Image Capture Failed");
}
}
Sultan Uz Zaman at 4 hrs ago
Reply Modify the comment. Delete the comment.
A button click event does the follwoing to save the pic:

public static void SavePic(string imageFile)
{
//Cam_NewFrame(null,null);
//image1.Source = frameHolder.Source;
//Image frame = frameHolder.Cam_NewFrame(null,null);
// Release any previous buffer


MainWindow myWin = Application.Current.MainWindow as MainWindow;
RenderTargetBitmap bitmap = new RenderTargetBitmap(320, 240, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(myWin.frameHolder);


using (FileStream stream = File.Create(Global.xImageLocation+"\\"+imageFile)) // or .png
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.QualityLevel = 90;
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(stream);
}
}
QuestionRe: Capturing from Webcam without preview to the user Pin
Paul Conrad7-Sep-15 7:19
professionalPaul Conrad7-Sep-15 7:19 
Questionsystem.drawing.image.fromstream ......... Pin
Member 119583516-Sep-15 9:08
Member 119583516-Sep-15 9:08 
AnswerRe: system.drawing.image.fromstream ......... Pin
Pete O'Hanlon6-Sep-15 10:32
mvePete O'Hanlon6-Sep-15 10:32 
GeneralRe: system.drawing.image.fromstream ......... Pin
Member 119583516-Sep-15 18:20
Member 119583516-Sep-15 18:20 
AnswerRe: system.drawing.image.fromstream ......... Pin
OriginalGriff6-Sep-15 21:02
mveOriginalGriff6-Sep-15 21:02 
QuestionSendKeys.Send Acting strangely Pin
goldsoft6-Sep-15 8:54
goldsoft6-Sep-15 8:54 
QuestionMessage Closed Pin
5-Sep-15 19:12
Sultan Uz Zaman5-Sep-15 19:12 
QuestionRe: Using WFP application for webcam. I do not want to show the image control on window. Using a function from pages to capture the image on certain occassion and save it. Pin
Paul Conrad6-Sep-15 7:38
professionalPaul Conrad6-Sep-15 7:38 
AnswerRe: Using WFP application for webcam. I do not want to show the image control on window. Using a function from pages to capture the image on certain occassion and save it. Pin
Sultan Uz Zaman6-Sep-15 16:11
Sultan Uz Zaman6-Sep-15 16:11 
GeneralRe: Using WFP application for webcam. I do not want to show the image control on window. Using a function from pages to capture the image on certain occassion and save it. Pin
Pete O'Hanlon6-Sep-15 23:21
mvePete O'Hanlon6-Sep-15 23:21 
GeneralRe: Using WFP application for webcam. I do not want to show the image control on window. Using a function from pages to capture the image on certain occassion and save it. Pin
Paul Conrad7-Sep-15 6:19
professionalPaul Conrad7-Sep-15 6:19 
QuestionHow can i get complex matrix svd(singlar value decompostion) lib? Pin
smallkubi5-Sep-15 17:45
smallkubi5-Sep-15 17:45 
QuestionSubreport in SSRS is getting error when calling throuch C# windows application Pin
hishamkmr4-Sep-15 22:19
hishamkmr4-Sep-15 22:19 
QuestionUse cutter for cut an image(.svg) with a definition layout image by winform (C#) Pin
phinq19104-Sep-15 16:32
professionalphinq19104-Sep-15 16:32 
AnswerRe: Use cutter for cut an image(.svg) with a definition layout image by winform (C#) Pin
OriginalGriff4-Sep-15 21:48
mveOriginalGriff4-Sep-15 21:48 
GeneralRe: Use cutter for cut an image(.svg) with a definition layout image by winform (C#) Pin
phinq19105-Sep-15 7:41
professionalphinq19105-Sep-15 7:41 
GeneralRe: Use cutter for cut an image(.svg) with a definition layout image by winform (C#) Pin
Dave Kreskowiak5-Sep-15 10:52
mveDave Kreskowiak5-Sep-15 10:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.