Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I try to read a sequence of images to do some process. I don't have any error but when I run it the program stop and gives the error "An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll" and told me that frame is null...I searched about DotImaging but I didn't find anything useful for fixing the error in my code.

What I have tried:

C#
private void button1_Click(object sender, EventArgs e)
        {
            Bgr<byte>[,] frame = null;
            string videoDir = "C:\\pic\\Sequence of mypic";
            videoCapture = new ImageDirectoryCapture(videoDir, "*.jpg");
           
                videoCapture.Open();

                videoCapture.ReadTo(ref frame);
               if (frame == null)
                return;

            videoCapture.Seek(-1, SeekOrigin.Current);

            if (isROISelected)
            {
                
                Application.Idle -= videoCapture_InitFrame;
                Application.Idle += videoCapture_NewFrame;
            }
            else
            {
                frame.Draw(roi, Bgr<byte>.Blue, 3);
            }
            this.pictureBox.Image = frame.ToBitmap(); 

            GC.Collect();
        }
Posted
Updated 17-Oct-19 4:25am
v3
Comments
Richard MacCutchan 17-Oct-19 8:04am    
Which line of code caused the error?
Member 14129828 17-Oct-19 13:10pm    
videoCapture.ReadTo(ref frame);
Richard MacCutchan 17-Oct-19 13:49pm    
Well, you have just set frame = null, four lines previously so using ref makes no sense. The variable needs to be a reference to an actual object for the ref to be used in the called method.
Richard Deeming 17-Oct-19 14:12pm    
Your question seems to be about this article:
Introducing Portable Imaging IO Library for C#[^]

Which is also available on GitHub:
GitHub - dajuric/dot-imaging: Minimalistic .NET imaging portable platform[^]

Either the forum at the bottom of the article, or the "Issues" within the GitHub project, would be the correct place to ask questions about that code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900