// the dumping thread loop
        public void dumpingLoop()
        {
            OutOfDumpingThread = false;
            ManagedImage convertedImage = new ManagedImage();
            ManagedImage mgdimg;

            while (!OutOfRecordingThread || (!FrameQueue.isEmpty()))
            {
                // recording the image straight into the file
                if (!FrameQueue.isEmpty())
                {
                    mgdimg = FrameQueue.remove();

                    // displying the image (via the DisplayBitmap)
                    // Convert the raw image
                    mgdimg.Convert(PixelFormat.PixelFormatBgr, convertedImage);

                    DisplayPicture.Image = (Image)convertedImage.bitmap;

                    if (RecordToFile)
                    {
                        AviRecorder.AVIAppend(mgdimg);
                    }
                }
            }
            // displying the image (via the DisplayBitmap)
            // Convert the raw image
            //ManagedImage convertedImage = new ManagedImage();
            //FrameQueue[0].Convert(PixelFormat.PixelFormatBgr, convertedImage);
            //System.Drawing.Bitmap bitmap = convertedImage.bitmap;

            //Image<Bgr, Byte> img = new Image<Bgr, byte>(bitmap);


            //DisplayPicture.Image = (Image)bitmap;



            //if (RecordToFile) AviRecorder.AVIClose();

            //DisplayPicture.Image = null;
            OutOfDumpingThread = true;
        }