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

C#

 
QuestionGet object back from server with .net remoting and Socket connection Pin
MahieuBrecht30-Aug-11 20:03
MahieuBrecht30-Aug-11 20:03 
AnswerRe: Get object back from server with .net remoting and Socket connection Pin
Michael J. Eber8-Sep-11 8:10
Michael J. Eber8-Sep-11 8:10 
Questioncompare two active directory methods Pin
dcof30-Aug-11 11:50
dcof30-Aug-11 11:50 
Questionswitch statement Pin
dcof30-Aug-11 8:31
dcof30-Aug-11 8:31 
AnswerRe: switch statement Pin
PIEBALDconsult30-Aug-11 8:48
mvePIEBALDconsult30-Aug-11 8:48 
AnswerRe: switch statement Pin
OriginalGriff30-Aug-11 9:48
mveOriginalGriff30-Aug-11 9:48 
AnswerRe: switch statement Pin
Dylan Morley1-Sep-11 1:25
Dylan Morley1-Sep-11 1:25 
QuestionC# and USB IR camera Pin
sandy630-Aug-11 2:39
sandy630-Aug-11 2:39 
Hello, i have designed a window in c# which contains one combobox(contains detected USB devices), one picturebox(for the video), one label, one start button(starts the camera)and one refresh button.
I have a USB security IR camera which i want to connect to the computer and hopefully get some video feed in the picturebox.

I have debugged and builded the project and the designed window pops up as it should. When i push the refresh button while the USB camera is connected,it is written in the combobox "USB 2.0 grabber". When i then push the start button nothing happens. Can somebody help me/explain to me how to get the video feed into the picture box? I really appreciate some help. Confused | :confused:

Source code follows:

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Text;  
using System.Windows.Forms;  
   
using AForge.Video;  
using AForge.Video.DirectShow;  
    
namespace cam_aforge1  
 {  
     public partial class Form1 : Form  
     {  
         private bool DeviceExist = false;  
         private FilterInfoCollection videoDevices;  
         private VideoCaptureDevice videoSource = null;  
    
         public Form1()  
         {  
             InitializeComponent();  
         }  
    
         // get the devices name  
         private void getCamList()  
         {  
             try 
             {  
                 videoDevices = new FilterInfoCollection    (FilterCategory.VideoInputDevice);  
                 comboBox1.Items.Clear();  
                 if (videoDevices.Count == 0)  
                     throw new ApplicationException();  
    
                 DeviceExist = true;  
                 foreach (FilterInfo device in videoDevices)  
                 {  
                     comboBox1.Items.Add(device.Name);  
                 }  
                 comboBox1.SelectedIndex = 0; //make dafault to first cam  
             }  
             catch (ApplicationException)  
             {  
                 DeviceExist = false;  
                 comboBox1.Items.Add("No capture device on your system");  
             }  
         }  
    
         //refresh button  
         private void rfsh_Click(object sender, EventArgs e)  
         {  
             getCamList();  
         }  
    
         //toggle start and stop button  
         private void start_Click(object sender, EventArgs e)  
         {  
             if (start.Text == "&Start")  
             {  
                 if (DeviceExist)  
                 {  
                     videoSource = new VideoCaptureDevice(videoDevices[comboBox1.SelectedIndex].MonikerString);  
                     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);  
064                     CloseVideoSource();  
                     videoSource.DesiredFrameSize = new Size(160,120);  
                     //videoSource.DesiredFrameRate = 10;  
                     videoSource.Start();  
                     label2.Text = "Device running...";  
                     start.Text = "&Stop";  
                    timer1.Enabled = true;  
                 }  
                 else 
                 {  
                     label2.Text = "Error: No Device selected.";  
                }  
             }  
             else 
             {  
                 if (videoSource.IsRunning)  
                 {  
                     timer1.Enabled = false;  
                     CloseVideoSource();  
                     label2.Text = "Device stopped.";  
                     start.Text = "&Start";  
                 }  
             }  
         }  
    
         //eventhandler if new frame is ready  
         private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)  
         {  
             Bitmap img = (Bitmap)eventArgs.Frame.Clone();  
             //do processing here  
             pictureBox1.Image = img;  
         }  
    
         //close the device safely  
         private void CloseVideoSource()  
         {  
             if (!(videoSource == null))  
                 if (videoSource.IsRunning)  
                 {  
                     videoSource.SignalToStop();  
                     videoSource = null;  
                 }  
         }  
    
         //get total received frame at 1 second tick  
         private void timer1_Tick(object sender, EventArgs e)  
         {  
             label2.Text = "Device running... " + videoSource.FramesReceived.ToString() + " FPS";  
         }  
    
         //prevent sudden close while device is running  
         private void Form1_FormClosed(object sender, FormClosedEventArgs e)  
         {  
             CloseVideoSource();  
         }  
     }  
 } 
<pre>

AnswerRe: C# and USB IR camera Pin
BobJanova30-Aug-11 4:48
BobJanova30-Aug-11 4:48 
SuggestionRe: C# and USB IR camera Pin
DaveAuld30-Aug-11 6:34
professionalDaveAuld30-Aug-11 6:34 
QuestionPer Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 2:17
Thomas.D Williams30-Aug-11 2:17 
AnswerRe: Per Pixel Access in C# winforms Pin
lukeer30-Aug-11 4:28
lukeer30-Aug-11 4:28 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 5:26
Thomas.D Williams30-Aug-11 5:26 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 7:04
BobJanova30-Aug-11 7:04 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 7:13
Thomas.D Williams30-Aug-11 7:13 
GeneralRe: Per Pixel Access in C# winforms Pin
Pete O'Hanlon30-Aug-11 7:20
mvePete O'Hanlon30-Aug-11 7:20 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 11:17
Thomas.D Williams30-Aug-11 11:17 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 7:38
BobJanova30-Aug-11 7:38 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 11:12
Thomas.D Williams30-Aug-11 11:12 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 23:02
BobJanova30-Aug-11 23:02 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 23:12
Thomas.D Williams30-Aug-11 23:12 
AnswerRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 4:36
BobJanova30-Aug-11 4:36 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 5:30
Thomas.D Williams30-Aug-11 5:30 
QuestionThis collection already contains an address with scheme http. There can be at most one address per scheme in this collection in 3.5 Pin
nitin_ion29-Aug-11 21:33
nitin_ion29-Aug-11 21:33 
AnswerRe: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection in 3.5 Pin
dan!sh 29-Aug-11 22:56
professional dan!sh 29-Aug-11 22:56 

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.