-2

I have two class Mainwindow and Mini_Screen which derive from Window class.i want to access image variable to another class and how video stream.here is the code

public partial class MainWindow : Window
{
public static Image<Bgr, Byte> contour_Frame;
public void Bu_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
FinalFrame = new VideoCaptureDevice(CaptureDevice[Camera_ComboBox.SelectedIndex].MonikerString);
FinalFrame.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
FinalFrame.Start();
}
void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Imgbox1.Image = skin;
}
}

second class

public partial class Mini_Screen : Window
{
public Mini_Screen()
{     InitializeComponent();
Imgbox2.Image = MainWindow.emgu_img;
}
}

i did that but i just see one capture image in Imgbox2. I want video streaming like in imgbox1. Plz Help, i hope you understand my question

1 Answers1

-1

You don't say where you're instantiating your 2 screens from but as it's MainWindow I'll assume that Mini_Screen is instantiated there.

It's very simple to achieve with a Property.

Here's your adjusted MainWindow

public partial class MainWindow : Window
{
    public static Image<Bgr, Byte> contour_Frame;
    public Mini_Screen subwindow;

    public void MainWindow_Load(object sender, EventArgs e)
    {
        subwindow = new MiniScreen();
        subwindow.Show();
    }

    public void Bu_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        FinalFrame = new VideoCaptureDevice(CaptureDevice[Camera_ComboBox.SelectedIndex].MonikerString);
        FinalFrame.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
        FinalFrame.Start();
    }

    void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Imgbox1.Image = skin;
        subwindow.DisplayImage = skin;
    }
}

Then your adjusted Mini_Screen

public partial class Mini_Screen : Window
{
    public Image DisplayImage
    {
        set
        {
            Imgbox2.Image = value;
        }
    }

    public Mini_Screen()
    {
        InitializeComponent();
    }
}

Now when the NewFrame event fires it will set the DisplayImage property to your new image which in turn will set the ImgBox2.Image to the generated image.

Handbag Crab
  • 1,488
  • 2
  • 8
  • 12