Jordan
Asked — Edited
Resolved Resolved by DJ Sures!

Wireless Camera C# Question

Hi, can anyone help me to as in why my camera doesnt load in C# when I execute ? I wrote a C# program that basically detects the cameras on my laptop and then displays video, my built in camera works, but when I load the wireless camera the program terminates and no errors.. here s my code that I included, hopefully someone could answer this

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using AForge.Video; using AForge.Video.DirectShow; namespace EZFirst { public partial class Form1 : Form {

    private FilterInfoCollection VideoCapture;
    private VideoCaptureDevice FinalVideo;
    public Form1()
    {
        InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
        VideoCapture = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo videoCaptureDevice in VideoCapture) {

            comboBox1.Items.Add(videoCaptureDevice.Name);
            comboBox1.SelectedIndex = 0;
            FinalVideo = new VideoCaptureDevice();
        
        }

        hScrollBar1.Value= EZ_B.Servo.SERVO_OFF;
        trackBar1.Minimum = EZ_B.Servo.SERVO_MIN;
        trackBar1.Maximum = EZ_B.Servo.SERVO_MAX;
        trackBar1.Value = EZ_B.Servo.SERVO_CENTER;

    }

   

    private void trackBar1_Scroll(object sender, EventArgs e)
    {
        ezB_Connect1.EZB.Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D0,trackBar1.Value);
    }

    private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
    {
        ezB_Connect1.EZB.Servo.SetServoSpeed(EZ_B.Servo.ServoPortEnum.D0, hScrollBar1.Value);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (FinalVideo.IsRunning == true) {
            FinalVideo.Stop();
        }

        FinalVideo = new VideoCaptureDevice(VideoCapture[comboBox1.SelectedIndex].MonikerString);
        FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
        FinalVideo.Start();
    }

    void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Bitmap video = (Bitmap)eventArgs.Frame.Clone();


        pictureBox1.Image = video;
        }
}

}


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
Synthiam
#1  

Have you looked at the example for camera usage in the EZ-SDK zip file. There are examples of how to use the camera. :)

Jordan
#2  

yes I have, but there like 48 tutorials, could you tell which ones has to do with setting the camera to work in C# ? like I don't want to track objects or anything complex, I just want to camera to display the live video on a panel.

I'll do the servos and movements and tracking in another project. Let me know Thanks

PRO
Synthiam
#3  

Tutorial 11 - Color Vision Tracking ... is a good place to start :)

Jordan
#4  

I got it to work buddy, thanks :)