hi there.

i need help in making my code work.
i will briefly discuss the output that is needed.

currently, i have 5picboxes that s'pose to relate to the frame that has been grab from the frame grabber. when i click, btnTrack5frames, the program suppose to capture image by image into the picboxes in a 2sec interval.

unfortunately, the code that i've used do not give me the right output. instead, the first image grabbed was shown on all the picboxes and it continue to change the image for every few sec.

here is the code that i have written:

private void grab5frames_Click(object sender, EventArgs e)
        {
            timer2.Enabled = true;
        }  

 private void timer2_Tick(object sender, EventArgs e)
        {

            v = 1;

            if (v <= 5)
            {

                if (v == 1 && time == true)
                {
                    time = false;
                    if (fg.GrabImage() == true)
                    {
                        picbox1.Image = fg.bmp;
                     }
                    time = true;
                    v++;

                }

                if (v == 2 && time == true)
                {

                    time = false;
                    if (fg.GrabImage() == true)
                    {
                        picbox2.Image = fg.bmp;                     
                    }
                    time = true;
                    v++;

                }

                if (v == 3 && time == true)
                {
                    time = false;
                    if (fg.GrabImage() == true)
                    {
                        picbox3.Image = fg.bmp;
                     }
                    time = true;
                    v++;
                }
                if (v == 4 && time == true)
                {
                    time = false;
                    if (fg.GrabImage() == true)
                    {
                        picbox4.Image = fg.bmp;
                     }
                    time = true;
                    v++;
                }
                if (v == 5 && time == true)
                {
                    time = false;
                    if (fg.GrabImage() == true)
                    {
                        picbox5.Image = fg.bmp;
                    }
                    time = true;
                }

                else if (v >= 6)
                {

                    timer2.Enabled = false;
                }
            }
}

do pls help.
thank you.

Well I think the reason it is only showing the one picture is because for each picture box you are assigning fg.bmp.
You said that you want each image to show up 2 seconds later but I don't see any timers in there.

Wouldn't it be easier to do away with the if statements and just assign each picturebox to whatever picture you want, sleep for 2 seconds and then move on to the next one?

I don't really understand what

if (fg.GrabImage() == true)

is for. Is that ever going to be false and what should be happening if it is?

Hope that is of some help. If you have any more questions please ask.

if (fg.GrabImage() == true)

this code is meant for the function to grab an image from the framegrabber.

i ever did using one timer for every picture grabbing but the image was not stored. the images will change to be the same for all 5 picboxes after the 10th second.

Not sure. Maybe if you assign the fg back to null and then grab a new frame it will update the picture.

This article has been dead for over six months. Start a new discussion instead.