maulikdantara / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

ArgumentNullException thrown in CountingMotionDetector.CreateMotionZoneFrame() #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce:

        AForge.Vision.Motion.CountingMotionDetector detector;
        detector = new AForge.Vision.Motion.CountingMotionDetector
();                
        PictureBox1.Image = System.Drawing.Image.FromFile("somefile.jpg");
        detector.ProcessFrame(PictureBox1.Image as 
Bitmap);            

-------------------------------------------------------
Exception:

System.ArgumentNullException was unhandled
  Message="Value cannot be null."
  Source="mscorlib"
  StackTrace:
       at System.Threading.Monitor.Enter(Object obj)
       at AForge.Vision.Motion.CountingMotionDetector.CreateMotionZoneFrame
()
       at AForge.Vision.Motion.CountingMotionDetector.ProcessFrame(Bitmap 
image)

-------------------------------------------------------

Code location:

CountingMotionDetector.cs
-------------------------

        private unsafe void CreateMotionZoneFrame( )
        {
-->         lock ( motionZones )
            {
                // free motion zones frame if required
                if ( ( motionZones == null ) && ( zonesFrame != 
IntPtr.Zero ) )

-------------------------------------------------------

AForge.Vision Version: 1.5.1.0
AForge.Imaging Version: 1.6.2.0

-------------------------------------------------------

Comments:

Null exception happens during the first-ever call to 
CountingMotionDetector.ProcessFrame() on the lock() stmt when ProcessFrame 
calls CreateMotionZoneFrame().

I dont know of any preconditions for user code to perform in advance that 
might help prevent the problem or work around.

The code line immediately following the exceptioning lock() stmt is 

if ( ( motionZones == null )

This code line can never be reached, due to exception during lock stmt on 
previous line when the motionZones is null.

Thanks for reading

Look forward to usage advice or fix, either one would be cool.

Original issue reported on code.google.com by geoffrey...@gmail.com on 8 Apr 2008 at 12:49

GoogleCodeExporter commented 8 years ago
The quick fix on user's side will be to set one motion zone with the size of 
entire 
frame.

Original comment by andrew.k...@gmail.com on 8 Apr 2008 at 6:03

GoogleCodeExporter commented 8 years ago
Motion zone routines are updated to lock motion detector object (this) instead 
of 
motionZones variable since it may be null and lead to exception

Committed in revision 476. Will be released in version 1.6.3

Original comment by andrew.k...@gmail.com on 18 May 2008 at 9:29

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 19 May 2008 at 6:01

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 19 May 2008 at 6:08