// the recording thread main loop
        public void mainLoop()
        {
            OutOfRecordingThread = false;
            ManagedImage rawImage = new ManagedImage();
            ManagedImage convertedImage = new ManagedImage();
            GPSDataInstance newGpsData;

            while (RecordingThreadActive)
            {

                // 1. retrieving a frame from the buffer

                if ((Flag_GravityFound_Y && (IMUcomms != null)) || (IMUcomms == null)) // record only if gravity is found or if there is no IMU
                {

                    FrameQueue.add(Cam);
                    //Cam.RetrieveBuffer(rawImage);

                    // increasing frame index
                    FrameIndex++;

                    //tempImage = new ManagedImage(rawImage);

                    //FrameQueue.add(tempImage);

                    //FrameQueue.Buffer[FrameQueue.last].Convert(PixelFormat.PixelFormatBgr, convertedImage);
                    //System.Drawing.Bitmap bitmap = convertedImage.bitmap;
                    //DisplayPicture.Image = (Image)convertedImage.bitmap;

                    // adding gps data in the GPS data list
                    if (GpsReceiver != null)
                    {

                        newGpsData = new GPSDataInstance(FrameIndex,
                                                         GpsReceiver.LatitudeAsDecimal,
                                                         GpsReceiver.LongitudeAsDecimal,
                                                         GpsReceiver.SpeedOverGround,
                                                         GpsReceiver.CourseOverGround,
                                                         GpsReceiver.MRCStatus);
                        GpsCaptureData.Add(newGpsData);
                    }

                }

            }

            DisplayPicture.Image = null;
            OutOfRecordingThread = true;
        }
 //getGPSdata opverloaded to include a given frameindex
 public GPSDataInstance getGPSDataInstance(int frameindex)
 {
     GPSDataInstance gpsdata = new GPSDataInstance(frameindex, LongDegrees, LongMinutes, LongDeciminutes,
                                                       LatDegrees, LatMinutes, LatDeciminutes,
                                                       SpeedOverGround,
                                                       CourseOverGround,
                                                       MRCStatus
                                                       );
     return gpsdata;
 }
 public FrameData(ManagedImage img, GPSDataInstance gpsData)
 {
     Img = img;
     GPSData = gpsData;
 }